From 91d04b2170f859b261abb7962bcbdb54839fc142 Mon Sep 17 00:00:00 2001 From: SamR1 Date: Sat, 13 Jan 2018 13:13:10 +0100 Subject: [PATCH] e2e tests: profile --- mpwo_client/e2e/profile.text.js | 40 +++++++++++++++++++++ mpwo_client/src/components/User/Profile.jsx | 12 ++----- 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 mpwo_client/e2e/profile.text.js diff --git a/mpwo_client/e2e/profile.text.js b/mpwo_client/e2e/profile.text.js new file mode 100644 index 00000000..b4429503 --- /dev/null +++ b/mpwo_client/e2e/profile.text.js @@ -0,0 +1,40 @@ +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' + + +// eslint-disable-next-line no-undef +fixture('/profile').page(`${TEST_URL}/profile`) + +test('should be able to access his profile 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}/logout`) + .navigateTo(`${TEST_URL}/login`) + .expect(Selector('H1').withText('Login').exists).ok() + .typeText('input[name="email"]', email) + .typeText('input[name="password"]', password) + .click(Selector('input[type="submit"]')) + + await t + .navigateTo(`${TEST_URL}/profile`) + .expect(Selector('H1').withText('Login').exists).notOk() + .expect(Selector('H1').withText('Dashboard').exists).notOk() + .expect(Selector('H1').withText('Profile').exists).ok() + .expect(Selector('.userName').withText(username).exists).ok() + +}) diff --git a/mpwo_client/src/components/User/Profile.jsx b/mpwo_client/src/components/User/Profile.jsx index 86ce7dfe..63551098 100644 --- a/mpwo_client/src/components/User/Profile.jsx +++ b/mpwo_client/src/components/User/Profile.jsx @@ -19,9 +19,9 @@ function Profile ({ message, onDeletePicture, onUploadPicture, user }) {

Profile

-
+
-
+
{user.username} {' '}
-
-
-
- Last activities -
-
-
-