diff --git a/cypress/integration/login.spec.js b/cypress/integration/login.spec.js index 4e29982..edac1f4 100644 --- a/cypress/integration/login.spec.js +++ b/cypress/integration/login.spec.js @@ -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') }) }) \ No newline at end of file diff --git a/cypress/integration/settings.spec.js b/cypress/integration/settings.spec.js new file mode 100644 index 0000000..e5d12df --- /dev/null +++ b/cypress/integration/settings.spec.js @@ -0,0 +1,11 @@ +import editor from '../selectors/editor.sel' + +describe.skip('Article', () => { + beforeEach(() => { + login() + visit('/editor') + }) + + it('can create a new article', () => { + }) +}) \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index aa9918d..07c1a0a 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -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 } diff --git a/cypress/selectors/editor.sel.js b/cypress/selectors/editor.sel.js new file mode 100644 index 0000000..51f92fb --- /dev/null +++ b/cypress/selectors/editor.sel.js @@ -0,0 +1,3 @@ +module.exports = { + +} \ No newline at end of file diff --git a/cypress/support/login.cmd.js b/cypress/support/login.cmd.js new file mode 100644 index 0000000..10cd7a6 --- /dev/null +++ b/cypress/support/login.cmd.js @@ -0,0 +1,3 @@ +Cypress.Commands.add('login', (email = 'email', password = 'pass') => { + //todo +}) \ No newline at end of file diff --git a/package.json b/package.json index 110a726..02c09c5 100644 --- a/package.json +++ b/package.json @@ -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"