Skip to content

Commit 1845ea7

Browse files
committed
open file using context menu
1 parent a82a8f5 commit 1845ea7

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

tests/e2e/cucumber/features/app-provider/officeSuites.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,13 @@ Feature: Integration with Collabora online office
144144
| resource |
145145
| Template (1).docx |
146146
And "Alice" logs out
147+
148+
149+
Scenario: open the file using the context menu
150+
When "Alice" logs in
151+
And "Alice" opens file "new.txt" via "collabora" using the context menu
152+
Then "Alice" should see the content "test content" in editor "Collabora"
153+
And "Alice" closes the file viewer
154+
When "Alice" opens file "new.txt" via "text-editor" using the context menu
155+
And "Alice" closes the file viewer
156+
And "Alice" logs out

tests/e2e/cucumber/steps/ui/resources.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,3 +1098,18 @@ Then(
10981098
await expect(avatarLocator).toBeVisible()
10991099
}
11001100
)
1101+
1102+
When(
1103+
'{string} opens file {string} via {string} using the context menu',
1104+
async function (this: World, stepUser: string, file: string, fileViewer: string): Promise<void> {
1105+
const allowedViewers = ['collabora', 'text-editor', 'preview'] as const
1106+
1107+
if (!allowedViewers.includes(fileViewer as any)) {
1108+
throw new Error(`Unsupported file viewer: ${fileViewer}`)
1109+
}
1110+
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
1111+
const resourceObject = new objects.applicationFiles.Resource({ page })
1112+
1113+
await resourceObject.openFileViaContextMenu(file, fileViewer as (typeof allowedViewers)[number])
1114+
}
1115+
)

tests/e2e/support/objects/app-files/resource/actions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const fileIconPreview = '#oc-file-details-sidebar .details-preview'
146146
const activitySidebarPanel = 'sidebar-panel-activities'
147147
const activitySidebarPanelBodyContent = '#sidebar-panel-activities .sidebar-panel__body-content'
148148
const contextMenuAction = '//*[@id="oc-files-context-actions-context"]//span[text()="%s"]'
149+
const openWithAction = '.oc-files-actions-%s-trigger'
149150

150151
export const clickResource = async ({
151152
page,
@@ -2268,3 +2269,21 @@ export const getAvatarLocatorFromActivityPanel = async (args: {
22682269
.locator(util.format(userAvatarInActivitypanelSelector, user.username))
22692270
.locator('img')
22702271
}
2272+
2273+
export const openFileViaContextMenu = async ({
2274+
page,
2275+
resource,
2276+
fileViewer
2277+
}: {
2278+
page: Page
2279+
resource: string
2280+
fileViewer: string
2281+
}): Promise<void> => {
2282+
await page.locator(util.format(resourceNameSelector, resource)).click({ button: 'right' })
2283+
const openWith = page.locator(util.format(contextMenuAction, 'Open with...'))
2284+
await openWith.hover()
2285+
2286+
const editorItem = page.locator(util.format(openWithAction, fileViewer))
2287+
await expect(editorItem).toBeVisible()
2288+
await editorItem.click()
2289+
}

tests/e2e/support/objects/app-files/resource/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,8 @@ export class Resource {
413413
}): Promise<Locator> {
414414
return await po.getAvatarLocatorFromActivityPanel({ page: this.#page, ...args })
415415
}
416+
417+
async openFileViaContextMenu(resource: string, fileViewer: string): Promise<void> {
418+
await po.openFileViaContextMenu({ page: this.#page, resource, fileViewer })
419+
}
416420
}

0 commit comments

Comments
 (0)