Skip to content

Commit cbde369

Browse files
nirajacharya2PrajwolAmatya
authored andcommitted
test: convert tags.feature test to playwright
1 parent f1bb395 commit cbde369

7 files changed

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

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

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

0 commit comments

Comments
 (0)