Skip to content

Commit

Permalink
test: add initial spa e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent c9d22d9 commit 20617f6
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 2 deletions.
4 changes: 4 additions & 0 deletions test/e2e/cypress/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ module.exports = {
/\/$/,
''
),
SPA_URL: (Cypress.env('mobile_url') || 'http://localhost:3000').replace(
/\/$/,
''
),
KRATOS_ADMIN: (Cypress.env('kratos_admin') || 'http://localhost:4434')
.replace()
.replace(/\/$/, ''),
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/cypress/integration/profiles/spa/login/success.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { gen, SPA_URL, website } from '../../../../helpers'

context('Mobile Profile', () => {
describe('Login Flow Success', () => {
before(() => {
cy.useConfigProfile('spa')
})

const email = gen.email()
const password = gen.password()

before(() => {
cy.registerApi({ email, password, fields: { 'traits.website': website } })
})

beforeEach(() => {
cy.visit(SPA_URL + '/login')
})

it('should sign up and be logged in', () => {
cy.get('input[name="password_identifier"]').type(email)
cy.get('input[name="password"]').type(password)
cy.get('button[value="password"][name="method"]').click()

cy.get('[data-testid="session-content"]').should('contain', email)
})
})
})
3 changes: 3 additions & 0 deletions test/e2e/profiles/kratos.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ serve:
base_url: http://localhost:4455/
cors:
enabled: true
allowed_origins:
- http://localhost:3000
- http://localhost:4457
allowed_headers:
- Authorization
- Content-Type
Expand Down
38 changes: 38 additions & 0 deletions test/e2e/profiles/spa/.kratos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
selfservice:
flows:
settings:
privileged_session_max_age: 5m
required_aal: aal1

logout:
after:
default_browser_return_url: http://localhost:4455/auth/login

registration:
after:
password:
hooks:
-
hook: session

methods:
totp:
enabled: true
config:
issuer: issuer.ory.sh
lookup_secret:
enabled: true
webauthn:
enabled: true
config:
rp:
id: localhost
origin: http://localhost:4455
display_name: Ory

identity:
default_schema_url: file://test/e2e/profiles/email/identity.traits.schema.json

session:
whoami:
required_aal: aal1
36 changes: 36 additions & 0 deletions test/e2e/profiles/spa/identity.traits.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$id": "https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"minLength": 3,
"ory.sh/kratos": {
"credentials": {
"password": {
"identifier": true
}
}
}
},
"website": {
"type": "string",
"format": "uri",
"minLength": 10
}
},
"required": [
"email",
"website"
],
"additionalProperties": false
}
}
}
1 change: 0 additions & 1 deletion test/e2e/proxy/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ run() {
$kratos migrate sql -e --yes
fi

for profile in email mobile oidc recovery verification mfa; do
for profile in email mobile oidc recovery verification mfa spa; do
yq merge test/e2e/profiles/kratos.base.yml "test/e2e/profiles/${profile}/.kratos.yml" > test/e2e/kratos.${profile}.yml
cp test/e2e/kratos.email.yml test/e2e/kratos.generated.yml
done
Expand Down

0 comments on commit 20617f6

Please sign in to comment.