Commit d930144b authored by Yannis Barlas's avatar Yannis Barlas

test(login): create first working e2e test

parent b47e7baa
export DB_USER='someuser'
export DB_PASSWORD='somepass'
export DB_NAME='somedb'
export DB_PORT='5490'
/* eslint-disable import/no-extraneous-dependencies */
// import { Selector } from 'testcafe'
// fixture('Getting Started').page('https://github.com')
// import ReactSelector from 'testcafe-react-selectors'
import { ClientFunction, Selector } from 'testcafe'
// test('Find "testcafe-example" repo on GitHub', async t => {
// const repo = Selector('.repo-list > li > div')
// // search github
// await t
// .typeText('form[action="/search"]', 'testcafe-example user:mjhea0')
// .pressKey('enter')
// // check li for results
// await t.expect(repo.innerText).contains('mjhea0/testcafe-example')
// })
import { addUser, createTables } from '@pubsweet/db-manager'
import start from 'pubsweet/src/startup/start'
fixture('Actual app').page('localhost:3000')
let server
test('no way', async t => {
// console.log(process.env.NODE_ENV)
const startServer = async () => {
if (!server) {
server = await start()
}
}
const setup = async () => {
await createTables(true)
const user = {
email: 'testUser@email.com',
password: 'testPassword',
username: 'testUser',
}
await addUser(user)
}
const getLocation = ClientFunction(() => document.location.href)
const loginPage = {
url: 'http://localhost:3000/login',
}
fixture`Login Page`.page`${loginPage.url}`.before(startServer).beforeEach(setup)
test('Succeful login redirects user to dashboard', async t => {
await t
.typeText(Selector('form input[type="text"]'), 'testUser')
.typeText(Selector('form input[type="password"]'), 'testPassword')
.click(Selector('form button'))
.expect(getLocation())
.contains('/dashboard')
})
......@@ -80,6 +80,7 @@
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-standard": "^3.1.0",
"faker": "^4.1.0",
"file-loader": "^1.1.11",
"husky": "^0.14.3",
"jest": "^23.1.0",
......@@ -93,6 +94,7 @@
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^1.3.1",
"testcafe": "^0.20.3",
"testcafe-react-selectors": "^2.1.0",
"url-loader": "^1.0.1"
},
"scripts": {
......@@ -104,7 +106,7 @@
"server": "pubsweet server",
"setupdb": "pubsweet setupdb",
"test": "jest",
"testcafe": "source ./config/test.env && testcafe chromium e2e/ --app 'npm run server'"
"testcafe": "source ./config/test.env && testcafe chromium e2e/"
},
"config": {
"commitizen": {
......
......@@ -4297,6 +4297,10 @@ eyes@0.1.x:
version "0.1.8"
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
faker@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f"
fast-deep-equal@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
......@@ -10300,6 +10304,10 @@ testcafe-legacy-api@3.1.7:
pinkie "^2.0.1"
strip-bom "^2.0.0"
testcafe-react-selectors@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/testcafe-react-selectors/-/testcafe-react-selectors-2.1.0.tgz#529dcdcceb427f86dc56b6fceff68905abc63b9f"
testcafe-reporter-json@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/testcafe-reporter-json/-/testcafe-reporter-json-2.1.0.tgz#80b9b5a6dff2ee1de1f91e2670706c1472e64006"
......
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