Skip to content

Commit

Permalink
test: fix e2e failures and speed up e2e tests (#3483)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Sep 7, 2023
1 parent 085d500 commit 70a6171
Show file tree
Hide file tree
Showing 22 changed files with 289 additions and 91 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
TEST_DATABASE_MYSQL: "mysql://root:test@(localhost:3306)/mysql?parseTime=true&multiStatements=true"
TEST_DATABASE_COCKROACHDB: "cockroach://root@localhost:26257/defaultdb?sslmode=disable"
strategy:
fail-fast: false
matrix:
database: ["postgres", "cockroach", "sqlite", "mysql"]
steps:
Expand Down
14 changes: 11 additions & 3 deletions test/e2e/cypress/integration/profiles/email/login/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ context("UI tests using the email profile", () => {
cy.get(`${appPrefix(app)}input[name="identifier"]`)
.parent()
.should("contain.text", "ID")
cy.get('input[name="password"]')
.parent()
.should("contain.text", "Password")

if (app === "express") {
cy.get('[data-testid="node/input/password"]').should(
"contain.text",
"Password",
)
} else {
cy.get('input[name="password"]')
.parent()
.should("contain.text", "Password")
}
cy.get('button[value="password"]').should("contain.text", "Sign in")
})

Expand Down
13 changes: 10 additions & 3 deletions test/e2e/cypress/integration/profiles/email/settings/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ context("Settings errors with email profile", () => {
cy.get('input[name="traits.website"]')
.parent()
.should("contain.text", "Your website")
cy.get('input[name="password"]')
.parent()
.should("contain.text", "Password")
if (app === "express") {
cy.get('[data-testid="node/input/password"]').should(
"contain.text",
"Password",
)
} else {
cy.get('input[name="password"]')
.parent()
.should("contain.text", "Password")
}
cy.get('button[value="profile"]').should("contain.text", "Save")
cy.get('button[value="password"]').should("contain.text", "Save")
})
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/cypress/integration/profiles/mfa/totp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ context("2FA TOTP", () => {
let password = gen.password()

beforeEach(() => {
cy.longPrivilegedSessionTime()
cy.useLaxAal()
cy.useConfig((builder) =>
builder.longPrivilegedSessionTime().useLaxAal(),
)
email = gen.email()
password = gen.password()

Expand Down Expand Up @@ -276,7 +277,7 @@ context("2FA TOTP", () => {
expect(loc.search).to.not.include("aal")
expect(loc.search).to.not.include("refresh")
})
cy.get("h2").should("contain.text", "Sign In")
cy.get("h2").contains(/Sign in/i)
cy.noSession()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ context("Social Sign In Settings Success", () => {

describe("oidc", () => {
beforeEach(() => {
cy.longRecoveryLifespan()
cy.longVerificationLifespan()
cy.longPrivilegedSessionTime()
cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longVerificationLifespan()
.longPrivilegedSessionTime(),
)
})

it("should show the correct options", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ context("Account Recovery Errors", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.longCodeLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("code")
cy.notifyUnknownRecipients("recovery", false)
cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longCodeLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("code")
.notifyUnknownRecipients("recovery", false),
)
})

it("should invalidate flow if wrong code is submitted too often", () => {
Expand Down
33 changes: 17 additions & 16 deletions test/e2e/cypress/integration/profiles/recovery/code/success.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ context("Account Recovery With Code Success", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.longLinkLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("code")
cy.notifyUnknownRecipients("recovery", false)

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("code")
.notifyUnknownRecipients("recovery", false),
)

identity = gen.identityWithWebsite()
cy.registerApi(identity)
Expand Down Expand Up @@ -85,8 +88,6 @@ context("Account Recovery With Code Success", () => {
})

it("should recover account with correct code after entering wrong code", () => {
const identity = gen.identityWithWebsite()
cy.registerApi(identity)
cy.visit(recovery)
cy.get(appPrefix(app) + "input[name='email']").type(identity.email)
cy.get("button[value='code']").click()
Expand Down Expand Up @@ -117,8 +118,6 @@ context("Account Recovery With Code Success", () => {
})

it("should recover account after resending code", () => {
const identity = gen.identityWithWebsite()
cy.registerApi(identity)
cy.visit(recovery)
cy.get(appPrefix(app) + "input[name='email']").type(identity.email)
cy.get("button[value='code']").click()
Expand Down Expand Up @@ -170,12 +169,14 @@ context("Account Recovery With Code Success", () => {
cy.useConfigProfile("recovery")
cy.proxy(app)

cy.deleteMail()
cy.longRecoveryLifespan()
cy.longCodeLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("code")
cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longCodeLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("code"),
)

const identity = gen.identityWithWebsite()
cy.registerApi(identity)
Expand Down
18 changes: 11 additions & 7 deletions test/e2e/cypress/integration/profiles/recovery/link/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ context("Account Recovery Errors", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.longLinkLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("link")
cy.disableRecoveryStrategy("code")
cy.clearAllCookies()
cy.notifyUnknownRecipients("verification", false)

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longLinkLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("link")
.disableRecoveryStrategy("code")
.notifyUnknownRecipients("verification", false),
)
})

it("responds with a HTML response on link click of an API flow if the link is expired", () => {
Expand Down
29 changes: 19 additions & 10 deletions test/e2e/cypress/integration/profiles/recovery/link/success.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ context("Account Recovery Success", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.longLinkLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("link")

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longLinkLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("link"),
)

identity = gen.identityWithWebsite()
cy.registerApi(identity)
Expand Down Expand Up @@ -93,10 +97,14 @@ context("Account Recovery Success", () => {
cy.proxy(app)

cy.deleteMail()
cy.longRecoveryLifespan()
cy.longLinkLifespan()
cy.disableVerification()
cy.enableRecovery()

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longLinkLifespan()
.disableVerification()
.enableRecovery(),
)

const identity = gen.identityWithWebsite()
cy.registerApi(identity)
Expand All @@ -123,7 +131,8 @@ context("Account Recovery Success", () => {
cy.proxy(app)

cy.deleteMail()
cy.disableVerification()

cy.useConfig((builder) => builder.disableVerification())

const identity1 = gen.identityWithWebsite()
cy.registerApi(identity1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ context("Recovery with `return_to`", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.disableVerification()
cy.enableRecovery()
cy.useRecoveryStrategy("code")
cy.notifyUnknownRecipients("recovery", false)

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.disableVerification()
.enableRecovery()
.useRecoveryStrategy("code")
.notifyUnknownRecipients("recovery", false)
.longPrivilegedSessionTime()
.requireStrictAal(),
)
cy.clearAllCookies()
cy.longPrivilegedSessionTime()
cy.requireStrictAal()
identity = gen.identityWithWebsite()
cy.registerApi(identity)
})
Expand Down Expand Up @@ -80,8 +84,6 @@ context("Recovery with `return_to`", () => {
})

it("should return to the `return_to` url even with mfa enabled after successful account recovery and settings update", () => {
cy.requireStrictAal()

cy.visit(settings)
cy.get('input[name="identifier"]').type(identity.email)
cy.get('input[name="password"]').type(identity.password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ context("Account Recovery Success", () => {

beforeEach(() => {
cy.deleteMail()
cy.longRecoveryLifespan()
cy.longLinkLifespan()
cy.disableVerification()
cy.enableRecovery()

cy.useConfig((builder) =>
builder
.longRecoveryLifespan()
.longLinkLifespan()
.disableVerification()
.enableRecovery(),
)

identity = gen.identityWithWebsite()
cy.registerApi(identity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ context("Account Verification Login Errors", () => {
before(() => {
cy.deleteMail()
cy.useConfigProfile(profile)
cy.enableLoginForVerifiedAddressOnly()
cy.useConfig((builder) => builder.enableLoginForVerifiedAddressOnly())
cy.proxy(app)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ context("Account Verification Login Success", () => {
before(() => {
cy.deleteMail()
cy.useConfigProfile(profile)
cy.enableLoginForVerifiedAddressOnly()
cy.useConfig((builder) => builder.enableLoginForVerifiedAddressOnly())
cy.proxy(app)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ context("Account Verification Registration Errors", () => {

let identity
beforeEach(() => {
cy.enableVerification()
cy.disableRecovery()
cy.shortCodeLifespan()
cy.longVerificationLifespan()

cy.useConfig((builder) =>
builder
.enableVerification()
.disableRecovery()
.shortCodeLifespan()
.longVerificationLifespan(),
)
cy.deleteMail()

identity = gen.identityWithWebsite()
Expand All @@ -47,7 +49,6 @@ context("Account Verification Registration Errors", () => {
})

it("is unable to verify the email address if the code is no longer valid and resend the code", () => {
cy.shortCodeLifespan()
cy.verifyEmailButExpired({
expect: { email: identity.email },
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ context("Account Verification Registration Success", () => {
})

beforeEach(() => {
cy.longVerificationLifespan()
cy.useConfig((builder) => builder.longVerificationLifespan())
cy.deleteMail()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ context("Account Verification Settings Error", () => {
})

beforeEach(() => {
cy.longCodeLifespan()
cy.useConfig((builder) => builder.longCodeLifespan())
identity = gen.identityWithWebsite()
cy.clearAllCookies()
cy.registerApi(identity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ context("Account Verification Error", () => {
let identity
beforeEach(() => {
cy.clearAllCookies()
cy.longVerificationLifespan()
cy.longLifespan(s)
cy.useVerificationStrategy(s)
cy.resetCourierTemplates("verification")
cy.notifyUnknownRecipients("verification", false)

cy.useConfig((builder) =>
builder
.longVerificationLifespan()
.longLifespan(s)
.useVerificationStrategy(s)
.notifyUnknownRecipients("verification", false),
)

identity = gen.identity()
cy.registerApi(identity)
Expand Down
Loading

0 comments on commit 70a6171

Please sign in to comment.