Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Add acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed Sep 6, 2020
1 parent 3980084 commit accc586
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ui/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<oc-grid v-if="selectedAccountsAmount > 0" key="selected-accounts-info" gutter="small" class="uk-flex-middle">
<span v-text="selectionInfoText" />
<div>
<oc-action-drop>
<oc-action-drop class="accounts-actions-dropdown">
<template v-slot:button>
<span class="uk-margin-xsmall-right" v-text="$gettext('Actions')" />
<oc-icon name="expand_more" />
Expand All @@ -14,6 +14,7 @@
<oc-button
v-for="(action, index) in actions"
:key="action.label"
:id="action.id"
variation="raw"
role="menuitem"
:class="{ 'uk-margin-small-bottom': index + 1 !== actions.length }"
Expand Down Expand Up @@ -65,13 +66,15 @@ export default {
if (isAnyAccountDisabled) {
actions.push({
id: 'accounts-actions-dropdown-action-enable',
label: this.$gettext('Enable'),
handler: this.enableAccounts
})
}
if (isAnyAccountEnabled) {
actions.push({
id: 'accounts-actions-dropdown-action-disable',
label: this.$gettext('Disable'),
handler: this.disableAccounts
})
Expand Down
18 changes: 16 additions & 2 deletions ui/components/accounts/AccountsListRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,22 @@
<oc-table-cell v-text="account.uidNumber || '-'" />
<oc-table-cell v-text="account.gidNumber || '-'" />
<oc-table-cell class="uk-text-center">
<oc-icon v-if="account.accountEnabled" key="account-icon-enabled" name="ready" variation="success" :aria-label="$gettext('Account is enabled')" />
<oc-icon v-else name="deprecated" key="account-icon-disabled" variation="danger" :aria-label="$gettext('Account is disabled')" />
<oc-icon
v-if="account.accountEnabled"
key="account-icon-enabled"
name="ready"
variation="success"
:aria-label="$gettext('Account is enabled')"
class="accounts-status-indicator-enabled"
/>
<oc-icon
v-else
name="deprecated"
key="account-icon-disabled"
variation="danger"
:aria-label="$gettext('Account is disabled')"
class="accounts-status-indicator-disabled"
/>
</oc-table-cell>
</oc-table-row>
</template>
Expand Down
31 changes: 31 additions & 0 deletions ui/tests/acceptance/features/accounts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,34 @@ Feature: Accounts
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

Scenario: disable account
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 disables user "einstein" using the WebUI
Then the status indicator of user "einstein" should be "disabled" on the WebUI
# At the moment user can log in even when disabled via WebUI - needs investigation
# And user "einstein" should not be able to log in

Scenario: disable multiple accounts
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
And user "marie" should be displayed in the accounts list on the WebUI
When the user disables users "einstein,marie" using the WebUI
Then the status indicator of users "einstein,marie" should be "disabled" on the WebUI
# And user "einstein" should not be able to log in
# And user "marie" should not be able to log in

Scenario: enable disabled account
Given user "Moss" has logged in using the webUI
# And user "einstein" has been disabled
When the user browses to the accounts page
Then user "einstein" should be displayed in the accounts list on the WebUI
# Disable the user manually until the prev commented out step gets implemented
When the user disables user "einstein" using the WebUI
Then the status indicator of user "einstein" should be "disabled" on the WebUI
When the user enables user "einstein" using the WebUI
Then the status indicator of user "einstein" should be "enabled" on the WebUI
# And user "einstein" should be able to log in
49 changes: 49 additions & 0 deletions ui/tests/acceptance/pageobjects/accountsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,37 @@ module.exports = {
util.format(this.elements.currentRole.selector, role)

return this.useXpath().expect.element(roleSelector).to.be.visible
},

toggleUserStatus: function (usernames, status) {
usernames = usernames.split(',')
const actionSelector = status === 'enabled' ? this.elements.enableAction : this.elements.disableAction

// Select users
for (const username of usernames) {
const checkboxSelector =
util.format(this.elements.rowByUsername.selector, username) +
this.elements.rowCheckbox.selector

this.useXpath().click(checkboxSelector)
}

return this.click('@actionsDropdownTrigger').useCss().click(actionSelector).useXpath()
},

checkUsersStatus: function (usernames, status) {
usernames = usernames.split(',')

for (const username of usernames) {
const indicatorSelector =
util.format(this.elements.rowByUsername.selector, username) +
util.format(this.elements.statusIndicator.selector, status)

// eslint-disable-next-line no-unused-expressions
this.useXpath().expect.element(indicatorSelector).to.be.visible
}

return this
}
},

Expand Down Expand Up @@ -75,6 +106,24 @@ module.exports = {
loadingAccountsList: {
selector: '//div[contains(@class, "oc-loader")]',
locateStrategy: 'xpath'
},
rowCheckbox: {
selector: '//input[@class="oc-checkbox"]',
locateStrategy: 'xpath'
},
actionsDropdownTrigger: {
selector: '//div[contains(@class, "accounts-actions-dropdown")]//button[normalize-space()="Actions"]',
locateStrategy: 'xpath'
},
disableAction: {
selector: '#accounts-actions-dropdown-action-disable'
},
enableAction: {
selector: '#accounts-actions-dropdown-action-enable'
},
statusIndicator: {
selector: '//span[contains(@class, "accounts-status-indicator-%s")]',
locateStrategy: 'xpath'
}
}
}
12 changes: 12 additions & 0 deletions ui/tests/acceptance/stepDefinitions/accountsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ Then('the user should not be able to see the accounts list on the WebUI', async
.waitForElementVisible('@loadingAccountsList')
.waitForElementNotPresent('@accountsListTable')
})

When('the user disables user/users {string} using the WebUI', function (usernames) {
return client.page.accountsPage().toggleUserStatus(usernames, 'disabled')
})

When('the user enables user/users {string} using the WebUI', function (usernames) {
return client.page.accountsPage().toggleUserStatus(usernames, 'enabled')
})

Then('the status indicator of user/users {string} should be {string} on the WebUI', function (usernames, status) {
return client.page.accountsPage().checkUsersStatus(usernames, status)
})

0 comments on commit accc586

Please sign in to comment.