Skip to content

Commit

Permalink
test(e2e): add SPA tests for logout and refactor tests to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent d9a25df commit b0c6776
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
25 changes: 0 additions & 25 deletions test/e2e/cypress/integration/profiles/email/logout/success.spec.js

This file was deleted.

37 changes: 37 additions & 0 deletions test/e2e/cypress/integration/profiles/email/logout/success.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {gen, website} from '../../../../helpers'
import {routes as express} from "../../../../helpers/express";
import {routes as react} from "../../../../helpers/react";

context('Testing logout flows', () => {
[{
route: express.login,
app: 'express', profile: 'email'
}, {
route: react.login,
app: 'react', profile: 'spa'
}].forEach(({route, profile, app}) => {
describe(`for app ${app}`, () => {
const email = gen.email()
const password = gen.password()

before(() => {
cy.useConfigProfile(profile)
cy.registerApi({email, password, fields: {'traits.website': website}})
cy.login({email, password, cookieUrl: route})
})

beforeEach(() => {
cy.visit(route)
})

it('should sign out and be able to sign in again', () => {
cy.getSession()
cy.getCookie('ory_kratos_session').should('not.be.null')
cy.get('*[data-testid="logout"]').click()
cy.noSession()
cy.url().should('include', '/login')
cy.getCookie('ory_kratos_session').should('be.null')
})
})
})
})

0 comments on commit b0c6776

Please sign in to comment.