e2e test: admin/sports

e2e test: admin/sports
This commit is contained in:
Sam 2018-04-29 19:21:22 +02:00
parent abb4a3840d
commit 3f025357b9
4 changed files with 37 additions and 2 deletions

View File

@ -0,0 +1,31 @@
import { Selector } from 'testcafe'
import { TEST_URL } from './utils'
// database must be initialiazed
const adminEmail = 'admin@example.com'
const adminPassword = 'mpwoadmin'
// eslint-disable-next-line no-undef
fixture('/admin/sports').page(`${TEST_URL}/admin/sports`)
test('admin should be able to access sports administration 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/sports`)
.expect(Selector('H1').withText('Administration - Sports').exists).ok()
.expect(Selector('.sport-items').withText('Hiking').exists).ok()
await t
.navigateTo(`${TEST_URL}/admin`)
.click(Selector('.sports'))
.expect(Selector('.sport-items').withText('Hiking').exists).ok()
})

View File

@ -7,6 +7,8 @@ const randomstring = require('randomstring')
const username = randomstring.generate(8)
const email = `${username}@test.com`
const password = 'lentghOk'
// database must be initialiazed
const adminEmail = 'admin@example.com'
const adminPassword = 'mpwoadmin'
@ -43,5 +45,6 @@ test('admin should be able to access admin page', async t => {
.navigateTo(`${TEST_URL}/admin`)
.expect(Selector('H1').withText('Access denied').exists).notOk()
.expect(Selector('H1').withText('Administration').exists).ok()
.expect(Selector('.admin-items').withText('Sports').exists).ok()
})

View File

@ -16,9 +16,10 @@ class AdminMenu extends React.Component {
<div className="row">
<div className="col-md-2" />
<div className="col-md-8 card">
<ul>
<ul className="admin-items">
<li>
<Link
className="sports"
to={{
pathname: '/admin/sports',
}}

View File

@ -20,7 +20,7 @@ class AdminSports extends React.Component {
<div className="row">
<div className="col-md-2" />
<div className="col-md-8 card">
<ul>
<ul className="sport-items">
{sports.map(sport => (
<li key={sport.id}>
{sport.label}