Commit e28073ca authored by Yannis Barlas's avatar Yannis Barlas Committed by Alexandros Georgantas

test(*): login programmatically & set up eslint

parent 968fd224
{
"env": {
"cypress/globals": true
},
"extends": ["plugin:cypress/recommended"],
"plugins": ["cypress"],
"rules": {
"jest/valid-expect": 0
}
}
describe('Dashboard', () => {
it('shows dashboard', () => {
cy.login('author')
cy.visit('/books')
})
})
......@@ -23,3 +23,33 @@
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
const credentials = require('./credentials')
Cypress.Commands.add('login', role => {
const { username, password } = credentials[role]
const loginUserMutation = `mutation{
loginUser (input: {
username: "${username}",
password: "${password}"
}) {
token
}
}`
window.localStorage.removeItem('token')
cy.request({
method: 'POST',
url: '/graphql',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: { query: loginUserMutation },
}).then(response => {
const { token } = response.body.data.loginUser
window.localStorage.setItem('token', token)
})
})
......@@ -3,6 +3,10 @@ const credentials = {
username: 'admin',
password: 'password',
},
author: {
username: 'author',
password: 'password',
},
}
module.exports = credentials
......@@ -6601,6 +6601,13 @@ eslint-module-utils@^2.0.0, eslint-module-utils@^2.4.0:
debug "^2.6.8"
pkg-dir "^2.0.0"
eslint-plugin-cypress@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-cypress/-/eslint-plugin-cypress-2.2.1.tgz#17295d8ef76984fe05886c7c5830ba216c1f9717"
integrity sha512-WkH81MEALKhnpeRo/wWHBHR883LdkS8aFzbGAGFxiwRwik2IKBZxb/JrxbiA6+SZskXGcmdEi6rwL7xmiqo9MA==
dependencies:
globals "^11.0.1"
eslint-plugin-import@^2.8.0:
version "2.17.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.17.2.tgz#d227d5c6dc67eca71eb590d2bb62fb38d86e9fcb"
......@@ -13172,11 +13179,6 @@ pkginfo@0.3.x:
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=
pkginfo@0.x.x:
version "0.4.1"
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
integrity sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=
platform@1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444"
......@@ -13807,19 +13809,7 @@ promisify-event@^1.0.0:
dependencies:
pinkie-promise "^2.0.0"
prompt@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prompt/-/prompt-1.0.0.tgz#8e57123c396ab988897fb327fd3aedc3e735e4fe"
integrity sha1-jlcSPDlquYiJf7Mn/Trtw+c15P4=
dependencies:
colors "^1.1.2"
pkginfo "0.x.x"
read "1.0.x"
revalidator "0.1.x"
utile "0.3.x"
winston "2.1.x"
prompt@flatiron/prompt#1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87:
prompt@^1.0.0, prompt@flatiron/prompt#1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87:
version "1.0.0"
resolved "https://codeload.github.com/flatiron/prompt/tar.gz/1c95d1d8d333b5fbc13fa5f0619f3dcf0d514f87"
dependencies:
......@@ -18272,19 +18262,6 @@ winston@0.8.x:
pkginfo "0.3.x"
stack-trace "0.0.x"
winston@2.1.x:
version "2.1.1"
resolved "https://registry.yarnpkg.com/winston/-/winston-2.1.1.tgz#3c9349d196207fd1bdff9d4bc43ef72510e3a12e"
integrity sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=
dependencies:
async "~1.0.0"
colors "1.0.x"
cycle "1.0.x"
eyes "0.1.x"
isstream "0.1.x"
pkginfo "0.3.x"
stack-trace "0.0.x"
winston@2.x, winston@^2.2.0:
version "2.4.4"
resolved "https://registry.yarnpkg.com/winston/-/winston-2.4.4.tgz#a01e4d1d0a103cf4eada6fc1f886b3110d71c34b"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment