From cef78c3713a2f6a72f9f1016bcc8288f9a86380c Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Fri, 10 Nov 2017 15:42:10 +0200 Subject: [PATCH] use randomly generated names for users, nodes --- e2e/suites/actions/create-folder.test.ts | 31 +++++++--------- e2e/suites/actions/edit-folder.test.ts | 30 +++++++-------- e2e/suites/application/page-titles.test.ts | 1 - e2e/suites/authentication/login.test.ts | 35 +++++++----------- e2e/suites/authentication/logout.test.ts | 16 ++------ e2e/suites/list-views/personal-files.test.ts | 37 ++++++++----------- e2e/suites/navigation/side-navigation.test.ts | 2 - e2e/suites/pagination/pagination.test.ts | 22 +++++------ 8 files changed, 70 insertions(+), 104 deletions(-) diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index c608562cf..f5639049e 100644 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -24,21 +24,20 @@ import { Utils } from '../../utilities/utils'; import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; describe('Create folder', () => { - const username = 'jane.doe'; - const password = 'jane.doe'; + const username = `user-${Utils.random()}`; - const parent = 'parent-folder'; - const folderName1 = 'my-folder1'; - const folderName2 = 'my-folder2'; + const parent = `parent-${Utils.random()}`; + const folderName1 = `folder-${Utils.random()}`; + const folderName2 = `folder-${Utils.random()}`; const folderDescription = 'description of my folder'; - const duplicateFolderName = 'duplicate-folder-name'; - const nameWithSpaces = ' folder-name '; + const duplicateFolderName = `folder-${Utils.random()}`; + const nameWithSpaces = ` folder-${Utils.random()} `; - const siteName = 'site-private'; + const siteName = `site-private-${Utils.random()}`; const apis = { admin: new RepoClient(), - user: new RepoClient(username, password) + user: new RepoClient(username, username) }; const loginPage = new LoginPage(); @@ -57,14 +56,14 @@ describe('Create folder', () => { } beforeAll(done => { - apis.admin.people.createUser(username, password) + apis.admin.people.createUser(username) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE)) .then(() => apis.admin.nodes.createFolders([ folderName1 ], `Sites/${siteName}/documentLibrary`)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.user.nodes.createFolders([ duplicateFolderName ], parent)) - .then(() => loginPage.load()) - .then(() => loginPage.loginWith(username, password)) - .then(done); + .then(() => loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done)); }); beforeEach(done => { @@ -80,9 +79,9 @@ describe('Create folder', () => { afterAll(done => { Promise .all([ + apis.admin.sites.deleteSite(siteName, true), apis.user.nodes.deleteNodes([ parent ]), logoutPage.load() - .then(() => Utils.clearLocalStorage()) ]) .then(done); }); @@ -128,9 +127,7 @@ describe('Create folder', () => { }) .then(() => { apis.user.nodes.getNodeDescription(folderName2) - .then((description) => { - expect(description).toEqual(folderDescription, 'Description is not correct'); - }); + .then((description) => expect(description).toEqual(folderDescription)); }) ); }); diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index 441ba60fa..26ebd85be 100644 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -23,24 +23,23 @@ import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-fo import { Utils } from '../../utilities/utils'; describe('Edit folder', () => { - const username = 'john.doe'; - const password = 'john.doe'; + const username = `user-${Utils.random()}`; - const parent = 'parent-folder'; - const folderName = 'my-folder'; + const parent = `parent-${Utils.random()}`; + const folderName = `folder-${Utils.random()}`; const folderDescription = 'my folder description'; - const folderNameToEdit = 'folder-to-be-edited'; - const duplicateFolderName = 'duplicate-folder-name'; + const folderNameToEdit = `folder-${Utils.random()}`; + const duplicateFolderName = `folder-${Utils.random()}`; - const folderNameEdited = 'edited-folder'; + const folderNameEdited = `folder-${Utils.random()}`; const folderDescriptionEdited = 'my folder description edited'; - const siteName = 'site-private'; + const siteName = `site-private-${Utils.random()}`; const apis = { admin: new RepoClient(), - user: new RepoClient(username, password) + user: new RepoClient(username, username) }; const loginPage = new LoginPage(); @@ -53,18 +52,18 @@ describe('Edit folder', () => { beforeAll(done => { Promise .all([ - apis.admin.people.createUser(username, password), + apis.admin.people.createUser(username), apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE) .then(() => apis.admin.nodes.createFolders([ folderName ], `Sites/${siteName}/documentLibrary`)) ]) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => Promise.all([ apis.user.nodes.createNodeWithProperties( folderName, '', folderDescription, parent ), - apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent), - loginPage.load() + apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent) ])) - .then(() => loginPage.loginWith(username, password)) - .then(done); + .then(() => loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done)); }); beforeEach(done => { @@ -83,7 +82,6 @@ describe('Edit folder', () => { apis.admin.sites.deleteSite(siteName, true), apis.user.nodes.deleteNodes([ parent ]), logoutPage.load() - .then(() => Utils.clearLocalStorage()) ]) .then(done); }); @@ -111,7 +109,7 @@ describe('Edit folder', () => { ); }); - it('folder properties are modified when pressing OK', () => { + it('properties are modified when pressing OK', () => { personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) .then(() => dataTable.clickOnRowByContainingText(folderNameToEdit) .then(() => editButton.click()) diff --git a/e2e/suites/application/page-titles.test.ts b/e2e/suites/application/page-titles.test.ts index 6906435af..498913ee6 100644 --- a/e2e/suites/application/page-titles.test.ts +++ b/e2e/suites/application/page-titles.test.ts @@ -65,7 +65,6 @@ describe('Page titles', () => { afterAll(done => { logoutPage.load() - .then(() => Utils.clearLocalStorage()) .then(done); }); diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index 56d804805..527483553 100644 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -27,19 +27,16 @@ describe('Login', () => { const loginPage = new LoginPage(); const logoutPage = new LogoutPage(); - const testUser = { - username: 'test.user@alfness', - password: 'test.user' - }; + const testUser = `user-${Utils.random()}@alfness`; const russianUser = { - username: 'пользователь', + username: `пользвате${Utils.random()}`, password: '密碼中國' }; const johnDoe = { - username: 'john.doe', - password: 'john.doe', + username: `user-${Utils.random()}`, + get password() { return this.username; }, firstName: 'John', lastName: 'Doe' }; @@ -47,7 +44,7 @@ describe('Login', () => { beforeAll(done => { Promise .all([ - peopleApi.createUser(testUser.username, testUser.password), + peopleApi.createUser(testUser), peopleApi.createUser(russianUser.username, russianUser.password), peopleApi.createUser(johnDoe.username, johnDoe.password, { firstName: johnDoe.firstName, @@ -71,10 +68,9 @@ describe('Login', () => { describe('with valid credentials', () => { it('navigate to "Personal Files"', () => { - const { username, password } = johnDoe; + const { username } = johnDoe; - loginPage - .loginWith(username, password) + loginPage.loginWith(username) .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); }); @@ -82,20 +78,17 @@ describe('Login', () => { it(`displays user's name in header`, () => { const { userInfo } = new BrowsingPage(APP_ROUTES.PERSONAL_FILES).header; - const { username, password, firstName, lastName } = johnDoe; + const { username, firstName, lastName } = johnDoe; - loginPage - .loginWith(username, password) + loginPage.loginWith(username) .then(() => { expect(userInfo.name).toEqual(`${firstName} ${lastName}`); }); }); it(`logs in with user having username containing "@"`, () => { - const { username, password } = testUser; - loginPage - .loginWith(username, password) + .loginWith(testUser) .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); }); @@ -112,10 +105,10 @@ describe('Login', () => { }); it('redirects to Home Page when navigating to the Login page while already logged in', () => { - const { username, password } = johnDoe; + const { username } = johnDoe; loginPage - .loginWith(username, password) + .loginWith(username) .then(() => browser.get(APP_ROUTES.LOGIN) .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); @@ -124,10 +117,10 @@ describe('Login', () => { }); it('redirects to Personal Files when pressing browser Back while already logged in ', () => { - const { username, password } = johnDoe; + const { username } = johnDoe; loginPage - .loginWith(username, password) + .loginWith(username) .then(() => browser.driver.navigate().back()) .then(() => { expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); diff --git a/e2e/suites/authentication/logout.test.ts b/e2e/suites/authentication/logout.test.ts index 6a48edc25..773f961a0 100644 --- a/e2e/suites/authentication/logout.test.ts +++ b/e2e/suites/authentication/logout.test.ts @@ -29,20 +29,17 @@ describe('Logout', () => { const peopleApi = new RepoClient().people; - const johnDoe = { - username: 'john.doe', - password: 'john.doe' - }; + const johnDoe = `user-${Utils.random()}`; beforeAll((done) => { peopleApi - .createUser(johnDoe.username, johnDoe.password) + .createUser(johnDoe) .then(done); }); beforeEach((done) => { loginPage.load() - .then(() => loginPage.loginWith(johnDoe.username, johnDoe.password)) + .then(() => loginPage.loginWith(johnDoe)) .then(done); }); @@ -59,13 +56,6 @@ describe('Logout', () => { }); }); - xit('redirects to Login page when logging out by URL', () => { - browser.get(APP_ROUTES.LOGOUT) - .then(() => { - expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN); - }); - }); - it('redirects to Login page when pressing browser Back after logout', () => { page.signOut() .then(() => browser.driver.navigate().back()) diff --git a/e2e/suites/list-views/personal-files.test.ts b/e2e/suites/list-views/personal-files.test.ts index efe263793..898219753 100644 --- a/e2e/suites/list-views/personal-files.test.ts +++ b/e2e/suites/list-views/personal-files.test.ts @@ -23,8 +23,8 @@ import { Utils } from '../../utilities/utils'; import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; describe('Personal Files', () => { - const username = 'jane.doe'; - const password = 'jane.doe'; + const username = `user-${Utils.random()}`; + const password = username; const apis = { admin: new RepoClient(), @@ -36,30 +36,27 @@ describe('Personal Files', () => { const personalFilesPage = new BrowsingPage(APP_ROUTES.PERSONAL_FILES); const dataTable = personalFilesPage.dataTable; - const adminContent: NodeContentTree = { - name: 'admin-folder' - }; + const adminFolder = `admin-folder-${Utils.random()}`; - const userContent: NodeContentTree = { - name: 'user-folder', - files: [ 'user-file.txt' ] - }; + const userFolder = `user-folder-${Utils.random()}`; + const userFile = `file-${Utils.random()}.txt`; beforeAll(done => { Promise .all([ apis.admin.people.createUser(username, password), - apis.admin.nodes.createContent(adminContent) + apis.admin.nodes.createFolders([ adminFolder ]) ]) - .then(() => apis.user.nodes.createContent(userContent)) + .then(() => apis.user.nodes.createFolders([ userFolder ])) + .then(() => apis.user.nodes.createFiles([ userFile ], userFolder)) .then(done); }); afterAll(done => { Promise .all([ - apis.admin.nodes.deleteNodes([ adminContent.name ]), - apis.user.nodes.deleteNodes([ userContent.name ]) + apis.admin.nodes.deleteNodes([ adminFolder ]), + apis.user.nodes.deleteNodes([ userFolder ]) ]) .then(done); }); @@ -81,7 +78,6 @@ describe('Personal Files', () => { afterAll(done => { logoutPage.load() - .then(() => Utils.clearLocalStorage()) .then(done); }); @@ -109,7 +105,6 @@ describe('Personal Files', () => { afterAll(done => { logoutPage.load() - .then(() => Utils.clearLocalStorage()) .then(done); }); @@ -131,17 +126,17 @@ describe('Personal Files', () => { }); it('has user created content', () => { - expect(dataTable.getRowByContainingText('user-folder').isPresent()) + expect(dataTable.getRowByContainingText(userFolder).isPresent()) .toBe(true); }); it('navigates to folder', () => { const getNodeIdPromise = apis.user.nodes - .getNodeByPath('/user-folder') + .getNodeByPath(`/${userFolder}`) .then(response => response.data.entry.id); const navigatePromise = dataTable - .doubleClickOnRowByContainingText('user-folder') + .doubleClickOnRowByContainingText(userFolder) .then(() => dataTable.waitForHeader()); Promise @@ -153,8 +148,8 @@ describe('Personal Files', () => { expect(browser.getCurrentUrl()) .toContain(nodeId, 'Node ID is not in the URL'); - expect(dataTable.getRowByContainingText('user-file.txt').isPresent()) - .toBe(true, '"user-file.txt" is missing'); + expect(dataTable.getRowByContainingText(userFile).isPresent()) + .toBe(true, 'user file is missing'); }); }); @@ -165,7 +160,7 @@ describe('Personal Files', () => { const { actions } = personalFilesPage.toolbar; dataTable - .clickOnRowByContainingText('user-folder') + .clickOnRowByContainingText(userFolder) .then(() => { expect(actions.isEmpty()).toBe(false, 'Toolbar to be present'); }) diff --git a/e2e/suites/navigation/side-navigation.test.ts b/e2e/suites/navigation/side-navigation.test.ts index bf6c8541d..792b4d845 100644 --- a/e2e/suites/navigation/side-navigation.test.ts +++ b/e2e/suites/navigation/side-navigation.test.ts @@ -19,7 +19,6 @@ import { browser } from 'protractor'; import { APP_ROUTES, SIDEBAR_LABELS } from '../../configs'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; -import { Utils } from '../../utilities/utils'; describe('Side navigation', () => { const loginPage = new LoginPage(); @@ -38,7 +37,6 @@ describe('Side navigation', () => { afterAll(done => { logoutPage.load() - .then(() => Utils.clearLocalStorage()) .then(done); }); diff --git a/e2e/suites/pagination/pagination.test.ts b/e2e/suites/pagination/pagination.test.ts index 7fb40c359..e510e3973 100644 --- a/e2e/suites/pagination/pagination.test.ts +++ b/e2e/suites/pagination/pagination.test.ts @@ -23,12 +23,11 @@ import { Utils } from '../../utilities/utils'; import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; describe('Pagination', () => { - const username = 'jane.doe'; - const password = 'jane.doe'; + const username = `user-${Utils.random()}`; const apis = { admin: new RepoClient(), - user: new RepoClient(username, password) + user: new RepoClient(username, username) }; const loginPage = new LoginPage(); @@ -36,7 +35,7 @@ describe('Pagination', () => { beforeAll(done => { apis.admin.people - .createUser(username, password) + .createUser(username) .then(done); }); @@ -48,7 +47,7 @@ describe('Pagination', () => { // Generate files const content: NodeContentTree = { - name: 'user-folder', + name: `user-folder-${Utils.random()}`, files: Array(101) .fill('file') .map((name, index): string => `${name}-${index + 1}.txt`) @@ -58,14 +57,13 @@ describe('Pagination', () => { beforeAll(done => { nodesApi.createContent(content) - .then(() => loginPage.load()) - .then(() => loginPage.loginWith(username, password)) - .then(done); + .then(() => loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done)); }); beforeEach(done => { - personalFilesPage - .load() + personalFilesPage.load() .then(() => dataTable.waitForHeader()) .then(() => dataTable.doubleClickOnRowByContainingText(content.name)) .then(() => dataTable.sortByColumn('Name')) @@ -73,9 +71,7 @@ describe('Pagination', () => { }); afterAll(done => { - logoutPage - .load() - .then(() => Utils.clearLocalStorage()) + logoutPage.load() .then(() => nodesApi.deleteNodes([ content.name ])) .then(done); });