diff --git a/ui/tests/acceptance/features/accounts.feature b/ui/tests/acceptance/features/accounts.feature index eb495aa296..8afac5ae66 100644 --- a/ui/tests/acceptance/features/accounts.feature +++ b/ui/tests/acceptance/features/accounts.feature @@ -1,6 +1,6 @@ Feature: Accounts - Scenario: list accounts + Scenario: admin checks accounts list Given user "Moss" has logged in using the webUI When the user browses to the accounts page Then user "einstein" should be displayed in the accounts list on the WebUI @@ -9,7 +9,7 @@ Feature: Accounts And user "reva" should be displayed in the accounts list on the WebUI And user "richard" should be displayed in the accounts list on the WebUI - Scenario: change users role + Scenario: admin changes non-admin user's role to admin Given user "Moss" has logged in using the webUI When the user browses to the accounts page Then user "einstein" should be displayed in the accounts list on the WebUI @@ -17,3 +17,18 @@ Feature: Accounts Then the displayed role of user "einstein" should be "Admin" on the WebUI When the user reloads the current page of the webUI Then the displayed role of user "einstein" should be "Admin" on the WebUI + + Scenario: regular user should not be able to see accounts list + Given user "Marie" has logged in using the webUI + When the user browses to the accounts page + Then the user should not be able to see the accounts list on the WebUI + + Scenario: guest user should not be able to see accounts list + Given user "Moss" has logged in using the webUI + When the user browses to the accounts page + Then user "einstein" should be displayed in the accounts list on the WebUI + When the user changes the role of user "einstein" to "Guest" using the WebUI + And the user logs out of the webUI + And user "Einstein" logs in using the webUI + And the user browses to the accounts page + Then the user should not be able to see the accounts list on the WebUI diff --git a/ui/tests/acceptance/pageobjects/accountsPage.js b/ui/tests/acceptance/pageobjects/accountsPage.js index dffd11707d..03e801df58 100644 --- a/ui/tests/acceptance/pageobjects/accountsPage.js +++ b/ui/tests/acceptance/pageobjects/accountsPage.js @@ -71,6 +71,10 @@ module.exports = { rolesDropdownTrigger: { selector: '//button[contains(@class, "accounts-roles-select-trigger")]', locateStrategy: 'xpath' + }, + loadingAccountsList: { + selector: '//div[contains(@class, "oc-loader")]', + locateStrategy: 'xpath' } } } diff --git a/ui/tests/acceptance/stepDefinitions/accountsContext.js b/ui/tests/acceptance/stepDefinitions/accountsContext.js index b07eb340f2..7be646eb58 100644 --- a/ui/tests/acceptance/stepDefinitions/accountsContext.js +++ b/ui/tests/acceptance/stepDefinitions/accountsContext.js @@ -1,6 +1,6 @@ const assert = require('assert') const { client } = require('nightwatch-api') -const { When, Then } = require('cucumber') +const { Given, When, Then } = require('cucumber') When('the user browses to the accounts page', function () { return client.page.accountsPage().navigateAndWaitTillLoaded() @@ -12,6 +12,10 @@ Then('user {string} should be displayed in the accounts list on the WebUI', asyn return assert.strictEqual(userListed, username) }) +Given('the user has changed the role of user {string} to {string}', function (username, role) { + return client.page.accountsPage().selectRole(username, role) +}) + When('the user changes the role of user {string} to {string} using the WebUI', function (username, role) { return client.page.accountsPage().selectRole(username, role) }) @@ -19,3 +23,10 @@ When('the user changes the role of user {string} to {string} using the WebUI', f Then('the displayed role of user {string} should be {string} on the WebUI', function (username, role) { return client.page.accountsPage().checkUsersRole(username, role) }) + +Then('the user should not be able to see the accounts list on the WebUI', async function () { + return client.page.accountsPage() + .waitForAjaxCallsToStartAndFinish() + .waitForElementVisible('@loadingAccountsList') + .waitForElementNotPresent('@accountsListTable') +})