Skip to content

Commit 24ecb37

Browse files
nirajacharya2PrajwolAmatya
authored andcommitted
test: convert tags.feature test to playwright
1 parent f7faa61 commit 24ecb37

7 files changed

Lines changed: 384 additions & 104 deletions

File tree

.drone.star

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ config = {
6767
"skip": False,
6868
"suites": [
6969
"journeys",
70-
"smoke",
7170
],
7271
},
7372
"2": {
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
import { test } from '../../support/test'
2+
import * as api from '../../steps/api/api'
3+
import * as ui from '../../steps/ui/index'
4+
5+
test.describe('Users can use web to organize tags', () => {
6+
test.beforeEach(async ({ world }) => {
7+
// Given "Admin" creates following users using API
8+
// | id |
9+
// | Alice |
10+
// | Brian |
11+
await api.usersHaveBeenCreated({
12+
world,
13+
stepUser: 'Admin',
14+
users: ['Alice', 'Brian']
15+
})
16+
17+
// Given "Alice" logs in
18+
await ui.userLogsIn({ world, stepUser: 'Alice' })
19+
})
20+
21+
test('Tag management', { tag: '@predefined-users' }, async ({ world }) => {
22+
// When "Alice" creates the following files into personal space using API
23+
// | pathToFile | content |
24+
// | lorem.txt | lorem ipsum |
25+
await api.userHasCreatedFiles({
26+
world,
27+
stepUser: 'Alice',
28+
files: [{ pathToFile: 'lorem.txt', content: 'lorem ipsum' }]
29+
})
30+
// And "Alice" adds the following tags for the following resources using the sidebar panel
31+
// | resource | tags |
32+
// | lorem.txt | tag 1, tag 2 |
33+
await ui.userAddsFollowingTagsForResourcesUsingSidebarPanel({
34+
world,
35+
stepUser: 'Alice',
36+
resource: 'lorem.txt',
37+
tags: ['tag 1', 'tag 2']
38+
})
39+
// Then the following resources should contain the following tags in the files list for user "Alice"
40+
// | resource | tags |
41+
// | lorem.txt | tag 1, tag 2 |
42+
await ui.resourceShouldContainTagsInFileList({
43+
world,
44+
stepUser: 'Alice',
45+
resource: 'lorem.txt',
46+
tags: ['tag 1', 'tag 2']
47+
})
48+
// Then the following resources should contain the following tags in the details panel for user "Alice"
49+
// | resource | tags |
50+
// | lorem.txt | tag 1, tag 2 |
51+
await ui.resourceShouldContainTagsInDetailPanel({
52+
world,
53+
stepUser: 'Alice',
54+
resource: 'lorem.txt',
55+
tags: ['tag 1', 'tag 2']
56+
})
57+
// When "Alice" removes the following tags for the following resources using the sidebar panel
58+
// | resource | tags |
59+
// | lorem.txt | tag 1 |
60+
await ui.userRemovesTagsFromResourcesUsingSideBar({
61+
world,
62+
stepUser: 'Alice',
63+
resource: 'lorem.txt',
64+
tags: ['tag 1']
65+
})
66+
// Then the following resources should contain the following tags in the files list for user "Alice"
67+
// | resource | tags |
68+
// | lorem.txt | tag 2 |
69+
await ui.resourceShouldContainTagsInFileList({
70+
world,
71+
stepUser: 'Alice',
72+
resource: 'lorem.txt',
73+
tags: ['tag 2']
74+
})
75+
// Then the following resources should contain the following tags in the details panel for user "Alice"
76+
// | resource | tags |
77+
// | lorem.txt | tag 2 |
78+
await ui.resourceShouldContainTagsInDetailPanel({
79+
world,
80+
stepUser: 'Alice',
81+
resource: 'lorem.txt',
82+
tags: ['tag 2']
83+
})
84+
// And "Alice" logs out
85+
await ui.userLogsOut({ world, stepUser: 'Alice' })
86+
})
87+
88+
test('Long tag name', async ({ world }) => {
89+
// And "Alice" creates the following files into personal space using API
90+
// | pathToFile | content |
91+
// | lorem.txt | lorem ipsum |
92+
await api.userHasCreatedFiles({
93+
world,
94+
stepUser: 'Alice',
95+
files: [{ pathToFile: 'lorem.txt', content: 'lorem ipsum' }]
96+
})
97+
// When "Alice" tries to add the following tag for the following resources using the sidebar panel
98+
// | resource | tags |
99+
// | lorem.txt | Loremipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore |
100+
await ui.userTriesToAddTagForResourceUsingSidebarPanel({
101+
world,
102+
stepUser: 'Alice',
103+
resource: 'lorem.txt',
104+
tags: [
105+
'Loremipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore'
106+
]
107+
})
108+
// Then "Alice" should see the following tag validation message:
109+
// """
110+
// Tags must not be longer than 100 characters
111+
// """
112+
await ui.userShouldSeeFollowingTagValidationMessages({
113+
world,
114+
stepUser: 'Alice',
115+
message: 'Tags must not be longer than 100 characters'
116+
})
117+
// And "Alice" logs out
118+
await ui.userLogsOut({ world, stepUser: 'Alice' })
119+
})
120+
121+
test('Tag search', { tag: '@predefined-users' }, async ({ world }) => {
122+
// When "Alice" creates the following files into personal space using API
123+
// | pathToFile | content |
124+
// | lorem.txt | lorem ipsum |
125+
// | textfile.txt | test file |
126+
await api.userHasCreatedFiles({
127+
world,
128+
stepUser: 'Alice',
129+
files: [
130+
{ pathToFile: 'lorem.txt', content: 'lorem ipsum' },
131+
{ pathToFile: 'textfile.txt', content: 'test file' }
132+
]
133+
})
134+
// And "Alice" adds the following tags for the following resources using the sidebar panel
135+
// | resource | tags |
136+
// | lorem.txt | tag1, tag2 |
137+
await ui.userAddsFollowingTagsForResourcesUsingSidebarPanel({
138+
world,
139+
stepUser: 'Alice',
140+
resource: 'lorem.txt',
141+
tags: ['tag1', 'tag2']
142+
})
143+
// And "Alice" clicks the tag "tag1" on the resource "lorem.txt"
144+
await ui.userClicksTheTagOnResource({
145+
world,
146+
stepUser: 'Alice',
147+
resourceName: 'lorem.txt',
148+
tagName: 'tag1'
149+
})
150+
// Then the following resources should contain the following tags in the files list for user "Alice"
151+
// | resource | tags |
152+
// | lorem.txt | tag1 |
153+
await ui.resourceShouldContainTagsInFileList({
154+
world,
155+
stepUser: 'Alice',
156+
resource: 'lorem.txt',
157+
tags: ['tag1']
158+
})
159+
// Then following resources should not be displayed in the files list for user "Alice"
160+
// | resource |
161+
// | textfile.txt |
162+
await ui.userShouldNotSeeTheResources({
163+
world,
164+
listType: 'files list',
165+
stepUser: 'Alice',
166+
resources: ['textfile.txt']
167+
})
168+
// And "Alice" logs out
169+
await ui.userLogsOut({ world, stepUser: 'Alice' })
170+
})
171+
172+
test('Tags in shared resources', { tag: '@predefined-users' }, async ({ world }) => {
173+
// And "Brian" logs in
174+
await ui.userLogsIn({ world, stepUser: 'Brian' })
175+
// And "Alice" creates the following folders in personal space using API
176+
// | name |
177+
// | folder_to_shared |
178+
await api.userHasCreatedFolders({
179+
world,
180+
stepUser: 'Alice',
181+
folderNames: ['folder_to_shared']
182+
})
183+
// And "Alice" creates the following files into personal space using API
184+
// | pathToFile | content |
185+
// | folder_to_shared/lorem.txt | lorem ipsum |
186+
await api.userHasCreatedFiles({
187+
world,
188+
stepUser: 'Alice',
189+
files: [{ pathToFile: 'folder_to_shared/lorem.txt', content: 'lorem ipsum' }]
190+
})
191+
// And "Alice" adds the following tags for the following resources using the sidebar panel
192+
// | resource | tags |
193+
// | folder_to_shared/lorem.txt | tag 1, tag 2 |
194+
await ui.userAddsFollowingTagsForResourcesUsingSidebarPanel({
195+
world,
196+
stepUser: 'Alice',
197+
resource: 'folder_to_shared/lorem.txt',
198+
tags: ['tag 1', 'tag 2']
199+
})
200+
// When "Alice" shares the following resource using the sidebar panel
201+
// | resource | recipient | type | role | resourceType |
202+
// | folder_to_shared | Brian | user | Can edit with trashbin | folder |
203+
await ui.userSharesResources({
204+
world,
205+
stepUser: 'Alice',
206+
actionType: 'SIDEBAR_PANEL',
207+
shares: [
208+
{
209+
resource: 'folder_to_shared',
210+
recipient: 'Brian',
211+
type: 'user',
212+
role: 'Can edit with trashbin',
213+
resourceType: 'folder'
214+
}
215+
]
216+
})
217+
// And "Alice" logs out
218+
await ui.userLogsOut({ world, stepUser: 'Alice' })
219+
// And "Brian" navigates to the shared with me page
220+
await ui.userNavigatesToSharedWithMePage({
221+
world,
222+
stepUser: 'Brian'
223+
})
224+
// Then the following resources should contain the following tags in the files list for user "Brian"
225+
// | resource | tags |
226+
// | folder_to_shared/lorem.txt | tag 1, tag 2 |
227+
await ui.resourceShouldContainTagsInFileList({
228+
world,
229+
stepUser: 'Brian',
230+
resource: 'folder_to_shared/lorem.txt',
231+
tags: ['tag 1', 'tag 2']
232+
})
233+
// And "Brian" logs out
234+
await ui.userLogsOut({ world, stepUser: 'Brian' })
235+
})
236+
})

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

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,3 +1371,133 @@ export async function userShouldNotSeeShareIndicatorOnResource({
13711371
})
13721372
await expect(shareIndicator).not.toBeVisible()
13731373
}
1374+
1375+
export async function userAddsFollowingTagsForResourcesUsingSidebarPanel({
1376+
world,
1377+
stepUser,
1378+
resource,
1379+
tags
1380+
}: {
1381+
world: World
1382+
stepUser: string
1383+
resource: string
1384+
tags: string[]
1385+
}): Promise<void> {
1386+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1387+
const resourceObject = new objects.applicationFiles.Resource({ page })
1388+
await resourceObject.addTags({
1389+
resource,
1390+
tags: tags.map((tag) => tag.trim().toLowerCase())
1391+
})
1392+
}
1393+
1394+
export async function resourceShouldContainTagsInFileList({
1395+
world,
1396+
stepUser,
1397+
resource,
1398+
tags
1399+
}: {
1400+
world: World
1401+
stepUser: string
1402+
resource: string
1403+
tags: string[]
1404+
}): Promise<void> {
1405+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1406+
const resourceObject = new objects.applicationFiles.Resource({ page })
1407+
const isVisible = await resourceObject.areTagsVisibleForResourceInFilesTable({
1408+
resource,
1409+
tags: tags.map((tag) => tag.trim().toLowerCase())
1410+
})
1411+
expect(isVisible).toBe(true)
1412+
}
1413+
1414+
export async function resourceShouldContainTagsInDetailPanel({
1415+
world,
1416+
stepUser,
1417+
resource,
1418+
tags
1419+
}: {
1420+
world: World
1421+
stepUser: string
1422+
resource: string
1423+
tags: string[]
1424+
}): Promise<void> {
1425+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1426+
const resourceObject = new objects.applicationFiles.Resource({ page })
1427+
const isVisible = await resourceObject.areTagsVisibleForResourceInDetailsPanel({
1428+
resource,
1429+
tags: tags.map((tag) => tag.trim().toLowerCase())
1430+
})
1431+
expect(isVisible).toBe(true)
1432+
}
1433+
1434+
export async function userRemovesTagsFromResourcesUsingSideBar({
1435+
world,
1436+
stepUser,
1437+
resource,
1438+
tags
1439+
}: {
1440+
world: World
1441+
stepUser: string
1442+
resource: string
1443+
tags: string[]
1444+
}): Promise<void> {
1445+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1446+
const resourceObject = new objects.applicationFiles.Resource({ page })
1447+
1448+
await resourceObject.removeTags({
1449+
resource,
1450+
tags: tags.map((tag) => tag.trim().toLowerCase())
1451+
})
1452+
}
1453+
1454+
export async function userTriesToAddTagForResourceUsingSidebarPanel({
1455+
world,
1456+
stepUser,
1457+
resource,
1458+
tags
1459+
}: {
1460+
world: World
1461+
stepUser: string
1462+
resource: string
1463+
tags: string[]
1464+
}): Promise<void> {
1465+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1466+
const resourceObject = new objects.applicationFiles.Resource({ page })
1467+
1468+
await resourceObject.tryToAddTags({
1469+
resource,
1470+
tags: tags.map((tag) => tag.trim().toLowerCase())
1471+
})
1472+
}
1473+
1474+
export async function userShouldSeeFollowingTagValidationMessages({
1475+
world,
1476+
stepUser,
1477+
message
1478+
}: {
1479+
world: World
1480+
stepUser: string
1481+
message: string
1482+
}): Promise<void> {
1483+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1484+
const resourceObject = new objects.applicationFiles.Resource({ page })
1485+
const actualMessage = await resourceObject.getTagValidationMessage()
1486+
expect(actualMessage).toBe(message)
1487+
}
1488+
1489+
export async function userClicksTheTagOnResource({
1490+
world,
1491+
stepUser,
1492+
resourceName,
1493+
tagName
1494+
}: {
1495+
world: World
1496+
stepUser: string
1497+
resourceName: string
1498+
tagName: string
1499+
}): Promise<void> {
1500+
const { page } = world.actorsEnvironment.getActor({ key: stepUser })
1501+
const resourceObject = new objects.applicationFiles.Resource({ page })
1502+
await resourceObject.clickTag({ resource: resourceName, tag: tagName.trim().toLowerCase() })
1503+
}

0 commit comments

Comments
 (0)