config and more files

master
null 4 years ago
parent 75a4d0d42b
commit cfd76e7c90

@ -1,4 +1,4 @@
import loginPage from '../selectors/login.sel'
import login from '../selectors/login.sel'
describe('Login', () => {
beforeEach(() => {
@ -8,17 +8,17 @@ describe('Login', () => {
})
it('can see error message when username/password incorrect', () => {
cy.get(loginPage.emailField).type('random@test.com')
cy.get(loginPage.passwordField).type('random_pass')
cy.get(loginPage.signInButton).should('have.text', 'Sign in').click()
cy.get(loginPage.errorMessages).should('be.visible')
cy.get(login.emailField).type('random@test.com')
cy.get(login.passwordField).type('random_pass')
cy.get(login.signInButton).should('have.text', 'Sign in').click()
cy.get(login.errorMessages).should('be.visible')
.and('have.text', 'email or password is invalid')
})
it('can press enter to log in', () => {
cy.get(loginPage.emailField).type('random2@test.com')
cy.get(loginPage.passwordField).type('random_pass{enter}')
cy.get(loginPage.errorMessages).should('be.visible')
cy.get(login.emailField).type('random2@test.com')
cy.get(login.passwordField).type('random_pass{enter}')
cy.get(login.errorMessages).should('be.visible')
.and('have.text', 'email or password is invalid')
})
})

@ -0,0 +1,11 @@
import editor from '../selectors/editor.sel'
describe.skip('Article', () => {
beforeEach(() => {
login()
visit('/editor')
})
it('can create a new article', () => {
})
})

@ -15,7 +15,28 @@
/**
* @type {Cypress.PluginConfig}
*/
function setViewPortsAndUserAgent(device) {
if (device === 'mob' || device === 'mobile') {
return {
viewportWidth: 360,
viewportHeight: 780,
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57'
}
}
if (device === 'web' || device === 'desktop') {
return {
viewportWidth: 1266,
viewportHeight: 768,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'
}
}
throw new Error("device not supported - [please set device to mob or web]")
}
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
const viewportConfig = setViewPortsAndUserAgent(config.env.device)
config = Object.assign({}, viewportConfig)
return config
}

@ -0,0 +1,3 @@
module.exports = {
}

@ -0,0 +1,3 @@
Cypress.Commands.add('login', (email = 'email', password = 'pass') => {
//todo
})

@ -1,13 +1,13 @@
{
"name": "cypress-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"cy:open:mob": "cypress open --env device=mob",
"cy:open:web": "cypress open --env device=web",
"cy:run:mob": "cypress run --env device=mob",
"cy:run:web": "cypress run --env device=web"
},
"author": "",
"license": "ISC",
"devDependencies": {
"cypress": "^6.6.0",
"eslint": "^7.21.0"

Loading…
Cancel
Save