Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/e2e/cucumber/features/app-provider/officeSuites.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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])
}
)
19 changes: 19 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<void> => {
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()
}
4 changes: 4 additions & 0 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,8 @@ export class Resource {
}): Promise<Locator> {
return await po.getAvatarLocatorFromActivityPanel({ page: this.#page, ...args })
}

async openFileViaContextMenu(resource: string, fileViewer: string): Promise<void> {
await po.openFileViaContextMenu({ page: this.#page, resource, fileViewer })
}
}