Skip to content

Commit

Permalink
Fix e2e tests for individual share in details view
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed May 9, 2023
1 parent b3aa484 commit c799132
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/features/smoke/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Feature: link
And "Alice" opens the "files" app
When "Alice" copies quick link of the resource "folderPublic" from the context menu
And "Anonymous" opens the public link "Link"
And "Anonymous" downloads the following public link resources using the sidebar panel
And "Anonymous" downloads the following public link resources using the single share view
| resource | type |
| lorem.txt | file |
And "Anonymous" logs out
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/steps/ui/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ When(
)

When(
/^"([^"]*)" downloads the following public link resource(s)? using the (sidebar panel|batch action)$/,
/^"([^"]*)" downloads the following public link resource(s)? using the (sidebar panel|batch action|single share view)$/,
async function (
this: World,
stepUser: string,
Expand Down
23 changes: 16 additions & 7 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { objects } from '../../../support'
import { expect } from '@playwright/test'
import { config } from '../../../config'
import { displayedResourceType } from '../../../support/objects/app-files/resource/actions'
import { Public } from '../../../support/objects/app-files/page/public'
import { Resource } from '../../../support/objects/app-files'

When(
'{string} creates the following resource(s)',
Expand Down Expand Up @@ -279,7 +281,11 @@ When(
}
)

export const processDelete = async (stepTable: DataTable, pageObject: any, actionType: string) => {
export const processDelete = async (
stepTable: DataTable,
pageObject: Public | Resource,
actionType: string
) => {
let files, parentFolder
const deleteInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { resource, from } = stepRow
Expand All @@ -306,13 +312,11 @@ export const processDelete = async (stepTable: DataTable, pageObject: any, actio

export const processDownload = async (
stepTable: DataTable,
pageObject: any,
pageObject: Public | Resource,
actionType: string
) => {
let downloads,
files,
parentFolder,
downloadedResources = []
let downloads, files, parentFolder
const downloadedResources = []
const downloadInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { resource, from, type } = stepRow
const resourceInfo = {
Expand All @@ -334,7 +338,12 @@ export const processDownload = async (
downloads = await pageObject.download({
folder: parentFolder,
resources: files,
via: actionType === 'batch action' ? 'BATCH_ACTION' : 'SIDEBAR_PANEL'
via:
actionType === 'batch action'
? 'BATCH_ACTION'
: actionType === 'sidebar panel'
? 'SIDEBAR_PANEL'
: 'SINGLE_SHARE_VIEW'
})

downloads.forEach((download) => {
Expand Down
27 changes: 24 additions & 3 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { File, Space } from '../../../types'
import { sidebar } from '../utils'
import { config } from '../../../../config'

const downloadFileButtonSingleShareView = '.oc-files-actions-download-file-trigger'
const downloadFolderButtonSingleShareView = '.oc-files-actions-download-archive-trigger'
const downloadFileButtonSideBar =
'#oc-files-actions-sidebar .oc-files-actions-download-file-trigger'
const downloadFolderButtonSidedBar =
const downloadFolderButtonSideBar =
'#oc-files-actions-sidebar .oc-files-actions-download-archive-trigger'
const downloadButtonBatchAction = '.oc-files-actions-download-archive-trigger'
const deleteButtonBatchAction = '.oc-files-actions-delete-trigger'
Expand Down Expand Up @@ -327,7 +329,7 @@ export interface downloadResourcesArgs {
page: Page
resources: resourceArgs[]
folder?: string
via: 'SIDEBAR_PANEL' | 'BATCH_ACTION'
via: 'SIDEBAR_PANEL' | 'BATCH_ACTION' | 'SINGLE_SHARE_VIEW'
}

export const downloadResources = async (args: downloadResourcesArgs): Promise<Download[]> => {
Expand All @@ -343,7 +345,7 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
await sidebar.open({ page, resource: resource.name })
await sidebar.openPanel({ page, name: 'actions' })
const downloadResourceSelector =
resource.type === 'file' ? downloadFileButtonSideBar : downloadFolderButtonSidedBar
resource.type === 'file' ? downloadFileButtonSideBar : downloadFolderButtonSideBar
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadResourceSelector).click()
Expand All @@ -368,6 +370,25 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
downloads.push(download)
break
}

case 'SINGLE_SHARE_VIEW': {
if (folder) {
await clickResource({ page, path: folder })
}
for (const resource of resources) {
const downloadResourceSelector =
resource.type === 'file'
? downloadFileButtonSingleShareView
: downloadFolderButtonSingleShareView
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadResourceSelector).click()
])

downloads.push(download)
}
break
}
}

return downloads
Expand Down

0 comments on commit c799132

Please sign in to comment.