mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #357 from omnivore-app/cypress-tests
Add cypress tests
This commit is contained in:
commit
4d6ea905a0
10 changed files with 168 additions and 0 deletions
2
packages/cypress/README.md
Normal file
2
packages/cypress/README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
Run `yarn && yarn cypress open`
|
||||
8
packages/cypress/cypress.json
Normal file
8
packages/cypress/cypress.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"baseUrl": "http://localhost:3000",
|
||||
"experimentalSessionSupport": true,
|
||||
"fixturesFolder": false,
|
||||
"supportFile": "cypress/support/index.js",
|
||||
"pluginsFile": false,
|
||||
"video": false
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
const email = 'tester@omnivore.app'
|
||||
const username = 'testuser'
|
||||
const password = 'testpassword'
|
||||
const fullName = 'Test User'
|
||||
|
||||
describe('Register with email', () => {
|
||||
it('creates a new user', function () {
|
||||
cy.visit('/email-registration')
|
||||
|
||||
cy.get('input[name=email]').type(email)
|
||||
cy.get('input[name=username]').type(username)
|
||||
cy.get('input[name=password]').type(password)
|
||||
cy.get('input[name=name]').type(fullName)
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
// we should be redirected to /dashboard
|
||||
cy.location('pathname').should('include', '/email-login')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Login with email', () => {
|
||||
it('sets auth token and redirects', function () {
|
||||
cy.visit('/email-login')
|
||||
|
||||
cy.get('input[name=email]').type(email)
|
||||
cy.get('input[name=password]').type(password)
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
cy.getCookie('auth').should('exist')
|
||||
cy.location('pathname').should('include', '/home')
|
||||
})
|
||||
})
|
||||
22
packages/cypress/cypress/integration/library/add-item.js
Normal file
22
packages/cypress/cypress/integration/library/add-item.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
describe('add link button', () => {
|
||||
before(() => {
|
||||
const email = 'tester@omnivore.app'
|
||||
const password = 'testpassword'
|
||||
|
||||
cy.login(email, password)
|
||||
cy.visit('/home');
|
||||
});
|
||||
|
||||
it('should add a link', () => {
|
||||
// Use keyboard command to open add link modal
|
||||
cy.get('body').type('a')
|
||||
|
||||
cy.focused().type('https://jacksonh.org/{enter}')
|
||||
|
||||
// wait for the link to be added
|
||||
cy.wait(2000)
|
||||
|
||||
cy.reload()
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
describe('pages that require auth', () => {
|
||||
it('should redirect to login', () => {
|
||||
cy.visit('/home')
|
||||
cy.location('pathname')
|
||||
.should('be.equal', '/login')
|
||||
});
|
||||
});
|
||||
22
packages/cypress/cypress/plugins/index.js
Normal file
22
packages/cypress/cypress/plugins/index.js
Normal 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
|
||||
}
|
||||
16
packages/cypress/cypress/support/commands.js
Normal file
16
packages/cypress/cypress/support/commands.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
import '@testing-library/cypress/add-commands';
|
||||
|
||||
Cypress.Commands.add('login', (email, password) => {
|
||||
cy.session([email, password], () => {
|
||||
cy.visit('/email-login')
|
||||
|
||||
cy.get('input[name=email]').type(email)
|
||||
cy.get('input[name=password]').type(password)
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
cy.getCookie('auth').should('exist')
|
||||
cy.location('pathname').should('include', '/home')
|
||||
})
|
||||
})
|
||||
20
packages/cypress/cypress/support/index.js
Normal file
20
packages/cypress/cypress/support/index.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// ***********************************************************
|
||||
// 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')
|
||||
15
packages/cypress/package.json
Normal file
15
packages/cypress/package.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "@omnivore/cypress",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@testing-library/cypress": "^8.0.2",
|
||||
"cypress": "^9.5.3"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"volta": {
|
||||
"node": "14.18.0",
|
||||
"yarn": "1.22.10"
|
||||
}
|
||||
}
|
||||
21
packages/cypress/tsconfig.json
Normal file
21
packages/cypress/tsconfig.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"types": ["node"],
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Loading…
Reference in a new issue