e2e tests: admin
This commit is contained in:
parent
52c889218a
commit
abb4a3840d
47
mpwo_client/e2e/admin.test.js
Normal file
47
mpwo_client/e2e/admin.test.js
Normal file
@ -0,0 +1,47 @@
|
||||
import { Selector } from 'testcafe'
|
||||
|
||||
import { TEST_URL } from './utils'
|
||||
|
||||
const randomstring = require('randomstring')
|
||||
|
||||
const username = randomstring.generate(8)
|
||||
const email = `${username}@test.com`
|
||||
const password = 'lentghOk'
|
||||
const adminEmail = 'admin@example.com'
|
||||
const adminPassword = 'mpwoadmin'
|
||||
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
fixture('/admin').page(`${TEST_URL}/admin`)
|
||||
|
||||
test('standard user should not be able to access admin page', async t => {
|
||||
// register user
|
||||
await t
|
||||
.navigateTo(`${TEST_URL}/register`)
|
||||
.typeText('input[name="username"]', username)
|
||||
.typeText('input[name="email"]', email)
|
||||
.typeText('input[name="password"]', password)
|
||||
.typeText('input[name="passwordConf"]', password)
|
||||
.click(Selector('input[type="submit"]'))
|
||||
|
||||
await t
|
||||
.navigateTo(`${TEST_URL}/admin`)
|
||||
.expect(Selector('H1').withText('Access denied').exists).ok()
|
||||
.expect(Selector('H1').withText('Dashboard').exists).notOk()
|
||||
|
||||
})
|
||||
|
||||
test('admin should be able to access admin page', async t => {
|
||||
// admin login
|
||||
await t
|
||||
.navigateTo(`${TEST_URL}/login`)
|
||||
.typeText('input[name="email"]', adminEmail)
|
||||
.typeText('input[name="password"]', adminPassword)
|
||||
.click(Selector('input[type="submit"]'))
|
||||
|
||||
await t
|
||||
.navigateTo(`${TEST_URL}/admin`)
|
||||
.expect(Selector('H1').withText('Access denied').exists).notOk()
|
||||
.expect(Selector('H1').withText('Administration').exists).ok()
|
||||
|
||||
})
|
1
test.sh
1
test.sh
@ -12,6 +12,7 @@ docker-compose -f docker-compose-ci.yml run mpwo-api py.test mpwo_api
|
||||
inspect $? api
|
||||
|
||||
docker-compose -f docker-compose-ci.yml run mpwo-api flask db upgrade
|
||||
docker-compose -f docker-compose-ci.yml run mpwo-api flask init_data
|
||||
|
||||
testcafe chrome mpwo_client/e2e
|
||||
inspect $? e2e
|
||||
|
Loading…
Reference in New Issue
Block a user