Skip to content

Commit

Permalink
deselect items
Browse files Browse the repository at this point in the history
Signed-off-by: Swikriti Tripathi <[email protected]>
  • Loading branch information
SwikritiT committed Apr 25, 2022
1 parent 869554f commit ccd6acf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const downloadResources = async (args: downloadResourcesArgs): Promise<Do
}

case 'BATCH_ACTION': {
await selectResources({ page: page, names: names, folder: folder })
await selectOrDeselectResources({ page: page, names: names, folder: folder, select: true })
let downloadSelector = downloadButtonBatchActionMultiple
if (names.length === 1) {
downloadSelector = downloadButtonBatchActionSingleFile
Expand All @@ -150,10 +150,11 @@ export type selectResourcesArgs = {
page: Page
names: string[]
folder: string
select: boolean
}

export const selectResources = async (args: selectResourcesArgs): Promise<void> => {
const { page, folder, names } = args
export const selectOrDeselectResources = async (args: selectResourcesArgs): Promise<void> => {
const { page, folder, names, select } = args
if (folder) {
await clickResource({ page: page, path: folder })
}
Expand All @@ -165,8 +166,10 @@ export const selectResources = async (args: selectResourcesArgs): Promise<void>
})
if (exists) {
const resourceCheckbox = page.locator(util.format(checkBox, resource))
if (!(await resourceCheckbox.isChecked())) {
if (!(await resourceCheckbox.isChecked()) && select) {
await resourceCheckbox.check()
} else if (await resourceCheckbox.isChecked()) {
await resourceCheckbox.uncheck()
}
} else {
throw new Error(`The resource ${resource} you are trying to select does not exist`)
Expand Down

0 comments on commit ccd6acf

Please sign in to comment.