Skip to content
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
2 changes: 1 addition & 1 deletion .woodpecker.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OpenCloud to use in pipelines
OPENCLOUD_COMMITID=13049b7b9dcf33a5e0d306f36581bc2daf99f1ea
OPENCLOUD_COMMITID=db7d0535f61e587c78a085dc713445d8d40e1399
OPENCLOUD_BRANCH=main
20 changes: 20 additions & 0 deletions tests/e2e/cucumber/features/user-settings/profilePhoto.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: profile photo
As a user, I want to provide my avatar to make my actions more visible

Scenario: profile photo
Given "Admin" creates following user using API
| id |
| Alice |
And "Alice" logs in
And "Alice" opens the user menu
And "Alice" should not have a profile picture

When "Alice" uploads the profile image "testavatar.jpeg"
Then "Alice" should have a profile picture

When "Alice" changes the profile image "testavatar.png"
Then "Alice" should have a profile picture

When "Alice" deletes the profile image
Then "Alice" should not have a profile picture
And "Alice" logs out
34 changes: 34 additions & 0 deletions tests/e2e/cucumber/steps/ui/accountMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,37 @@ Then(
expect(pageTitle).toEqual(title)
}
)

When(
'{string} uploads/changes the profile image {string}',
async function (this: World, stepUser: string, profileImage: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
const profileImagePath = this.filesEnvironment.getFile({ name: profileImage }).path
await accountObject.uploadProfileImage({ path: profileImagePath })
}
)

When(
'{string} deletes the profile image',
async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
await accountObject.deleteProfileImage()
}
)

Then(
/^"([^"]+)" should( not)? have a profile picture$/,
async function (this: World, stepUser: string, not: string | undefined): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
const profilePicture = await accountObject.getProfilePicture()

if (not) {
await expect(profilePicture).toHaveCount(0)
} else {
await expect(profilePicture).toHaveAttribute('src', /.+/)
}
}
)
34 changes: 33 additions & 1 deletion tests/e2e/support/objects/account/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page, expect } from '@playwright/test'
import { Locator, Page, expect } from '@playwright/test'
import util from 'util'
import { config } from '../../../config'

Expand All @@ -12,6 +12,10 @@ const languageInput = '[data-testid="language"] .vs__search'
const languageValueDropDown = `.vs__dropdown-menu :text-is("%s")`
const languageValue = '[data-testid="language"] .vs__selected'
const accountPageTitle = '#account-page-title'
const confirmButton = '.oc-modal-body-actions-confirm'
const topbarProfileAvatarImg = '.oc-topbar-personal-avatar .avatarImg'
const accountProfileAvatarImg = '.avatar-upload .oc-avatar .avatarImg'
const removeAccountProfileAvatarButton = 'button:has-text("Remove")'

export const getQuotaValue = async (args: { page: Page }): Promise<string> => {
const { page } = args
Expand Down Expand Up @@ -109,3 +113,31 @@ export const getTitle = (args: { page: Page }): Promise<string> => {
const { page } = args
return page.locator(accountPageTitle).textContent()
}

export const uploadProfileImage = async (path: string, page: Page): Promise<void> => {
await page.locator('input[type="file"]').setInputFiles(path)

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().endsWith('/me/photo/$value') &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
),
page.locator(confirmButton).click()
])

await expect(page.locator(accountProfileAvatarImg)).toHaveAttribute('src')
await expect(page.locator(topbarProfileAvatarImg)).toHaveAttribute('src')
}

export const deleteProfilePicture = async (args: { page: Page }): Promise<void> => {
const { page } = args
await page.locator(removeAccountProfileAvatarButton).click()
await page.locator(confirmButton).click()
}

export const getProfilePicture = async (args: { page: Page }): Promise<Locator> => {
const { page } = args
return await page.locator(topbarProfileAvatarImg)
}
14 changes: 13 additions & 1 deletion tests/e2e/support/objects/account/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from '@playwright/test'
import { Locator, Page } from '@playwright/test'
import * as po from './actions'

export class Account {
Expand Down Expand Up @@ -35,4 +35,16 @@ export class Account {
getTitle(): Promise<string> {
return po.getTitle({ page: this.#page })
}

async uploadProfileImage({ path }: { path: string }): Promise<void> {
await po.uploadProfileImage(path, this.#page)
}

async deleteProfileImage(): Promise<void> {
await po.deleteProfilePicture({ page: this.#page })
}

async getProfilePicture(): Promise<Locator> {
return await po.getProfilePicture({ page: this.#page })
}
}