Skip to content

Commit 76a05ca

Browse files
committed
rewrite office suites test in playwright
Signed-off-by: Prajwol Amatya <prajwolamatya11@gmail.com>
1 parent b1f052d commit 76a05ca

10 files changed

Lines changed: 1254 additions & 289 deletions

File tree

tests/e2e-playwright/specs/app-provider/officeSuites.spec.ts

Lines changed: 1113 additions & 0 deletions
Large diffs are not rendered by default.

tests/e2e-playwright/specs/file-action/fileViewer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test.describe('Different file viewers', { tag: '@predefined-users' }, () => {
6060
// | resource | content |
6161
// | lorem.txt | new content edited |
6262
// | lorem.md | new readme content edited |
63-
await ui.userEditsFile({
63+
await ui.userEditsResources({
6464
actorsEnvironment,
6565
stepUser: 'Alice',
6666
resources: [

tests/e2e-playwright/specs/shares/link.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test.describe('link', () => {
9090
newName: 'myPublicLink'
9191
})
9292
// And "Alice" edits the public link named "myPublicLink" of resource "folderPublic" changing role to "Secret File Drop"
93-
await ui.userChangesRoleOfThePublicLinkOfResource({
93+
await ui.userChangesRoleOfPublicLinkOfResource({
9494
actorsEnvironment,
9595
stepUser: 'Alice',
9696
resource: 'folderPublic',
@@ -177,7 +177,7 @@ test.describe('link', () => {
177177
name: 'files'
178178
})
179179
// And "Alice" edits the public link named "myPublicLink" of resource "folderPublic" changing role to "Can edit"
180-
await ui.userChangesRoleOfThePublicLinkOfResource({
180+
await ui.userChangesRoleOfPublicLinkOfResource({
181181
actorsEnvironment,
182182
stepUser: 'Alice',
183183
resource: 'folderPublic',

tests/e2e-playwright/specs/smoke/activity.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test.describe('Users can see all activities of the resources and spaces', () =>
147147
// And "Anonymous" edits the following resources
148148
// | resource | content |
149149
// | textfile.txt | new content |
150-
await ui.userEditsFile({
150+
await ui.userEditsResources({
151151
actorsEnvironment,
152152
stepUser: 'Anonymous',
153153
resources: [{ name: 'textfile.txt', content: 'new content' }]

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { objects } from '../../../e2e/support'
22
import { expect } from '@playwright/test'
33
import { ActorsEnvironment } from '../../../e2e/support/environment'
4+
import { substitute } from '../../../e2e/support/utils'
45

56
export async function userRenamesMostRecentlyCreatedPublicLinkOfResource({
67
actorsEnvironment,
@@ -48,7 +49,7 @@ export async function userClosesThePasswordProtectedFolderModal({
4849
await linkObject.closeFolderModal()
4950
}
5051

51-
export async function userChangesRoleOfThePublicLinkOfResource({
52+
export async function userChangesRoleOfPublicLinkOfResource({
5253
actorsEnvironment,
5354
stepUser,
5455
resource,
@@ -100,3 +101,50 @@ export async function userRemovesThePublicLinkOfResource({
100101
const linkObject = new objects.applicationFiles.Link({ page })
101102
await linkObject.delete({ resourceName: resource, name: linkName })
102103
}
104+
105+
export async function userCreatesPublicLinkOfSpaceWithPassword({
106+
actorsEnvironment,
107+
stepUser,
108+
password
109+
}: {
110+
actorsEnvironment: ActorsEnvironment
111+
stepUser: string
112+
password: string
113+
}): Promise<void> {
114+
const { page } = actorsEnvironment.getActor({ key: stepUser })
115+
const spaceObject = new objects.applicationFiles.Spaces({ page })
116+
password = substitute(password)
117+
await spaceObject.createPublicLink({ password })
118+
}
119+
120+
export async function userRenamesTheMostRecentlyCreatedPublicLinkOfSpace({
121+
actorsEnvironment,
122+
stepUser,
123+
newName
124+
}: {
125+
actorsEnvironment: ActorsEnvironment
126+
stepUser: string
127+
newName: string
128+
}): Promise<void> {
129+
const { page } = actorsEnvironment.getActor({ key: stepUser })
130+
const linkObject = new objects.applicationFiles.Link({ page })
131+
const linkName = await linkObject.changeName({ newName, space: true })
132+
expect(linkName).toBe(newName)
133+
}
134+
135+
export async function userEditsThePublicLinkOfSpaceChangingRole({
136+
actorsEnvironment,
137+
stepUser,
138+
linkName,
139+
role
140+
}: {
141+
actorsEnvironment: ActorsEnvironment
142+
stepUser: string
143+
linkName: string
144+
role: string
145+
}): Promise<void> {
146+
const { page } = actorsEnvironment.getActor({ key: stepUser })
147+
const linkObject = new objects.applicationFiles.Link({ page })
148+
const newPermission = await linkObject.changeRole({ linkName, role, space: true })
149+
expect(newPermission.toLowerCase()).toBe(role.toLowerCase())
150+
}

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ export async function userNavigatesToFolderViaBreadcrumb({
707707
await resourceObject.openFolderViaBreadcrumb(resource)
708708
}
709709

710-
export async function userEditsFile({
710+
export async function userEditsResources({
711711
actorsEnvironment,
712712
stepUser,
713713
resources
@@ -1088,3 +1088,54 @@ export async function userDownloadsThePublicLinkResources({
10881088
const pageObject = new objects.applicationFiles.page.Public({ page })
10891089
await processDownload(pageObject, actionType, resources)
10901090
}
1091+
1092+
export async function userShouldNotBeAbleToEditContentOfResources({
1093+
actorsEnvironment,
1094+
stepUser,
1095+
resources
1096+
}: {
1097+
actorsEnvironment: ActorsEnvironment
1098+
stepUser: string
1099+
resources: { name: string; type: string; content: string }[]
1100+
}): Promise<void> {
1101+
const { page } = actorsEnvironment.getActor({ key: stepUser })
1102+
const resourceObject = new objects.applicationFiles.Resource({ page })
1103+
for (const resource of resources) {
1104+
const canEdit = await resourceObject.canEditDocumentContent({ type: resource.type })
1105+
expect(canEdit).toBe(false)
1106+
}
1107+
}
1108+
1109+
export async function userCreatesFileFromTemplateFile({
1110+
actorsEnvironment,
1111+
stepUser,
1112+
file,
1113+
webOffice,
1114+
actionType
1115+
}: {
1116+
actorsEnvironment: ActorsEnvironment
1117+
stepUser: string
1118+
file: string
1119+
webOffice: string
1120+
actionType: 'sidebar panel' | 'context menu'
1121+
}): Promise<void> {
1122+
const { page } = actorsEnvironment.getActor({ key: stepUser })
1123+
const resourceObject = new objects.applicationFiles.Resource({ page })
1124+
await resourceObject.createFileFromTemplate(file, webOffice, actionType)
1125+
}
1126+
1127+
export async function userOpensTemplateFileUsingContextMenu({
1128+
actorsEnvironment,
1129+
stepUser,
1130+
file,
1131+
webOffice
1132+
}: {
1133+
actorsEnvironment: ActorsEnvironment
1134+
stepUser: string
1135+
file: string
1136+
webOffice: string
1137+
}): Promise<void> {
1138+
const { page } = actorsEnvironment.getActor({ key: stepUser })
1139+
const resourceObject = new objects.applicationFiles.Resource({ page })
1140+
await resourceObject.openTemplateFile(file, webOffice)
1141+
}

0 commit comments

Comments
 (0)