diff --git a/tests/e2e/cucumber/features/app-provider/officeSuites.feature b/tests/e2e/cucumber/features/app-provider/officeSuites.feature index 207485ce1f..d74ba3faaf 100644 --- a/tests/e2e/cucumber/features/app-provider/officeSuites.feature +++ b/tests/e2e/cucumber/features/app-provider/officeSuites.feature @@ -144,3 +144,13 @@ Feature: Integration with Collabora online office | resource | | Template (1).docx | And "Alice" logs out + + + Scenario: open the file using the context menu + When "Alice" logs in + And "Alice" opens file "new.txt" via "collabora" using the context menu + Then "Alice" should see the content "test content" in editor "Collabora" + And "Alice" closes the file viewer + When "Alice" opens file "new.txt" via "text-editor" using the context menu + And "Alice" closes the file viewer + And "Alice" logs out diff --git a/tests/e2e/cucumber/steps/ui/resources.ts b/tests/e2e/cucumber/steps/ui/resources.ts index c4e2b3c98b..f235ac403e 100644 --- a/tests/e2e/cucumber/steps/ui/resources.ts +++ b/tests/e2e/cucumber/steps/ui/resources.ts @@ -1098,3 +1098,18 @@ Then( await expect(avatarLocator).toBeVisible() } ) + +When( + '{string} opens file {string} via {string} using the context menu', + async function (this: World, stepUser: string, file: string, fileViewer: string): Promise { + const allowedViewers = ['collabora', 'text-editor', 'preview'] as const + + if (!allowedViewers.includes(fileViewer as any)) { + throw new Error(`Unsupported file viewer: ${fileViewer}`) + } + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const resourceObject = new objects.applicationFiles.Resource({ page }) + + await resourceObject.openFileViaContextMenu(file, fileViewer as (typeof allowedViewers)[number]) + } +) diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 71cd4811a1..eda6865be6 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -146,6 +146,7 @@ const fileIconPreview = '#oc-file-details-sidebar .details-preview' const activitySidebarPanel = 'sidebar-panel-activities' const activitySidebarPanelBodyContent = '#sidebar-panel-activities .sidebar-panel__body-content' const contextMenuAction = '//*[@id="oc-files-context-actions-context"]//span[text()="%s"]' +const openWithAction = '.oc-files-actions-%s-trigger' export const clickResource = async ({ page, @@ -2268,3 +2269,21 @@ export const getAvatarLocatorFromActivityPanel = async (args: { .locator(util.format(userAvatarInActivitypanelSelector, user.username)) .locator('img') } + +export const openFileViaContextMenu = async ({ + page, + resource, + fileViewer +}: { + page: Page + resource: string + fileViewer: string +}): Promise => { + await page.locator(util.format(resourceNameSelector, resource)).click({ button: 'right' }) + const openWith = page.locator(util.format(contextMenuAction, 'Open with...')) + await openWith.hover() + + const editorItem = page.locator(util.format(openWithAction, fileViewer)) + await expect(editorItem).toBeVisible() + await editorItem.click() +} diff --git a/tests/e2e/support/objects/app-files/resource/index.ts b/tests/e2e/support/objects/app-files/resource/index.ts index 275b9cba33..04c0db790e 100644 --- a/tests/e2e/support/objects/app-files/resource/index.ts +++ b/tests/e2e/support/objects/app-files/resource/index.ts @@ -413,4 +413,8 @@ export class Resource { }): Promise { return await po.getAvatarLocatorFromActivityPanel({ page: this.#page, ...args }) } + + async openFileViaContextMenu(resource: string, fileViewer: string): Promise { + await po.openFileViaContextMenu({ page: this.#page, resource, fileViewer }) + } }