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
143 changes: 143 additions & 0 deletions tests/e2e-playwright/specs/user-settings/languageChange.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { expect, test } from '@playwright/test'
import { config } from '../../../e2e/config.js'
import {
ActorsEnvironment,
UsersEnvironment,
LinksEnvironment,
FilesEnvironment
} from '../../../e2e/support/environment/index.js'
import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken.js'
import * as api from '../../steps/api/api.js'
import * as ui from '../../steps/ui/index'

test.describe('language settings', { tag: '@predefined-users' }, () => {
let actorsEnvironment
const usersEnvironment = new UsersEnvironment()
const linksEnvironment = new LinksEnvironment()
const filesEnvironment = new FilesEnvironment()

test.beforeEach(async ({ browser }) => {
actorsEnvironment = new ActorsEnvironment({
context: {
acceptDownloads: config.acceptDownloads,
reportDir: config.reportDir,
tracingReportDir: config.tracingReportDir,
reportHar: config.reportHar,
reportTracing: config.reportTracing,
reportVideo: config.reportVideo,
failOnUncaughtConsoleError: config.failOnUncaughtConsoleError
},
browser: browser
})

await setAccessAndRefreshToken(usersEnvironment)
// Given "Admin" creates following users using API
await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' })
await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Brian' })

// Given "Alice" logs in
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' })
})

test.afterEach(async () => {
// clean up users
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' })
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Brian' })
})

test('system language change', async () => {
// And "Alice" creates the following folder in personal space using API
// | name |
// | check_message |
await api.userHasCreatedFolder({
usersEnvironment,
stepUser: 'Alice',
folderName: 'check_message'
})
// And "Alice" shares the following resource using API
// | resource | recipient | type | role | resourceType |
// | check_message | Brian | user | Can edit | folder |
await api.userHasSharedResource({
usersEnvironment,
stepUser: 'Alice',
resource: 'check_message',
recipient: 'Brian',
type: 'user',
role: 'Can edit',
resourceType: 'folder'
})
// And "Alice" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
// And "Brian" logs in
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Brian' })
// When "Brian" opens the user menu
await ui.openAccountPage({ actorsEnvironment, stepUser: 'Brian' })
// And "Brian" changes the language to "Deutsch - German"
await ui.changeLanguage({ actorsEnvironment, stepUser: 'Brian', language: 'Deutsch - German' })
// Then "Brian" should see the following account page title "Mein Konto"
const actualTitle = await ui.getAccountPageTitle({ actorsEnvironment, stepUser: 'Brian' })
expect(actualTitle).toEqual('Mein Konto')
// And "Brian" should see the following notifications
// | Alice hat check_message mit Ihnen geteilt |
const messages = await ui.getNotificationMessages({ actorsEnvironment, stepUser: 'Brian' })
expect(messages).toContain('Alice Hansen hat check_message mit Ihnen geteilt')
// And "Brian" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Brian' })
})

test('anonymous user language change', async () => {
// And "Alice" creates the following folder in personal space using API
// | name |
// | folderPublic |
await api.userHasCreatedFolder({
usersEnvironment,
stepUser: 'Alice',
folderName: 'folderPublic'
})
// And "Alice" uploads the following local file into personal space using API
// | localFile | to |
// | filesForUpload/lorem.txt | lorem.txt |
await api.uploadFileInPersonalSpace({
usersEnvironment,
filesEnvironment,
stepUser: 'Alice',
resource: 'lorem.txt',
destination: 'lorem.txt'
})
// And "Alice" creates a public link of following resource using API
// | resource | password |
// | folderPublic | %public% |
await api.userHasCreatedPublicLinkOfResource({
usersEnvironment,
stepUser: 'Alice',
resource: 'lorem.txt',
password: '%public%'
})
// And "Alice" logs out
await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
// When "Anonymous" opens the public link "Unnamed link"
await ui.anonymousUserOpensPublicLink({
actorsEnvironment,
linksEnvironment,
stepUser: 'Anonymous',
name: 'Unnamed link'
})
// And "Anonymous" unlocks the public link with password "%public%"
await ui.anonymousUserUnlocksPublicLink({
actorsEnvironment,
password: '%public%',
stepUser: 'Anonymous'
})
// And "Anonymous" opens the user menu
await ui.openAccountPage({ actorsEnvironment, stepUser: 'Anonymous' })
// And "Anonymous" changes the language to "Deutsch - German"
await ui.changeLanguage({
actorsEnvironment,
stepUser: 'Anonymous',
language: 'Deutsch - German'
})
// Then "Anonymous" should see the following account page title "Mein Konto"
const actualTitle = await ui.getAccountPageTitle({ actorsEnvironment, stepUser: 'Anonymous' })
expect(actualTitle).toEqual('Mein Konto')
})
})
32 changes: 30 additions & 2 deletions tests/e2e-playwright/steps/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { config } from '../../../e2e/config.js'
import { UsersEnvironment, SpacesEnvironment } from '../../../e2e/support/environment'
import {
FilesEnvironment,
UsersEnvironment,
SpacesEnvironment
} from '../../../e2e/support/environment'
import { api } from '../../../e2e/support'
import { ResourceType } from '../../../e2e/support/api/share/share'
import { Space } from '../../../e2e/support/types'
import fs from 'fs'

export async function userHasBeenCreated({
usersEnvironment,
Expand Down Expand Up @@ -123,7 +128,7 @@ export async function userHasCreatedPublicLinkOfResource({
usersEnvironment: UsersEnvironment
stepUser: string
resource: string
role: string
role?: string
name?: string
password?: string
space?: 'Personal'
Expand Down Expand Up @@ -185,3 +190,26 @@ export async function userHasCreatedProjectSpace({
space: { name: name, id: spaceId }
})
}

export async function uploadFileInPersonalSpace({
usersEnvironment,
stepUser,
filesEnvironment,
resource,
destination
}: {
usersEnvironment: UsersEnvironment
stepUser: string
filesEnvironment: FilesEnvironment
resource: string
destination: string
}) {
const user = usersEnvironment.getUser({ key: stepUser })
const fileInfo = filesEnvironment.getFile({ name: resource })
const content = fs.readFileSync(fileInfo.path)
await api.dav.uploadFileInPersonalSpace({
user,
pathToFile: destination,
content
})
}
41 changes: 41 additions & 0 deletions tests/e2e-playwright/steps/ui/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { objects } from '../../../e2e/support'
import { ActorsEnvironment } from '../../../e2e/support/environment'

export async function openAccountPage({
actorsEnvironment,
stepUser
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
await accountObject.openAccountPage()
}

export async function changeLanguage({
actorsEnvironment,
stepUser,
language
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
language: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
const isAnonymousUser = stepUser === 'Anonymous'
await accountObject.changeLanguage(language, isAnonymousUser)
}

export async function getAccountPageTitle({
actorsEnvironment,
stepUser
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
}): Promise<string> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const accountObject = new objects.account.Account({ page })
return await accountObject.getTitle()
}
12 changes: 12 additions & 0 deletions tests/e2e-playwright/steps/ui/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ export async function openApplication({
const applicationObject = new objects.runtime.Application({ page })
await applicationObject.open({ name })
}

export async function getNotificationMessages({
actorsEnvironment,
stepUser
}: {
actorsEnvironment: ActorsEnvironment
stepUser: string
}): Promise<string[]> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const application = new objects.runtime.Application({ page })
return await application.getNotificationMessages()
}
1 change: 1 addition & 0 deletions tests/e2e-playwright/steps/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './resources'
export * from './session'
export * from './spaces'
export * from './application'
export * from './account'
35 changes: 35 additions & 0 deletions tests/e2e-playwright/steps/ui/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,38 @@ export async function createPublicLink({
const publicObject = new objects.applicationFiles.Link({ page })
await publicObject.create({ resource, password: substitute(password) })
}

export async function anonymousUserOpensPublicLink({
actorsEnvironment,
linksEnvironment,
stepUser,
name
}: {
actorsEnvironment: ActorsEnvironment
linksEnvironment: LinksEnvironment
stepUser: string
name: string
}): Promise<void> {
const { page } = await actorsEnvironment.createActor({
key: stepUser,
namespace: actorsEnvironment.generateNamespace(`${stepUser} user language change`, 'Anonymous')
})

const { url } = linksEnvironment.getLink({ name })
const pageObject = new objects.applicationFiles.page.Public({ page })
await pageObject.open({ url })
}

export async function anonymousUserUnlocksPublicLink({
actorsEnvironment,
stepUser,
password
}: {
actorsEnvironment: ActorsEnvironment
password: string
stepUser: string
}): Promise<void> {
const { page } = actorsEnvironment.getActor({ key: stepUser })
const pageObject = new objects.applicationFiles.page.Public({ page })
await pageObject.authenticate({ password: substitute(password) })
}
47 changes: 0 additions & 47 deletions tests/e2e/cucumber/features/user-settings/languageChange.feature

This file was deleted.

5 changes: 4 additions & 1 deletion tests/e2e/support/objects/a11y/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ export const selectors = {
filesSpaceTableCheckbox: '#files-space-table .oc-checkbox',
uploadMenuDropdown: '#upload-menu-drop',
appSidebar: '#app-sidebar',
accountInfoContainer: '#account-info-container',
account: '#account',
removeUserModal: '.oc-modal.oc-modal-danger',
appSwitcherDropdown: '#app-switcher-dropdown',
tippyBox: '.tippy-box',
textEditor: '#text-editor-component',
topBar: '#oc-topbar',
displayOptions: '#files-app-bar-controls-right',
ocCard: '.oc-card'
ocCard: '.oc-card',
body: 'body'
}

const a11yRuleTags = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice']
Expand Down
Loading