Skip to content

Commit 6d32d13

Browse files
committed
test: convert discovery.feature test to playwright
1 parent e0255df commit 6d32d13

8 files changed

Lines changed: 196 additions & 2159 deletions

File tree

a11y-report-cucumber.json

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

test-results/.last-run.json

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { test, expect } from '@playwright/test'
2+
import { config } from '../../../e2e/config.js'
3+
import { ActorsEnvironment, UsersEnvironment } from '../../../e2e/support/environment/index.js'
4+
import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken.js'
5+
import * as ui from '../../steps/ui/index'
6+
7+
test.describe('details', { tag: '@predefined-users' }, () => {
8+
let actorsEnvironment: ActorsEnvironment
9+
const usersEnvironment = new UsersEnvironment()
10+
11+
test.beforeEach(async ({ browser }) => {
12+
actorsEnvironment = new ActorsEnvironment({
13+
context: {
14+
acceptDownloads: config.acceptDownloads,
15+
reportDir: config.reportDir,
16+
tracingReportDir: config.tracingReportDir,
17+
reportHar: config.reportHar,
18+
reportTracing: config.reportTracing,
19+
reportVideo: config.reportVideo,
20+
failOnUncaughtConsoleError: config.failOnUncaughtConsoleError
21+
},
22+
browser: browser
23+
})
24+
25+
await setAccessAndRefreshToken(usersEnvironment)
26+
})
27+
28+
test.afterEach(async () => {})
29+
30+
test('apps can be searched and downloaded', async () => {
31+
// When "Alice" logs in
32+
await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Admin' })
33+
34+
// And "Admin" navigates to the app store
35+
await ui.openAppStore({ actorsEnvironment, stepUser: 'Admin' })
36+
37+
// Then "Admin" should see the app store
38+
await ui.waitForAppStoreIsVisible({ actorsEnvironment, stepUser: 'Admin' })
39+
40+
// And "Admin" should see the following apps
41+
// | app |
42+
// | Draw.io |
43+
// | JSON Viewer |
44+
// | Unzip |
45+
let apps = await ui.getAppsList({ actorsEnvironment, stepUser: 'Admin' })
46+
expect(apps).toContain('Draw.io')
47+
expect(apps).toContain('JSON Viewer')
48+
expect(apps).toContain('Unzip')
49+
50+
// When "Admin" enters the search term "draw"
51+
await ui.setSearchTerm({ actorsEnvironment, stepUser: 'Admin', searchTerm: 'draw' })
52+
53+
// Then "Admin" should see the following apps
54+
// | app |
55+
// | Draw.io |
56+
apps = []
57+
apps = await ui.getAppsList({ actorsEnvironment, stepUser: 'Admin' })
58+
expect(apps).toContain('Draw.io')
59+
60+
// When "Admin" clicks on the tag "viewer" of the app "Draw.io"
61+
await ui.selectAppTag({ actorsEnvironment, stepUser: 'Admin', tag: 'viewer', app: 'Draw.io' })
62+
63+
// Then "Admin" should see the following apps
64+
// | app |
65+
// | JSON Viewer |
66+
// | Draw.io |
67+
apps = []
68+
apps = await ui.getAppsList({ actorsEnvironment, stepUser: 'Admin' })
69+
expect(apps).toContain('Draw.io')
70+
expect(apps).toContain('JSON Viewer')
71+
72+
// When "Admin" clicks on the app "JSON Viewer"
73+
await ui.selectApp({ actorsEnvironment, stepUser: 'Admin', app: 'JSON Viewer' })
74+
75+
// Then "Admin" should see the app details of "JSON Viewer"
76+
await ui.waitForAppDetailsIsVisible({
77+
actorsEnvironment,
78+
stepUser: 'Admin',
79+
app: 'JSON Viewer'
80+
})
81+
82+
// When "Admin" clicks on the tag "viewer"
83+
await ui.selectTag({ actorsEnvironment, stepUser: 'Admin', tag: 'viewer' })
84+
85+
// Then "Admin" should see the app store
86+
await ui.waitForAppStoreIsVisible({ actorsEnvironment, stepUser: 'Admin' })
87+
88+
// Then "Admin" should see the following apps
89+
// | app |
90+
// | JSON Viewer |
91+
// | Draw.io |
92+
apps = []
93+
apps = await ui.getAppsList({ actorsEnvironment, stepUser: 'Admin' })
94+
expect(apps).toContain('Draw.io')
95+
expect(apps).toContain('JSON Viewer')
96+
97+
// And "Admin" logs out
98+
await ui.logOutUser({ actorsEnvironment, stepUser: 'Admin' })
99+
})
100+
})

tests/e2e/cucumber/features/app-store/web-packages.txt renamed to tests/e2e-playwright/specs/app-store/web-packages.txt

File renamed without changes.

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,59 @@ export async function navigateToAppStoreOverview({
9292
const pageObject = new objects.appStore.AppStore({ page })
9393
await pageObject.navigateToAppStoreOverview()
9494
}
95+
96+
export async function getAppsList({
97+
actorsEnvironment,
98+
stepUser
99+
}: {
100+
actorsEnvironment: ActorsEnvironment
101+
stepUser: string
102+
}): Promise<Array<string>> {
103+
const { page } = actorsEnvironment.getActor({ key: stepUser })
104+
const pageObject = new objects.appStore.AppStore({ page })
105+
return await pageObject.getAppsList()
106+
}
107+
108+
export async function setSearchTerm({
109+
actorsEnvironment,
110+
stepUser,
111+
searchTerm
112+
}: {
113+
actorsEnvironment: ActorsEnvironment
114+
stepUser: string
115+
searchTerm: string
116+
}): Promise<void> {
117+
const { page } = actorsEnvironment.getActor({ key: stepUser })
118+
const pageObject = new objects.appStore.AppStore({ page })
119+
await pageObject.setSearchTerm(searchTerm)
120+
}
121+
122+
export async function selectAppTag({
123+
actorsEnvironment,
124+
stepUser,
125+
tag,
126+
app
127+
}: {
128+
actorsEnvironment: ActorsEnvironment
129+
stepUser: string
130+
tag: string
131+
app: string
132+
}): Promise<void> {
133+
const { page } = actorsEnvironment.getActor({ key: stepUser })
134+
const pageObject = new objects.appStore.AppStore({ page })
135+
await pageObject.selectAppTag({ tag, app })
136+
}
137+
138+
export async function selectTag({
139+
actorsEnvironment,
140+
stepUser,
141+
tag
142+
}: {
143+
actorsEnvironment: ActorsEnvironment
144+
stepUser: string
145+
tag: string
146+
}): Promise<void> {
147+
const { page } = actorsEnvironment.getActor({ key: stepUser })
148+
const pageObject = new objects.appStore.AppStore({ page })
149+
await pageObject.selectTag(tag)
150+
}

tests/e2e/cucumber/features/app-store/discovery.feature

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

tests/e2e/support/objects/app-store/actions.ts

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,58 @@ export const waitForAppStoreIsVisible = async (args: { page: Page }): Promise<vo
6767
).toHaveLength(0)
6868
}
6969

70-
export const getAppsList = (args: { page: Page }): Promise<string[]> => {
70+
export const getAppsList = async (args: { page: Page }): Promise<string[]> => {
7171
const { page } = args
72+
const a11yObject = new objects.a11y.Accessibility({ page })
73+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
74+
a11yObject.getSelectors().appStore
75+
)
76+
expect(
77+
a11yViolations,
78+
`Found ${a11yViolations.length} severe accessibility violations in app store page`
79+
).toHaveLength(0)
7280
return page.locator(selectors.appTileTitle).allTextContents()
7381
}
7482

75-
export const setSearchTerm = (args: { page: Page; searchTerm: string }): Promise<void> => {
83+
export const setSearchTerm = async (args: { page: Page; searchTerm: string }): Promise<void> => {
7684
const { page, searchTerm } = args
85+
const a11yObject = new objects.a11y.Accessibility({ page })
86+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
87+
a11yObject.getSelectors().appStore
88+
)
89+
expect(
90+
a11yViolations,
91+
`Found ${a11yViolations.length} severe accessibility violations in app store page`
92+
).toHaveLength(0)
7793
return page.locator(selectors.appsFilter).fill(searchTerm)
7894
}
7995

80-
export const selectAppTag = (args: { page: Page; app: string; tag: string }): Promise<void> => {
96+
export const selectAppTag = async (args: {
97+
page: Page
98+
app: string
99+
tag: string
100+
}): Promise<void> => {
81101
const { page, app, tag } = args
102+
const a11yObject = new objects.a11y.Accessibility({ page })
103+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
104+
a11yObject.getSelectors().appStore
105+
)
106+
expect(
107+
a11yViolations,
108+
`Found ${a11yViolations.length} severe accessibility violations in app store page`
109+
).toHaveLength(0)
82110
return page.locator(util.format(selectors.appTag, app, tag)).click()
83111
}
84-
export const selectTag = (args: { page: Page; tag: string }): Promise<void> => {
112+
export const selectTag = async (args: { page: Page; tag: string }): Promise<void> => {
85113
const { page, tag } = args
114+
const a11yObject = new objects.a11y.Accessibility({ page })
115+
const a11yViolations = await a11yObject.getSevereAccessibilityViolations(
116+
a11yObject.getSelectors().appStore
117+
)
118+
expect(
119+
a11yViolations,
120+
`Found ${a11yViolations.length} severe accessibility violations in app store page`
121+
).toHaveLength(0)
86122
return page.locator(util.format(selectors.tag, tag)).click()
87123
}
88124

users.json

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

0 commit comments

Comments
 (0)