Skip to content

Commit f62fe9a

Browse files
committed
test: convert tiles.feature test to playwright
1 parent d57f9e1 commit f62fe9a

File tree

9 files changed

+194
-29
lines changed

9 files changed

+194
-29
lines changed

.drone.star

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ def e2eTestsOnPlaywright(ctx):
579579
"BASE_URL_OCIS": "ocis:9200",
580580
"PLAYWRIGHT_BROWSERS_PATH": ".playwright",
581581
"TESTS_RUNNER": "playwright",
582+
"SKIP_A11Y_TESTS": True,
582583
}
583584

584585
steps += restoreBuildArtifactCache(ctx, "pnpm", ".pnpm-store") + \
@@ -695,7 +696,7 @@ def e2eTests(ctx):
695696
"PLAYWRIGHT_BROWSERS_PATH": ".playwright",
696697
"BROWSER": "chromium",
697698
"FEDERATED_BASE_URL_OCIS": "federation-ocis:9200",
698-
"SKIP_A11Y_TESTS": params["skipA11y"],
699+
"SKIP_A11Y_TESTS": True,
699700
}
700701

701702
if "suites" in matrix:

tests/e2e-playwright/helpers/setAccessAndRefreshToken.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { UsersEnvironment } from '../../e2e/support/environment'
44

55
export async function setAccessAndRefreshToken(usersEnvironment: UsersEnvironment) {
66
if (!config.basicAuth && !config.predefinedUsers) {
7-
let user = usersEnvironment.getUser({ key: config.adminUsername })
7+
const user = usersEnvironment.getUser({ key: config.adminUsername })
88
await api.token.setAccessAndRefreshToken(user)
99
}
1010
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { test } from '@playwright/test'
2+
import { config } from './../../../e2e/config.js'
3+
import { ActorsEnvironment, UsersEnvironment } from '../../../e2e/support/environment'
4+
import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken'
5+
import * as api from '../../steps/api/api'
6+
import * as ui from '../../steps/ui/index'
7+
8+
test.describe('user-settings', () => {
9+
let actorsEnvironment: ActorsEnvironment
10+
const usersEnvironment = new UsersEnvironment()
11+
12+
test.beforeEach(async ({ browser }) => {
13+
actorsEnvironment = new ActorsEnvironment({
14+
context: {
15+
acceptDownloads: config.acceptDownloads,
16+
reportDir: config.reportDir,
17+
tracingReportDir: config.tracingReportDir,
18+
reportHar: config.reportHar,
19+
reportTracing: config.reportTracing,
20+
reportVideo: config.reportVideo,
21+
failOnUncaughtConsoleError: config.failOnUncaughtConsoleError
22+
},
23+
browser: browser
24+
})
25+
26+
await setAccessAndRefreshToken(usersEnvironment)
27+
28+
// Given "Admin" creates following user using API
29+
await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' })
30+
// And "Alice" logs in
31+
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' })
32+
// And "Alice" creates the following resources
33+
await api.userHasCreatedFolder({
34+
usersEnvironment,
35+
stepUser: 'Alice',
36+
folderName: 'tile_folder'
37+
})
38+
})
39+
40+
test.afterEach(async () => {
41+
await api.deleteUser({ usersEnvironment, stepUser: 'Admin', targetUser: 'Alice' })
42+
})
43+
44+
test('Users can navigate web via tiles', async () => {
45+
// When "Alice" switches to the tiles-view
46+
await ui.switchToTilesViewMode({
47+
actorsEnvironment,
48+
stepUser: 'Alice'
49+
})
50+
// Then "Alice" sees the resources displayed as tiles
51+
await ui.expectThatResourcesAreTiles({
52+
actorsEnvironment,
53+
stepUser: 'Alice'
54+
})
55+
// And "Alice" opens folder "tile_folder"
56+
await ui.openFolder({
57+
actorsEnvironment,
58+
stepUser: 'Alice',
59+
resource: 'tile_folder'
60+
})
61+
// And "Alice" creates the following resources
62+
await ui.createFolder({
63+
actorsEnvironment,
64+
stepUser: 'Alice',
65+
resource: 'tile_folder/tile_folder2'
66+
})
67+
// And "Alice" sees the resources displayed as tiles
68+
await ui.expectThatResourcesAreTiles({
69+
actorsEnvironment,
70+
stepUser: 'Alice'
71+
})
72+
// And "Alice" logs out
73+
await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' })
74+
})
75+
})

tests/e2e-playwright/steps/ui/resources.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { objects } from '../../../e2e/support'
22
import { ActorsEnvironment, FilesEnvironment } from '../../../e2e/support/environment'
3+
import { createResourceTypes } from '../../../e2e/support/objects/app-files/resource/actions'
34

45
export async function uploadResource({
56
actorsEnvironment,
@@ -59,3 +60,64 @@ export async function createDir({
5960
type: 'folder'
6061
})
6162
}
63+
64+
export async function switchToTilesViewMode({
65+
actorsEnvironment,
66+
stepUser
67+
}: {
68+
actorsEnvironment: ActorsEnvironment
69+
stepUser: string
70+
}): Promise<void> {
71+
const { page } = actorsEnvironment.getActor({ key: stepUser })
72+
const resourceObject = new objects.applicationFiles.Resource({ page })
73+
await resourceObject.switchToTilesViewMode()
74+
}
75+
76+
export async function expectThatResourcesAreTiles({
77+
actorsEnvironment,
78+
stepUser
79+
}: {
80+
actorsEnvironment: ActorsEnvironment
81+
stepUser: string
82+
}): Promise<void> {
83+
const { page } = actorsEnvironment.getActor({ key: stepUser })
84+
const resourceObject = new objects.applicationFiles.Resource({ page })
85+
await resourceObject.expectThatResourcesAreTiles()
86+
}
87+
88+
export async function openFolder({
89+
actorsEnvironment,
90+
stepUser,
91+
resource
92+
}: {
93+
actorsEnvironment: ActorsEnvironment
94+
stepUser: string
95+
resource: string
96+
}): Promise<void> {
97+
const { page } = actorsEnvironment.getActor({ key: stepUser })
98+
const resourceObject = new objects.applicationFiles.Resource({ page })
99+
await resourceObject.openFolder(resource)
100+
}
101+
102+
export async function createFolder({
103+
actorsEnvironment,
104+
stepUser,
105+
resource,
106+
content,
107+
password
108+
}: {
109+
actorsEnvironment: ActorsEnvironment
110+
stepUser: string
111+
resource: string
112+
content?: string
113+
password?: string
114+
}): Promise<void> {
115+
const { page } = actorsEnvironment.getActor({ key: stepUser })
116+
const resourceObject = new objects.applicationFiles.Resource({ page })
117+
await resourceObject.create({
118+
name: resource,
119+
type: 'folder' as createResourceTypes,
120+
content: content,
121+
password: password
122+
})
123+
}

tests/e2e/cucumber/features/user-settings/tiles.feature

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/e2e/support/objects/a11y/actions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ export const selectors = {
2828
appbarBatchActions: '#oc-appbar-batch-actions',
2929
filesSpaceTableCheckbox: '#files-space-table .oc-checkbox',
3030
uploadMenuDropdown: '#upload-menu-drop',
31-
appSidebar: '#app-sidebar'
31+
appSidebar: '#app-sidebar',
32+
tippyBox: '.tippy-box',
33+
textEditor: '#text-editor-component',
34+
topBar: '#oc-topbar',
35+
displayOptions: '#files-app-bar-controls-right',
36+
ocCard: '.oc-card'
3237
}
3338

3439
const a11yRuleTags = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice']

tests/e2e/support/objects/app-files/page/public.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { File } from '../../../types'
33
import util from 'util'
44
import path from 'path'
55
import * as po from '../resource/actions'
6-
import { objects } from '../../..'
76

87
const passwordInput = 'input[type="password"]'
98
const fileUploadInput = '//input[@id="files-file-upload-input"]'
@@ -21,8 +20,6 @@ export class Public {
2120

2221
async open({ url }: { url: string }): Promise<void> {
2322
await this.#page.goto(url)
24-
const a11yObject = new objects.a11y.Accessibility({ page: this.#page })
25-
await a11yObject.getSevereAccessibilityViolations('body')
2623
}
2724

2825
async authenticate({

tests/e2e/support/objects/app-files/resource/actions.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,14 @@ export const createPasswordProtectedFolder = async ({
350350
password: string
351351
}): Promise<void> => {
352352
password = substitute(password)
353+
const a11yObject = new objects.a11y.Accessibility({ page })
354+
const violations = await a11yObject.getSevereAccessibilityViolations(
355+
a11yObject.getSelectors().ocModal
356+
)
357+
expect(
358+
violations,
359+
`Found ${violations.length} severe accessibility violations in create new folder modal`
360+
).toHaveLength(0)
353361
await page.locator(passwordProtectedFolderButton).click()
354362
await page.locator(passwordProtectedFolderNameInput).fill(resource)
355363
await page.locator(passwordProtectedFolderPasswordInput).fill(password)
@@ -379,6 +387,14 @@ export const createPasswordProtectedFolder = async ({
379387
export const createNewFileOrFolder = async (args: createResourceArgs): Promise<void> => {
380388
const { page, name, type, content, password } = args
381389
await page.locator(addNewResourceButton).click()
390+
const a11yObject = new objects.a11y.Accessibility({ page })
391+
const violations = await a11yObject.getSevereAccessibilityViolations(
392+
a11yObject.getSelectors().tippyBox
393+
)
394+
expect(
395+
violations,
396+
`Found ${violations.length} severe accessibility violations in create new tippy box`
397+
).toHaveLength(0)
382398
switch (type) {
383399
case 'folder': {
384400
await createNewFolder({ page, resource: name })
@@ -440,6 +456,14 @@ const createDocumentFile = async (
440456
`The document of type ${type} did not appear in the webUI for ${editorToOpen}. Possible reason could be the app provider service for ${editorToOpen} was not ready yet.`
441457
)
442458
}
459+
const a11yObject = new objects.a11y.Accessibility({ page })
460+
const violations = await a11yObject.getSevereAccessibilityViolations(
461+
a11yObject.getSelectors().ocModal
462+
)
463+
expect(
464+
violations,
465+
`Found ${violations.length} severe accessibility violations in create new folder modal`
466+
).toHaveLength(0)
443467
await page.locator(util.format(createNewOfficeDocumentFileButton, type)).click()
444468
await page.locator(resourceNameInput).clear()
445469
await page.locator(resourceNameInput).fill(name)
@@ -569,6 +593,19 @@ export const editTextDocument = async ({
569593
const inputLocator =
570594
isMarkdownMode === 'true' ? textEditorMarkdownInput : textEditorPlainTextInput
571595

596+
const a11yObject = new objects.a11y.Accessibility({ page })
597+
let violations = await a11yObject.getSevereAccessibilityViolations(
598+
a11yObject.getSelectors().textEditor
599+
)
600+
violations = [
601+
...violations,
602+
...(await a11yObject.getSevereAccessibilityViolations(a11yObject.getSelectors().topBar))
603+
]
604+
expect(
605+
violations,
606+
`Found ${violations.length} severe accessibility violations in create new folder modal`
607+
).toHaveLength(0)
608+
572609
await page.locator(inputLocator).fill(content)
573610
await Promise.all([
574611
page.waitForResponse((resp) => resp.status() === 204 && resp.request().method() === 'PUT'),
@@ -1656,11 +1693,21 @@ export interface switchViewModeArgs {
16561693

16571694
export const clickViewModeToggle = async (args: switchViewModeArgs): Promise<void> => {
16581695
const { page, target } = args
1696+
const a11yObject = new objects.a11y.Accessibility({ page })
1697+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
1698+
a11yObject.getSelectors().displayOptions
1699+
)
1700+
expect(a11yViolations).toMatchObject([])
16591701
await page.locator(`.viewmode-switch-buttons .${target}`).click()
16601702
}
16611703

16621704
export const expectThatResourcesAreTiles = async (args: { page: Page }): Promise<void> => {
16631705
const { page } = args
1706+
const a11yObject = new objects.a11y.Accessibility({ page })
1707+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
1708+
a11yObject.getSelectors().tilesView
1709+
)
1710+
expect(a11yViolations).toMatchObject([])
16641711
const tiles = page.locator(resourcesAsTiles)
16651712
await expect(tiles).toBeVisible()
16661713
}

tests/e2e/support/objects/app-files/resource/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class Resource {
228228
}
229229

230230
async getAllFiles(): Promise<string[]> {
231-
return po.getAllFiles(this.#page)
231+
return await po.getAllFiles(this.#page)
232232
}
233233

234234
async editResource(args: Omit<po.editResourcesArgs, 'page'>): Promise<void> {

0 commit comments

Comments
 (0)