e2e test: admin/sports
e2e test: admin/sports
This commit is contained in:
parent
abb4a3840d
commit
3f025357b9
31
mpwo_client/e2e/admin-sports.test.js
Normal file
31
mpwo_client/e2e/admin-sports.test.js
Normal 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()
|
||||||
|
|
||||||
|
})
|
@ -7,6 +7,8 @@ const randomstring = require('randomstring')
|
|||||||
const username = randomstring.generate(8)
|
const username = randomstring.generate(8)
|
||||||
const email = `${username}@test.com`
|
const email = `${username}@test.com`
|
||||||
const password = 'lentghOk'
|
const password = 'lentghOk'
|
||||||
|
|
||||||
|
// database must be initialiazed
|
||||||
const adminEmail = 'admin@example.com'
|
const adminEmail = 'admin@example.com'
|
||||||
const adminPassword = 'mpwoadmin'
|
const adminPassword = 'mpwoadmin'
|
||||||
|
|
||||||
@ -43,5 +45,6 @@ test('admin should be able to access admin page', async t => {
|
|||||||
.navigateTo(`${TEST_URL}/admin`)
|
.navigateTo(`${TEST_URL}/admin`)
|
||||||
.expect(Selector('H1').withText('Access denied').exists).notOk()
|
.expect(Selector('H1').withText('Access denied').exists).notOk()
|
||||||
.expect(Selector('H1').withText('Administration').exists).ok()
|
.expect(Selector('H1').withText('Administration').exists).ok()
|
||||||
|
.expect(Selector('.admin-items').withText('Sports').exists).ok()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -16,9 +16,10 @@ class AdminMenu extends React.Component {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-2" />
|
<div className="col-md-2" />
|
||||||
<div className="col-md-8 card">
|
<div className="col-md-8 card">
|
||||||
<ul>
|
<ul className="admin-items">
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
|
className="sports"
|
||||||
to={{
|
to={{
|
||||||
pathname: '/admin/sports',
|
pathname: '/admin/sports',
|
||||||
}}
|
}}
|
||||||
|
@ -20,7 +20,7 @@ class AdminSports extends React.Component {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-2" />
|
<div className="col-md-2" />
|
||||||
<div className="col-md-8 card">
|
<div className="col-md-8 card">
|
||||||
<ul>
|
<ul className="sport-items">
|
||||||
{sports.map(sport => (
|
{sports.map(sport => (
|
||||||
<li key={sport.id}>
|
<li key={sport.id}>
|
||||||
{sport.label}
|
{sport.label}
|
||||||
|
Loading…
Reference in New Issue
Block a user