From 3f025357b934e4de37d4fb47fb00d5e41214181a Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 29 Apr 2018 19:21:22 +0200 Subject: [PATCH] e2e test: admin/sports e2e test: admin/sports --- mpwo_client/e2e/admin-sports.test.js | 31 +++++++++++++++++++ mpwo_client/e2e/admin.test.js | 3 ++ .../src/components/Admin/AdminMenu.jsx | 3 +- .../src/components/Admin/AdminSports.jsx | 2 +- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 mpwo_client/e2e/admin-sports.test.js diff --git a/mpwo_client/e2e/admin-sports.test.js b/mpwo_client/e2e/admin-sports.test.js new file mode 100644 index 00000000..64470c8d --- /dev/null +++ b/mpwo_client/e2e/admin-sports.test.js @@ -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() + +}) diff --git a/mpwo_client/e2e/admin.test.js b/mpwo_client/e2e/admin.test.js index d1cd02ca..7f841626 100644 --- a/mpwo_client/e2e/admin.test.js +++ b/mpwo_client/e2e/admin.test.js @@ -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() }) diff --git a/mpwo_client/src/components/Admin/AdminMenu.jsx b/mpwo_client/src/components/Admin/AdminMenu.jsx index e6357855..fb7cee93 100644 --- a/mpwo_client/src/components/Admin/AdminMenu.jsx +++ b/mpwo_client/src/components/Admin/AdminMenu.jsx @@ -16,9 +16,10 @@ class AdminMenu extends React.Component {
-
    +
    • -
        +
          {sports.map(sport => (
        • {sport.label}