Skip to content

Commit

Permalink
change selector
Browse files Browse the repository at this point in the history
  • Loading branch information
SwikritiT committed Apr 29, 2022
1 parent 72d51cf commit 4db25e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/support/objects/app-files/page/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Public {

async upload({ resources }: { resources: File[] }): Promise<void> {
const startUrl = this.#page.url()
const resourceSelector = `//tbody/tr/td[contains(@class, "oc-pl-rm") and contains(text(), "%s")]`
const resourceSelector = `[data-test-resource-name="%s"]`
await this.#page
.locator('//input[@id="fileUploadInput"]')
.setInputFiles(resources.map((file) => file.path))
Expand Down
13 changes: 9 additions & 4 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,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 @@ -149,10 +149,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 @@ -164,9 +165,13 @@ 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 4db25e8

Please sign in to comment.