This commit is contained in:
Eddie Jaoude 2022-06-06 23:15:39 +01:00
Родитель a491ca1692
Коммит c5ad632408
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E23109A19B3A6270
12 изменённых файлов: 6640 добавлений и 3816 удалений

1
.github/workflows/test.yml поставляемый
Просмотреть файл

@ -21,3 +21,4 @@ jobs:
npm install
npm run test
npm run build
npm run test:e2e

4
.gitignore поставляемый
Просмотреть файл

@ -33,3 +33,7 @@ yarn-error.log*
# vercel
.vercel
# cypress
cypress/videos/
cypress/screenshots/

Просмотреть файл

@ -46,6 +46,23 @@ yarn build
This will create an `out` folder in the repository root with the static files.
### Run tests
#### Using the UI
```
yarn run cypress open
```
#### Using the CLI
Stop the app if you already have it running
```
npm run build && npm run test:e2e
```
## Contributing
See the [contributing guide](CONTRIBUTING.md) for more details.

12
cypress.config.js Normal file
Просмотреть файл

@ -0,0 +1,12 @@
const { defineConfig } = require('cypress')
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = defineConfig({
e2e: {
specPattern: 'cypress/integration/**/*.{feature, features, js}',
setupNodeEvents(on, config) {
// implement node event listeners here
on('file:preprocessor', cucumber())
},
},
})

5
cypress/e2e/spec.cy.js Normal file
Просмотреть файл

@ -0,0 +1,5 @@
describe('spec.cy.js', () => {
it('should visit', () => {
cy.visit('/')
})
})

Просмотреть файл

@ -0,0 +1,33 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
Given('I open {string} page', (uri) => {
const baseUrl = 'http://localhost:3000'
let path = ''
switch (uri) {
case 'home':
path = '/'
break
case 'schedule':
path = '/schedule'
break
default:
path = uri
}
cy.visit(baseUrl + path)
})
When(`I click on {string}`, (path) => {
cy.get(`a[href*="/${path}"]`).click()
})
When(`I click on {string} in section {string}`, (path, section) => {
cy.get(`${section} a[href*="/${path}"]`).click()
})
Then(`I should see {string} in the url`, (text) => {
cy.url().should('include', text)
})
Then(`I see {string} text in section {string}`, (text, location) => {
cy.get(location).should('contain', text)
})

Просмотреть файл

@ -0,0 +1,7 @@
Feature: Maintainer Month homepage
I want check the homepage loads
Scenario: Opening the homepage
Given I open "home" page
Then I see "June 2022" text in section ".hero"

Просмотреть файл

@ -0,0 +1,18 @@
Feature: Schedule page
I want check the schedule page loads the data correctly
Scenario: Navigating to the schedule page
Given I open "home" page
When I click on "schedule" in section ".header"
Then I should see "schedule" in the url
Then I see "Jun 2" text in section ".events-list"
Then I see "Jun 3" text in section ".events-list"
Scenario: Opening the schedule page directly
Given I open "/schedule" page
Then I see "Jun 2" text in section ".events-list"
Scenario: Check data is loaded correctly
Given I open "schedule" page
Then I see "Maintainer Twitter Space" text in section ".events-list"

Просмотреть файл

@ -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) => { ... })

20
cypress/support/e2e.js Normal file
Просмотреть файл

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')

Просмотреть файл

@ -7,7 +7,10 @@
"build": "NODE_ENV=production next build && next export",
"start": "next start",
"lint": "next lint",
"test": "jest"
"test": "jest",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test:e2e": "concurrently -k --success first \"npm run cypress:run\" \"npm run start\""
},
"dependencies": {
"clsx": "^1.1.1",
@ -25,11 +28,17 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.0",
"babel-jest": "^27.5.1",
"concurrently": "^7.2.1",
"cypress": "^10.0.2",
"cypress-cucumber-preprocessor": "^4.3.1",
"eslint": "8.11.0",
"eslint-config-next": "12.1.0",
"jest": "^27.5.1",
"jest-css-modules": "^2.1.0",
"sass": "^1.49.9",
"sass-loader": "^12.6.0"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
}

10303
yarn.lock

Разница между файлами не показана из-за своего большого размера Загрузить разницу