Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: resolve flaky e2e tests #3935

Merged
merged 7 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ jobs:
name: Start CockroachDB
- uses: browser-actions/setup-chrome@latest
name: Install Chrome
- uses: browser-actions/setup-firefox@latest
name: Install Firefox
- uses: browser-actions/setup-geckodriver@latest
name: Install Geckodriver
with:
geckodriver-version: 0.32.0
# - uses: browser-actions/setup-firefox@latest
# name: Install Firefox
# - uses: browser-actions/setup-geckodriver@latest
# name: Install Geckodriver
# with:
# geckodriver-version: 0.32.0
- uses: ory/ci/checkout@master
with:
fetch-depth: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ context("Login success with code method", () => {
cy.get(Selectors[app]["submit"]).click()
})

if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}

if (app === "mobile") {
cy.get('[data-testid="session-token"]').then((token) => {
cy.getSession({
Expand Down Expand Up @@ -206,6 +212,12 @@ context("Login success with code method", () => {

cy.get(Selectors[app]["submit"]).click()

if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}

if (app === "express") {
cy.get('a[href*="sessions"').click()
}
Expand Down Expand Up @@ -274,6 +286,12 @@ context("Login success with code method", () => {
cy.get(Selectors[app]["submit"]).click()
})

if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}

if (app === "mobile") {
cy.get('[data-testid="session-token"]').then((token) => {
cy.getSession({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,53 @@ import { gen, MOBILE_URL } from "../../../../helpers"
import { routes as express } from "../../../../helpers/express"
import { routes as react } from "../../../../helpers/react"

const Selectors = {
mobile: {
identifier: "[data-testid='field/identifier']",
recoveryEmail: "[data-testid='field/email']",
email: "[data-testid='traits.email']",
email2: "[data-testid='traits.email2']",
tos: "[data-testid='traits.tos']",
username: "[data-testid='traits.username']",
code: "[data-testid='field/code'] input",
recoveryCode: "[data-testid='code']",
submitCode: "[data-testid='field/method/code']",
resendCode: "[data-testid='field/resend/code']",
submitRecovery: "[data-testid='field/method/code']",
codeHiddenMethod: "[data-testid='field/method/code']",
},
express: {
identifier: "[data-testid='login-flow-code'] input[name='identifier']",
recoveryEmail: "input[name=email]",
email: "[data-testid='registration-flow-code'] input[name='traits.email']",
email2:
"[data-testid='registration-flow-code'] input[name='traits.email2']",
tos: "[data-testid='registration-flow-code'] [name='traits.tos'] + label",
username:
"[data-testid='registration-flow-code'] input[name='traits.username']",
code: "input[name='code']",
recoveryCode: "input[name=code]",
submitRecovery: "button[name=method][value=code]",
submitCode: "button[name='method'][value='code']",
resendCode: "button[name='resend'][value='code']",
codeHiddenMethod: "input[name='method'][value='code'][type='hidden']",
},
react: {
identifier: "input[name='identifier']",
recoveryEmail: "input[name=email]",
email: "input[name='traits.email']",
email2: "input[name='traits.email2']",
tos: "[name='traits.tos'] + label",
username: "input[name='traits.username']",
code: "input[name='code']",
recoveryCode: "input[name=code]",
submitRecovery: "button[name=method][value=code]",
submitCode: "button[name='method'][value='code']",
resendCode: "button[name='resend'][value='code']",
codeHiddenMethod: "input[name='method'][value='code'][type='hidden']",
},
}

context("Registration success with code method", () => {
;[
{
Expand All @@ -31,57 +78,7 @@ context("Registration success with code method", () => {
},
].forEach(({ route, login, recovery, profile, app }) => {
describe(`for app ${app}`, () => {
const Selectors = {
mobile: {
identifier: "[data-testid='field/identifier']",
recoveryEmail: "[data-testid='field/email']",
email: "[data-testid='traits.email']",
email2: "[data-testid='traits.email2']",
tos: "[data-testid='traits.tos']",
username: "[data-testid='traits.username']",
code: "[data-testid='field/code']",
recoveryCode: "[data-testid='code']",
submitCode: "[data-testid='field/method/code']",
resendCode: "[data-testid='field/method/resend']",
submitRecovery: "[data-testid='field/method/code']",
codeHiddenMethod: "[data-testid='field/method/code']",
},
express: {
identifier:
"[data-testid='login-flow-code'] input[name='identifier']",
recoveryEmail: "input[name=email]",
email:
"[data-testid='registration-flow-code'] input[name='traits.email']",
email2:
"[data-testid='registration-flow-code'] input[name='traits.email2']",
tos: "[data-testid='registration-flow-code'] [name='traits.tos'] + label",
username:
"[data-testid='registration-flow-code'] input[name='traits.username']",
code: "input[name='code']",
recoveryCode: "input[name=code]",
submitRecovery: "button[name=method][value=code]",
submitCode: "button[name='method'][value='code']",
resendCode: "button[name='resend'][value='code']",
codeHiddenMethod: "input[name='method'][value='code'][type='hidden']",
},
react: {
identifier: "input[name='identifier']",
recoveryEmail: "input[name=email]",
email: "input[name='traits.email']",
email2: "input[name='traits.email2']",
tos: "[name='traits.tos'] + label",
username: "input[name='traits.username']",
code: "input[name='code']",
recoveryCode: "input[name=code]",
submitRecovery: "button[name=method][value=code]",
submitCode: "button[name='method'][value='code']",
resendCode: "button[name='resend'][value='code']",
codeHiddenMethod: "input[name='method'][value='code'][type='hidden']",
},
}

before(() => {
cy.deleteMail()
cy.useConfigProfile(profile)
if (app !== "mobile") {
cy.proxy(app)
Expand All @@ -94,11 +91,11 @@ context("Registration success with code method", () => {
cy.visit(route)
})

it("should be able to resend the registration code", async () => {
it("should be able to resend the registration code", () => {
const email = gen.email()

cy.get(Selectors[app]["email"]).type(email)
cy.get(`${Selectors[app]["tos"]} + label`).click()
cy.get(Selectors[app]["tos"]).click()

cy.submitCodeForm(app)
cy.get('[data-testid="ui/message/1040005"]').should(
Expand All @@ -110,7 +107,6 @@ context("Registration success with code method", () => {
cy.wrap(code).as("code1"),
)

cy.get(Selectors[app]["email"]).should("have.value", email)
cy.get(Selectors[app]["codeHiddenMethod"]).should("exist")
cy.get(Selectors[app]["resendCode"]).click()

Expand Down Expand Up @@ -180,7 +176,13 @@ context("Registration success with code method", () => {
cy.get(Selectors[app]["submitCode"]).click()
})

if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}
if (app === "mobile") {
cy.get('[data-testid="session-token"]').should("not.be.empty")
cy.get('[data-testid="session-token"]').then((token) => {
cy.getSession({
expectAal: "aal1",
Expand All @@ -190,9 +192,6 @@ context("Registration success with code method", () => {
cy.wrap(session).as("session")
})
})

cy.get('[data-testid="session-content"]').should("contain", email)
cy.get('[data-testid="session-token"]').should("not.be.empty")
} else {
cy.getSession({ expectAal: "aal1", expectMethods: ["code"] }).then(
(session) => {
Expand Down Expand Up @@ -236,7 +235,14 @@ context("Registration success with code method", () => {
cy.get(Selectors[app]["submitCode"]).click()
})

if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}

if (app === "mobile") {
cy.get('[data-testid="session-token"]').should("not.be.empty")
cy.get('[data-testid="session-token"]').then((token) => {
cy.getSession({
expectAal: "aal1",
Expand All @@ -246,9 +252,6 @@ context("Registration success with code method", () => {
cy.wrap(session).as("session")
})
})

cy.get('[data-testid="session-content"]').should("contain", email)
cy.get('[data-testid="session-token"]').should("not.be.empty")
} else {
cy.getSession({ expectAal: "aal1", expectMethods: ["code"] }).then(
(session) => {
Expand Down Expand Up @@ -305,6 +308,9 @@ context("Registration success with code method", () => {
{
hook: "session",
},
{
hook: "show_verification_ui",
},
])

// Setup complex schema
Expand Down Expand Up @@ -335,6 +341,7 @@ context("Registration success with code method", () => {
cy.get(Selectors[app]["submitCode"]).click()
},
)
cy.get('[data-testid="ui/message/1080003"]').should("be.visible")

if (app === "mobile") {
cy.visit(MOBILE_URL + "/Home")
Expand All @@ -359,8 +366,14 @@ context("Registration success with code method", () => {
cy.get(Selectors[app]["code"]).type(code)
cy.get(Selectors[app]["submitCode"]).click()
})
if (app === "express") {
cy.url().should("match", /\/welcome/)
} else {
cy.get('[data-testid="session-content"]').should("contain", email)
}

if (app === "mobile") {
cy.get('[data-testid="session-token"]').should("not.be.empty")
cy.get('[data-testid="session-token"]').then((token) => {
cy.getSession({
expectAal: "aal1",
Expand All @@ -370,9 +383,6 @@ context("Registration success with code method", () => {
cy.wrap(session).as("session")
})
})

cy.get('[data-testid="session-content"]').should("contain", email)
cy.get('[data-testid="session-token"]').should("not.be.empty")
} else {
cy.getSession({ expectAal: "aal1", expectMethods: ["code"] }).then(
(session) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ context("Social Sign In Successes", () => {
cy.loginOidc({ app, url: login })
})

it.only("should be able to sign up and link existing account", () => {
it("should be able to sign up and link existing account", () => {
const email = gen.email()
const password = gen.password()

Expand Down
Loading
Loading