Skip to content

Commit

Permalink
Download single file
Browse files Browse the repository at this point in the history
  • Loading branch information
SwikritiT committed Apr 4, 2022
1 parent 5acccdb commit e00256b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/features/integrations/link.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: link
#Then the public should not see the following files on the files-drop page
# | textfile.txt |
And "Anonymous" logs out
When "Alice" downloads the following resources using the batch action
When "Alice" downloads the following files using the batch action
| resource | from |
| lorem.txt | folderPublic |
| textfile.txt | folderPublic |
Expand Down
20 changes: 14 additions & 6 deletions tests/e2e/cucumber/steps/app-files/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ When(
)

When(
/^"([^"]*)" downloads the following resource(s)? using the (sidebar panel|batch action)$/,
/^"([^"]*)" downloads the following file(s)? using the (sidebar panel|batch action)$/,
async function (
this: World,
stepUser: string,
Expand All @@ -46,6 +46,7 @@ When(
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
let downloads
let files
const downloadInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { resource, from } = stepRow

Expand All @@ -59,7 +60,7 @@ When(
}, {})

for (const folder of Object.keys(downloadInfo)) {
const files = downloadInfo[folder]
files = downloadInfo[folder]
downloads = await resourceObject.download({
folder,
names: files,
Expand All @@ -74,10 +75,17 @@ When(
}

if (actionType === 'batch action') {
expect(downloads.length).toBe(1)
downloads.forEach((download) => {
expect(download.suggestedFilename()).toBe('download.tar')
})
if (files.length === 1) {
expect(files.length).toBe(downloads.length)
downloads.forEach((download) => {
expect(files[0]).toBe(download.suggestedFilename())
})
} else {
expect(downloads.length).toBe(1)
downloads.forEach((download) => {
expect(download.suggestedFilename()).toBe('download.tar')
})
}
}
}
)
Expand Down
18 changes: 13 additions & 5 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,19 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do

case 'BATCH_ACTION': {
await selectMultipleResources({ page: page, names: names, folder: folder })
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('.oc-files-actions-download-archive-trigger').click()
])
downloads.push(download)
if (names.length === 1) {
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('.oc-files-actions-download-file-trigger').click()
])
downloads.push(download)
} else {
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('.oc-files-actions-download-archive-trigger').click()
])
downloads.push(download)
}
break
}
}
Expand Down

0 comments on commit e00256b

Please sign in to comment.