Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test-only] E2e. changing user #8602

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<form id="user-edit-form" class="oc-background-highlight oc-p-m" autocomplete="off">
<div>
<oc-text-input
id="userName-input"
v-model="editUser.onPremisesSamAccountName"
class="oc-mb-s"
:label="$gettext('User name')"
Expand All @@ -12,6 +13,7 @@
@update:model-value="validateUserName"
/>
<oc-text-input
id="displayName-input"
v-model="editUser.displayName"
class="oc-mb-s"
:label="$gettext('First and last name')"
Expand All @@ -20,6 +22,7 @@
@update:model-value="validateDisplayName"
/>
<oc-text-input
id="email-input"
v-model="editUser.mail"
class="oc-mb-s"
:label="$gettext('Email')"
Expand All @@ -29,6 +32,7 @@
@change="validateEmail"
/>
<oc-text-input
id="password-input"
:model-value="editUser.passwordProfile?.password"
class="oc-mb-s"
:label="$gettext('Password')"
Expand All @@ -39,6 +43,7 @@
/>
<div class="oc-mb-s">
<oc-select
id="role-input"
:model-value="editUser"
:label="$gettext('Role')"
option-label="displayName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ exports[`EditPanel renders all available inputs 1`] = `
<user-info-box-stub user="[object Object]"></user-info-box-stub>
<form autocomplete="off" class="oc-background-highlight oc-p-m" id="user-edit-form">
<div>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="oc-textinput-1" label="User name" type="text"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="oc-textinput-2" label="First and last name" modelvalue="jan" type="text"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="oc-textinput-3" label="Email" modelvalue="[email protected]" type="email"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" fixmessageline="true" id="oc-textinput-4" label="Password" modelvalue="" placeholder="●●●●●●●●" type="password"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="userName-input" label="User name" type="text"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="displayName-input" label="First and last name" modelvalue="jan" type="text"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" errormessage="" fixmessageline="true" id="email-input" label="Email" modelvalue="[email protected]" type="email"></oc-text-input-stub>
<oc-text-input-stub class="oc-mb-s" clearbuttonaccessiblelabel="" clearbuttonenabled="false" disabled="false" fixmessageline="true" id="password-input" label="Password" modelvalue="" placeholder="●●●●●●●●" type="password"></oc-text-input-stub>
<div class="oc-mb-s">
<oc-select-stub clearable="false" disabled="false" filter="[Function]" id="oc-select-5" label="Role" loading="false" model-value="[object Object]" optionlabel="displayName" options="[object Object]" searchable="true"></oc-select-stub>
<oc-select-stub clearable="false" disabled="false" filter="[Function]" id="role-input" label="Role" loading="false" model-value="[object Object]" optionlabel="displayName" options="[object Object]" searchable="true"></oc-select-stub>
<div class="oc-text-input-message"></div>
</div>
<div class="oc-mb-s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,24 @@ Feature: spaces management
| Alice |
| Brian |
And "Admin" logs out


Scenario: edit user
Given "Admin" creates following users
| id |
| Alice |
When "Admin" logs in
And "Admin" opens the "admin-settings" app
And "Admin" navigates to the users management page
When "Admin" changes userName to "anna" for user "Alice" using the sidebar panel
And "Admin" changes displayName to "Anna Murphy" for user "Alice" using the sidebar panel
And "Admin" changes email to "[email protected]" for user "Alice" using the sidebar panel
And "Admin" changes password to "password" for user "Alice" using the sidebar panel
And "Admin" changes role to "Space Admin" for user "Alice" using the sidebar panel
And "Admin" logs out
When "anna" logs in
Then "anna" should have self info:
| key | value |
| username | anna |
| displayname | Anna Murphy |
| email | [email protected] |
34 changes: 33 additions & 1 deletion tests/e2e/cucumber/steps/ui/adminSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataTable, Then, When } from '@cucumber/cucumber'
import { World } from '../../environment'
import { objects } from '../../../support'
import { api, objects } from '../../../support'
import { expect } from '@playwright/test'

When(
Expand Down Expand Up @@ -242,3 +242,35 @@ When(
}
}
)

When(
/^"([^"]*)" changes (userName|displayName|email|password|role) to "([^"]*)" for user "([^"]*)" using the sidebar panel$/,
async function (
this: World,
stepUser: string,
attribute: string,
value: string,
user: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const usersObject = new objects.applicationAdminSettings.Users({ page })

// deleting a user with a same userName before testing
if (attribute === 'userName') {
const newUser = this.usersEnvironment.createUser({
key: value,
user: {
id: value,
displayName: '',
password: 'password',
email: ''
}
})
Comment on lines +260 to +268
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: why not call this.usersEnvironment.getUser() here instead?

Copy link
Contributor Author

@ScharfViktor ScharfViktor Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we get error user with key anna not found.
https://github.com/owncloud/web/blob/master/tests/e2e/support/environment/userManagement.ts#L8-L9
We need create anna in the store before deleting

await api.graph.deleteUser({
user: newUser,
admin: this.usersEnvironment.getUser({ key: stepUser })
})
}
await usersObject.changeUser({ key: user, attribute: attribute, value: value })
}
)
14 changes: 13 additions & 1 deletion tests/e2e/cucumber/steps/ui/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When, Then } from '@cucumber/cucumber'
import { When, Then, DataTable } from '@cucumber/cucumber'
import { World } from '../../environment'
import { objects } from '../../../support'
import { expect } from '@playwright/test'
Expand Down Expand Up @@ -27,3 +27,15 @@ Then(
expect(quotaValue).toBe(quota)
}
)

Then(
/^"([^"]*)" should have self info:$/,
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })

for (const info of stepTable.hashes()) {
expect(info.value).toBe(await accountObject.getUserInfo(info.key))
}
}
)
9 changes: 9 additions & 0 deletions tests/e2e/support/objects/account/account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Page } from 'playwright'
import util from 'util'

const accountMenuButton = '.oc-topbar-personal-avatar'
const quotaValue = '.storage-wrapper-text .oc-text-small'
const accountManageButton = '#oc-topbar-account-manage'
const infoValue = '.account-page-info-%s dd'

export class Account {
#page: Page
Expand All @@ -20,4 +23,10 @@ export class Account {
const value = quotaText.split('of')
return value[1].replace(/[^0-9]/g, '')
}

async getUserInfo(key: string): Promise<string> {
await this.#page.locator(accountMenuButton).click()
await this.#page.locator(accountManageButton).click()
return await this.#page.locator(util.format(infoValue, key)).textContent()
}
}
29 changes: 29 additions & 0 deletions tests/e2e/support/objects/app-admin-settings/users/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const userCheckboxSelector = `[data-item-id="%s"]:not(.oc-table-highlighted) inp
const editQuotaBtn = '.oc-files-actions-edit-quota-trigger'
const quotaInputBatchAction = '#quota-select-batch-action-form .vs__search'
const confirmChangeQuotaSeveralSpacesBtn = '.oc-modal-body-actions-confirm'
const userInput = '#%s-input'
const roleValueDropDown = `.vs__dropdown-menu :text-is("%s")`

export const changeAccountEnabled = async (args: {
page: Page
Expand Down Expand Up @@ -158,3 +160,30 @@ export const filterUsers = async (args: {
])
}
}

export const changeUser = async (args: {
page: Page
uuid: string
attribute: string
value: string
}): Promise<void> => {
const { page, attribute, value, uuid } = args
await page.locator(util.format(userIdSelector, uuid)).click()
await page.waitForSelector(editActionBtn)
await page.locator(`.context-menu`).locator(editActionBtn).click()
await page.locator(util.format(userInput, attribute)).fill(value)

if (attribute === 'role') {
await page.locator(util.format(roleValueDropDown, value)).click()
}

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().endsWith(encodeURIComponent(uuid)) &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
),
await page.locator(compareDialogConfirm).click()
])
}
15 changes: 14 additions & 1 deletion tests/e2e/support/objects/app-admin-settings/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
filterUsers,
getDisplayedUsers,
removeSelectedUsersFromGroups,
selectUser
selectUser,
changeUser
} from './actions'

export class Users {
Expand Down Expand Up @@ -57,4 +58,16 @@ export class Users {
async filter({ filter, values }: { filter: string; values: string[] }): Promise<void> {
await filterUsers({ page: this.#page, filter, values })
}
async changeUser({
key,
attribute,
value
}: {
key: string
attribute: string
value: string
}): Promise<void> {
const { uuid } = this.#usersEnvironment.getUser({ key })
await changeUser({ uuid, attribute: attribute, value: value, page: this.#page })
}
}