Migrated from React to NextJS

This commit is contained in:
2022-10-14 13:58:57 +02:00
parent b2a16e5181
commit b4ff0c8f77
72 changed files with 1557 additions and 1686 deletions

View File

@ -0,0 +1,64 @@
const randomString = () => (Math.random() + 1).toString(36).substring(7)
const randomPassword = () => randomString() + randomString()
const randomEmail = () => randomString() + '@' + randomString() + '.com'
const login = (email, password) => {
cy.visit('/api/.ory/ui/login')
cy.get('[name="identifier"]').type(email)
cy.get('[name="password"]').type(password)
cy.get('[name="method"]').click()
loggedIn(email)
}
const loggedIn = (email) => {
cy.location('pathname').should('eq', '/')
cy.get('[data-testid="session-content"]').should('contain.text', email)
cy.get('[data-testid="logout"]').should('have.attr', 'aria-disabled', 'false')
}
context('Basic UI interactions', () => {
const email = randomEmail()
const password = randomPassword()
beforeEach(() => {
cy.clearCookies({ domain: null })
})
it('can load the start page', () => {
cy.visit('/')
cy.get('a[href="/api/.ory/self-service/login/browser"]').should('exist')
cy.get('a[href="/api/.ory/self-service/registration/browser"]').should(
'exist'
)
})
it('redirects to login when accessing settings without session', () => {
cy.visit('/api/.ory/ui/settings')
cy.location('pathname').should('contain', 'api/.ory/ui/login')
cy.get('[name="method"]').should('exist')
})
it('can submit registration', () => {
cy.visit('/api/.ory/ui/registration')
cy.get('[name="traits.email"]').type(email)
cy.get('[name="password"]').type(password)
cy.get('[name="method"]').click()
loggedIn(email)
})
it('can load the login page', () => {
login(email, password)
})
it('goes to registration and clicks on log in and redirect works', () => {
cy.visit('/api/.ory/ui/registration')
cy.get('[data-testid="cta-link"]').click()
login(email, password)
})
it('can log out', () => {
login(email, password)
cy.get('a[data-testid="logout"]').click()
cy.get('[data-testid="logout"]').should('not.exist')
})
})

View File

@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

View File

@ -0,0 +1,19 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')