Skip to content

Commit 791dd6b

Browse files
committed
test: convert tiles.feature test to playwright
1 parent 7637cd5 commit 791dd6b

File tree

6 files changed

+184
-28
lines changed

6 files changed

+184
-28
lines changed

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('tiles view', () => {
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.shouldSeeResourcesAsTiles({
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.createDir({
63+
actorsEnvironment,
64+
stepUser: 'Alice',
65+
resource: 'tile_folder/tile_folder2'
66+
})
67+
// And "Alice" sees the resources displayed as tiles
68+
await ui.shouldSeeResourcesAsTiles({
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: 49 additions & 4 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,
@@ -46,16 +47,60 @@ export async function isAbleToEditFileOrFolder({
4647
export async function createDir({
4748
actorsEnvironment,
4849
stepUser,
49-
directoryName
50+
resource,
51+
content,
52+
password
5053
}: {
5154
actorsEnvironment: ActorsEnvironment
5255
stepUser: string
53-
directoryName: string
56+
resource: string
57+
content?: string
58+
password?: string
5459
}): Promise<void> {
5560
const { page } = actorsEnvironment.getActor({ key: stepUser })
5661
const resourceObject = new objects.applicationFiles.Resource({ page })
5762
await resourceObject.create({
58-
name: directoryName,
59-
type: 'folder'
63+
name: resource,
64+
type: 'folder' as createResourceTypes,
65+
content: content,
66+
password: password
6067
})
6168
}
69+
70+
export async function switchToTilesViewMode({
71+
actorsEnvironment,
72+
stepUser
73+
}: {
74+
actorsEnvironment: ActorsEnvironment
75+
stepUser: string
76+
}): Promise<void> {
77+
const { page } = actorsEnvironment.getActor({ key: stepUser })
78+
const resourceObject = new objects.applicationFiles.Resource({ page })
79+
await resourceObject.switchToTilesViewMode()
80+
}
81+
82+
export async function shouldSeeResourcesAsTiles({
83+
actorsEnvironment,
84+
stepUser
85+
}: {
86+
actorsEnvironment: ActorsEnvironment
87+
stepUser: string
88+
}): Promise<void> {
89+
const { page } = actorsEnvironment.getActor({ key: stepUser })
90+
const resourceObject = new objects.applicationFiles.Resource({ page })
91+
await resourceObject.expectThatResourcesAreTiles()
92+
}
93+
94+
export async function openFolder({
95+
actorsEnvironment,
96+
stepUser,
97+
resource
98+
}: {
99+
actorsEnvironment: ActorsEnvironment
100+
stepUser: string
101+
resource: string
102+
}): Promise<void> {
103+
const { page } = actorsEnvironment.getActor({ key: stepUser })
104+
const resourceObject = new objects.applicationFiles.Resource({ page })
105+
await resourceObject.openFolder(resource)
106+
}

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/resource/actions.ts

Lines changed: 53 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 text editor`
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,27 @@ 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(
1701+
a11yViolations,
1702+
`Found ${a11yViolations.length} severe accessibility violations in file controls modal`
1703+
).toHaveLength(0)
16591704
await page.locator(`.viewmode-switch-buttons .${target}`).click()
16601705
}
16611706

16621707
export const expectThatResourcesAreTiles = async (args: { page: Page }): Promise<void> => {
16631708
const { page } = args
1709+
const a11yObject = new objects.a11y.Accessibility({ page })
1710+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
1711+
a11yObject.getSelectors().tilesView
1712+
)
1713+
expect(
1714+
a11yViolations,
1715+
`Found ${a11yViolations.length} severe accessibility violations in file tile view`
1716+
).toHaveLength(0)
16641717
const tiles = page.locator(resourcesAsTiles)
16651718
await expect(tiles).toBeVisible()
16661719
}

0 commit comments

Comments
 (0)