Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
SwikritiT committed Apr 13, 2022
1 parent 50b5f05 commit b05f23d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 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 files using the batch action
When "Alice" downloads the following resources using the batch action
| resource | from |
| lorem.txt | folderPublic |
| textfile.txt | folderPublic |
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cucumber/features/integrations/share.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Feature: share
And "Brian" copies the following resource
| resource | to |
| Shares/testavatar.jpeg | Personal |
And "Brian" downloads the following file using the sidebar panel
And "Brian" downloads the following resource using the sidebar panel
| resource | from |
| testavatar.jpeg | Shares |
And "Alice" updates following sharee role
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/cucumber/features/journeys/kindergarten.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Feature: Kindergarten can use web to organize a day
| name |
| meal plan |
And "Brian" navigates to the personal space page
And "Brian" downloads the following files using the sidebar panel
And "Brian" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | Shares/meal plan |
# Then what do we check for to be confident that the above things done by Brian have worked?
Expand All @@ -59,22 +59,22 @@ Feature: Kindergarten can use web to organize a day
| name |
| meal plan |
And "Carol" navigates to the personal space page
And "Carol" downloads the following files using the sidebar panel
And "Carol" downloads the following resources using the sidebar panel
| resource | from |
| data.zip | Shares/meal plan |
| lorem.txt | Shares/meal plan |
| lorem-big.txt | Shares/meal plan |
# Then what do we check for to be confident that the above things done by Carol have worked?
# Then the downloaded files should have content "abc..."
And "Carol" logs out
When "Brian" downloads the following files using the sidebar panel
When "Brian" downloads the following resources using the sidebar panel
| resource | from |
| lorem.txt | Shares/meal plan |
| lorem-big.txt | Shares/meal plan |
# Then what do we check for to be confident that the above things done by Brian have worked?
# Then the downloaded files should have content "abc..."
And "Brian" logs out
And "Alice" downloads the following files using the sidebar panel
And "Alice" downloads the following resources using the sidebar panel
| resource | from |
| parent.txt | groups/Kindergarten Koalas/meal plan |
| lorem.txt | groups/Kindergarten Koalas/meal plan |
Expand Down
2 changes: 1 addition & 1 deletion 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 file(s)? using the (sidebar panel|batch action)$/,
/^"([^"]*)" downloads the following resource(s)? using the (sidebar panel|batch action)$/,
async function (
this: World,
stepUser: string,
Expand Down
51 changes: 27 additions & 24 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Download, Page } from 'playwright'
import util from 'util'
import { resourceExists, waitForResources } from './utils'
import path from 'path'
import { File } from '../../../types'
import { sidebar } from '../utils'

const downloadButtonSideBar = '#oc-files-actions-sidebar .oc-files-actions-download-file-trigger'
const downloadButtonBatchActionSingleFile = '.oc-files-actions-download-file-trigger'
const downloadButtonBatchActionMultiple = '.oc-files-actions-download-archive-trigger'
const checkBox = `//*[@data-test-resource-name="%s"]//ancestor::tr//input`

export const clickResource = async ({
page,
path
Expand All @@ -13,10 +19,8 @@ export const clickResource = async ({
}): Promise<void> => {
const paths = path.split('/')
for (const name of paths) {
const resourceSelector = `[data-test-resource-name="${name}"]`
await page.waitForSelector(resourceSelector)
await Promise.all([
page.locator(resourceSelector).click(),
page.locator(`[data-test-resource-name="${name}"]`).click(),
page.waitForResponse((resp) => resp.url().endsWith(encodeURIComponent(name)))
])
}
Expand Down Expand Up @@ -114,7 +118,7 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do

const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator('#oc-files-actions-sidebar .oc-files-actions-download-file-trigger').click()
page.locator(downloadButtonSideBar).click()
])

await sidebar.close({ page: page })
Expand All @@ -125,20 +129,16 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
}

case 'BATCH_ACTION': {
await selectMultipleResources({ page: page, names: names, folder: folder })
await selectResources({ page: page, names: names, folder: folder })
let downloadSelector = downloadButtonBatchActionMultiple
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)
downloadSelector = downloadButtonBatchActionSingleFile
}
const [download] = await Promise.all([
page.waitForEvent('download'),
page.locator(downloadSelector).click()
])
downloads.push(download)
break
}
}
Expand All @@ -152,19 +152,22 @@ export type selectResourcesArgs = {
folder: string
}

export const selectMultipleResources = async (args: selectResourcesArgs): Promise<void> => {
export const selectResources = async (args: selectResourcesArgs): Promise<void> => {
const { page, folder, names } = args
if (folder) {
await clickResource({ page: page, path: folder })
}

for (const name of names) {
const resourceCheckbox = page.locator(
`//*[@data-test-resource-name="${name}"]//ancestor::tr//input`
)

if (!(await resourceCheckbox.isChecked())) {
await resourceCheckbox.check()
for (const resource of names) {
const exists = await resourceExists({
page: page,
name: resource
})
if (exists) {
const resourceCheckbox = page.locator(util.format(checkBox, resource))
if (!(await resourceCheckbox.isChecked())) {
await resourceCheckbox.check()
}
}
}
}
Expand Down

0 comments on commit b05f23d

Please sign in to comment.