Skip to content

Commit

Permalink
test(e2e): resolve regressions and flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Feb 14, 2022
1 parent 67945a4 commit a607385
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ context('Social Sign In Errors', () => {
})

it('should fail when the login request is rejected', () => {
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#reject').click()
cy.location('pathname').should('equal', '/login')
cy.get(appPrefix(app) + '[data-testid="ui/message/4000001"]').should(
Expand All @@ -39,7 +39,7 @@ context('Social Sign In Errors', () => {

it('should fail when the consent request is rejected', () => {
const email = gen.email()
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#username').type(email)
cy.get('#accept').click()
cy.get('#reject').click()
Expand All @@ -53,7 +53,7 @@ context('Social Sign In Errors', () => {

it('should fail when the id_token is missing', () => {
const email = gen.email()
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#username').type(email)
cy.get('#accept').click()
cy.get('#website').type(website)
Expand All @@ -70,7 +70,7 @@ context('Social Sign In Errors', () => {

const email = gen.email()
cy.visit(login)
cy.triggerOidc()
cy.triggerOidc(app)

cy.get('#username').clear().type(email)
cy.get('#remember').click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ context('Social Sign Up Errors', () => {
})

it('should fail when the login request is rejected', () => {
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#reject').click()
cy.location('pathname').should('equal', '/registration')
cy.get(appPrefix(app) + '[data-testid="ui/message/4000001"]').should(
Expand All @@ -39,7 +39,7 @@ context('Social Sign Up Errors', () => {

it('should fail when the consent request is rejected', () => {
const email = gen.email()
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#username').type(email)
cy.get('#accept').click()
cy.get('#reject').click()
Expand All @@ -53,7 +53,7 @@ context('Social Sign Up Errors', () => {

it('should fail when the id_token is missing', () => {
const email = gen.email()
cy.triggerOidc()
cy.triggerOidc(app)
cy.get('#username').type(email)
cy.get('#accept').click()
cy.get('#website').type(website)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APP_URL, appPrefix, gen, website } from '../../../../helpers'
import { routes as react } from '../../../../helpers/react'
import { routes as express } from '../../../../helpers/express'
import {appPrefix, gen, website} from '../../../../helpers'
import {routes as react} from '../../../../helpers/react'
import {routes as express} from '../../../../helpers/express'

context('Social Sign Up Successes', () => {
;[
Expand All @@ -16,7 +16,7 @@ context('Social Sign Up Successes', () => {
app: 'express' as 'express',
profile: 'oidc'
}
].forEach(({ registration, login, profile, app }) => {
].forEach(({registration, login, profile, app}) => {
describe(`for app ${app}`, () => {
before(() => {
cy.useConfigProfile(profile)
Expand All @@ -32,18 +32,16 @@ context('Social Sign Up Successes', () => {
})

const shouldSession = (email) => (session) => {
const { identity } = session
const {identity} = session
expect(identity.id).to.not.be.empty
expect(identity.schema_id).to.equal('default')
expect(identity.schema_url).to.equal(`${APP_URL}/schemas/default`)
expect(identity.traits.website).to.equal(website)
expect(identity.traits.email).to.equal(email)
}

it('should be able to sign up with incomplete data and finally be signed in', () => {
const email = gen.email()

cy.registerOidc({ email, expectSession: false, route: registration })
cy.registerOidc({email, expectSession: false, route: registration})

cy.get('#registration-password').should('not.exist')
cy.get(appPrefix(app) + '[name="traits.email"]').should(
Expand Down Expand Up @@ -84,9 +82,11 @@ context('Social Sign Up Successes', () => {
cy.get('[name="traits.consent"]').should('be.checked')
cy.get('[name="traits.newsletter"]').should('be.checked')

cy.triggerOidc()
cy.triggerOidc(app)

cy.location('pathname').should('not.contain', '/consent')
cy.location('pathname').should((loc) => {
expect(loc).to.be.oneOf(['/welcome', '/'])
})

cy.getSession().should((session) => {
shouldSession(email)(session)
Expand All @@ -97,18 +97,18 @@ context('Social Sign Up Successes', () => {
it('should be able to sign up with complete data', () => {
const email = gen.email()

cy.registerOidc({ email, website, route: registration })
cy.registerOidc({email, website, route: registration})
cy.getSession().should(shouldSession(email))
})

it('should be able to convert a sign up flow to a sign in flow', () => {
const email = gen.email()

cy.registerOidc({ email, website, route: registration })
cy.registerOidc({email, website, route: registration})
cy.logout()
cy.noSession()
cy.visit(registration)
cy.triggerOidc()
cy.triggerOidc(app)

cy.location('pathname').should((path) => {
expect(path).to.oneOf(['/', '/welcome'])
Expand All @@ -124,7 +124,7 @@ context('Social Sign Up Successes', () => {

const email = gen.email()
cy.visit(login)
cy.triggerOidc()
cy.triggerOidc(app)

cy.get('#username').clear().type(email)
cy.get('#remember').click()
Expand All @@ -139,7 +139,7 @@ context('Social Sign Up Successes', () => {
)
cy.get('[name="traits.website"]').type('http://s')

cy.triggerOidc()
cy.triggerOidc(app)

cy.get('[data-testid="ui/message/4000001"]').should(
'contain.text',
Expand All @@ -152,7 +152,7 @@ context('Social Sign Up Successes', () => {
.should('have.value', 'http://s')
.clear()
.type(website)
cy.triggerOidc()
cy.triggerOidc(app)

cy.location('pathname').should('not.contain', '/registration')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ context('Social Sign In Settings Success', () => {
cy.get('#accept').click()

cy.get('input[name="traits.website"]').clear().type(website)
cy.triggerOidc('hydra')
cy.triggerOidc(app,'hydra')

cy.get('[data-testid="ui/message/4000007"]').should(
'contain.text',
Expand Down
Loading

0 comments on commit a607385

Please sign in to comment.