Skip to content

Commit

Permalink
Merge pull request #8986 from owncloud/backport-test-adjustments
Browse files Browse the repository at this point in the history
[full-ci] Backport test adjustments
  • Loading branch information
kulmann authored May 5, 2023
2 parents 12f39df + 52d90f4 commit 548ff61
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OCIS to use in pipelines that test against OCIS
OCIS_COMMITID=01f660418296efe4018409f8887e33ec068a70ac
OCIS_COMMITID=33d9be383249a9e2db2c0c1207797227186d6649
OCIS_BRANCH=master
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ Feature: Sharing files and folders with internal groups
| entry_name |
| simple-folder |
| testimage.jpg |
And these resources should be listed in the folder "/Shares%2Fsimple-folder" on the webUI
And these resources should be listed in the folder "/Shares/simple-folder" on the webUI
| entry_name |
| lorem.txt |
But these resources should not be listed in the folder "/Shares%2Fsimple-folder" on the webUI
But these resources should not be listed in the folder "/Shares/simple-folder" on the webUI
| entry_name |
| simple-folder |
When the user browses to the shared-with-me page
Expand Down
16 changes: 12 additions & 4 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,21 @@ module.exports = {
* @param {string} folder
*/
navigateToFolder: async function (folder) {
await this.waitForFileVisible(folder)
const paths = folder.split('/')
for (const folderName of paths) {
if (folderName === '') {
continue
}

await this.useXpath().click(this.getFileLinkSelectorByFileName(folder, 'folder')).useCss()
await this.waitForFileVisible(folderName)

// wait until loading is finished
await this.waitForLoadingFinished()
await this.useXpath()
.click(this.getFileLinkSelectorByFileName(folderName, 'folder'))
.useCss()

// wait until loading is finished
await this.waitForLoadingFinished()
}
return this
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ module.exports = {
return this.waitForElementVisible('@publicLinkCreateButton')
.initAjaxCounters()
.click('@publicLinkCreateButton')
.waitForElementNotPresent('@popupNotificationMessage')
.waitForOutstandingAjaxCalls()
},
/**
Expand Down Expand Up @@ -545,6 +546,11 @@ module.exports = {
}
},
elements: {
popupNotificationMessage: {
selector:
'//*[contains(@class, "oc-notification-message")]//div[contains(@class, "oc-notification-message-title")]',
locateStrategy: 'xpath'
},
latestLinkName: {
selector: '//div[@id="oc-files-file-link"]//ul/li[1]//h4',
locateStrategy: 'xpath'
Expand Down
8 changes: 3 additions & 5 deletions tests/acceptance/pageObjects/personalPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ module.exports = {
*
* @param {string} folder
*/
navigateToFolder: function (folder) {
return this.page.FilesPageElement.filesList()
.navigateToFolder(folder)
.waitForElementVisible('@breadcrumb')
.assert.containsText('@breadcrumb', folder)
navigateToFolder: async function (folder) {
await this.page.FilesPageElement.filesList().navigateToFolder(folder)
return this
},
/**
*
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ Then('these files/folders/resources should be listed on the webUI', function (en
Then(
'these files/folders/resources should be listed in the folder {string} on the webUI',
async function (folder, entryList) {
await client.page.personalPage().navigateAndWaitTillLoaded(folder)
await client.page.personalPage().navigateAndWaitTillLoaded()
await client.page.personalPage().navigateToFolder(folder)
return theseResourcesShouldBeListed(entryList)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ Feature: users management
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" changes displayName to "Anna Murphy" for user "anna" using the sidebar panel
And "Admin" changes email to "[email protected]" for user "anna" using the sidebar panel
And "Admin" changes password to "password" for user "anna" using the sidebar panel
And "Admin" changes role to "Space Admin" for user "anna" using the sidebar panel
And "Admin" logs out
When "anna" logs in
Then "anna" should have self info:
Expand Down
12 changes: 0 additions & 12 deletions tests/e2e/cucumber/steps/ui/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ When(
user = this.usersEnvironment.getUser({ key: stepUser })
} catch (e) {}

if (!user) {
user = this.usersEnvironment.createUser({
key: stepUser,
user: {
id: stepUser,
displayName: stepUser,
password: '',
email: ''
}
})
}

let actor
try {
actor = this.actorsEnvironment.getActor(user)
Expand Down
11 changes: 7 additions & 4 deletions tests/e2e/support/api/graph/userManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import join from 'join-path'
import { config } from '../../../config'
import { getApplicationEntity } from './utils'
import { userRoleStore } from '../../store'
import { UsersEnvironment } from '../../environment'

export const me = async ({ user }: { user: User }): Promise<Me> => {
const response = await request({
Expand Down Expand Up @@ -32,9 +33,8 @@ export const createUser = async ({ user, admin }: { user: User; admin: User }):

checkResponseStatus(response, 'Failed while creating user')

const responseData = await response.json()
user.uuid = responseData.id

const usersEnvironment = new UsersEnvironment()
usersEnvironment.storeCreatedUser({ user: { ...user, uuid: (await response.json()).id } })
return user
}

Expand All @@ -44,7 +44,10 @@ export const deleteUser = async ({ user, admin }: { user: User; admin: User }):
path: join('graph', 'v1.0', 'users', user.id),
user: admin
})

try {
const usersEnvironment = new UsersEnvironment()
usersEnvironment.removeCreatedUser({ key: user.id })
} catch (e) {}
return user
}

Expand Down
13 changes: 10 additions & 3 deletions tests/e2e/support/api/userManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { checkResponseStatus, checkOCJsonStatus, request } from './http'
import { Group, User } from '../types'
import { URLSearchParams } from 'url'
import join from 'join-path'
import { UsersEnvironment } from '../environment'

export const createUser = async ({ user, admin }: { user: User; admin: User }): Promise<void> => {
const promChain = []
Expand All @@ -21,8 +22,11 @@ export const createUser = async ({ user, admin }: { user: User; admin: User }):
})
checkResponseStatus(response, 'Failed while creating user')

const json = await response.json()
checkOCJsonStatus(json, 'Failed while creating user')
const jsonResponse = await response.json()
checkOCJsonStatus(jsonResponse, 'Failed while creating user')

const usersEnvironment = new UsersEnvironment()
usersEnvironment.storeCreatedUser({ user: { ...user, uuid: jsonResponse.id } })
}

;[
Expand Down Expand Up @@ -55,7 +59,10 @@ export const deleteUser = async ({ user, admin }: { user: User; admin: User }):
path: join('ocs', 'v2.php', 'cloud', 'users', encodeURIComponent(user.id)),
user: admin
})

try {
const usersEnvironment = new UsersEnvironment()
usersEnvironment.removeCreatedUser({ key: user.id })
} catch (e) {}
return user
}

Expand Down
56 changes: 48 additions & 8 deletions tests/e2e/support/environment/userManagement.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,69 @@
import { Group, User } from '../types'
import { dummyUserStore, dummyGroupStore } from '../store'
import { createdUserStore } from '../store/user'

export class UsersEnvironment {
getUser({ key }: { key: string }): User {
const uniqueKey = key.toLowerCase()
const userKey = key.toLowerCase()

if (!dummyUserStore.has(uniqueKey)) {
throw new Error(`user with key '${uniqueKey}' not found`)
if (!dummyUserStore.has(userKey)) {
throw new Error(`user with key '${userKey}' not found`)
}

return dummyUserStore.get(uniqueKey)
return dummyUserStore.get(userKey)
}

createUser({ key, user }: { key: string; user: User }): User {
const uniqueKey = key.toLowerCase()
const userKey = key.toLowerCase()

if (dummyUserStore.has(uniqueKey)) {
throw new Error(`user with key '${uniqueKey}' already exists`)
if (dummyUserStore.has(userKey)) {
throw new Error(`user with key '${userKey}' already exists`)
}

dummyUserStore.set(userKey, user)

return user
}

storeCreatedUser({ user }: { user: User }): User {
if (createdUserStore.has(user.id)) {
throw new Error(`user '${user.id}' already exists`)
}
createdUserStore.set(user.id, user)

return user
}

getCreatedUser({ key }: { key: string }): User {
const userKey = key.toLowerCase()
if (!createdUserStore.has(userKey)) {
throw new Error(`user with key '${userKey}' not found`)
}

dummyUserStore.set(uniqueKey, user)
return createdUserStore.get(userKey)
}

updateCreatedUser({ key, user }: { key: string; user: User }): User {
const userKey = key.toLowerCase()
if (!createdUserStore.has(userKey)) {
throw new Error(`user '${userKey}' not found`)
}
createdUserStore.delete(userKey)
createdUserStore.set(user.id, user)

return user
}

removeCreatedUser({ key }: { key: string }): boolean {
const userKey = key.toLowerCase()

if (!createdUserStore.has(userKey)) {
throw new Error(`user '${userKey}' not found`)
}

return createdUserStore.delete(userKey)
}

getGroup({ key }: { key: string }): Group {
const uniqueKey = key.toLowerCase()

Expand Down
18 changes: 15 additions & 3 deletions tests/e2e/support/objects/app-admin-settings/users/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,39 @@ const displayNameInput = '#create-user-input-display-name'
const emailInput = '#create-user-input-email'
const passwordInput = '#create-user-input-password'

export interface UserInterface {
displayName: string
givenName: string
id: string
mail: string
onPremisesSamAccountName: string
surname: string
userType: string
}

export const createUser = async (args: {
page: Page
name: string
displayname: string
email: string
password: string
}): Promise<void> => {
}): Promise<UserInterface> => {
const { page, name, displayname, email, password } = args
await page.locator(createUserButton).click()
await page.locator(userNameInput).fill(name)
await page.locator(displayNameInput).fill(displayname)
await page.locator(emailInput).fill(email)
await page.locator(passwordInput).fill(password)

await Promise.all([
const [response] = await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().endsWith('users') && resp.status() === 200 && resp.request().method() === 'POST'
),
await page.locator(actionConfirmButton).click()
page.locator(actionConfirmButton).click()
])

return await response.json()
}
export const changeAccountEnabled = async (args: {
page: Page
Expand Down
25 changes: 23 additions & 2 deletions tests/e2e/support/objects/app-admin-settings/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Users {
this.#page = page
}
getUUID({ key }: { key: string }): string {
return this.#usersEnvironment.getUser({ key }).uuid
return this.#usersEnvironment.getCreatedUser({ key }).uuid
}

async allowLogin({ key, action }: { key: string; action: string }): Promise<void> {
Expand Down Expand Up @@ -104,9 +104,19 @@ export class Users {
action: string
}): Promise<void> {
const uuid = this.getUUID({ key })

await openEditPanel({ page: this.#page, uuid, action })
await changeUser({ uuid, attribute: attribute, value: value, page: this.#page })
const currentUser = this.#usersEnvironment.getCreatedUser({ key })

if (attribute !== 'role') {
this.#usersEnvironment.updateCreatedUser({
key: key,
user: { ...currentUser, [attribute === 'userName' ? 'id' : attribute]: value }
})
}
}

async addToGroups({
key,
groups,
Expand Down Expand Up @@ -139,6 +149,7 @@ export class Users {
async deleteUserUsingBatchAction({ userIds }: { userIds: string[] }): Promise<void> {
await deleteUserUsingBatchAction({ page: this.#page, userIds })
}

async createUser({
name,
displayname,
Expand All @@ -150,7 +161,17 @@ export class Users {
email: string
password: string
}): Promise<void> {
await createUser({ page: this.#page, name, displayname, email, password })
const response = await createUser({ page: this.#page, name, displayname, email, password })

this.#usersEnvironment.storeCreatedUser({
user: {
id: response.onPremisesSamAccountName,
displayName: response.displayName,
password: password,
email: response.mail,
uuid: response.id
}
})
}

async openEditPanel({ key, action }: { key: string; action: string }): Promise<void> {
Expand Down

0 comments on commit 548ff61

Please sign in to comment.