Skip to content

Commit 9d5a1cd

Browse files
authored
[tests-only] Reduce smoke test flakiness by waiting for action responses (#6149)
* wait for response when accept/decline shares * wait for more responses
1 parent 35343cf commit 9d5a1cd

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

tests/smoke/support/cta/files/misc.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ export const navigateToFolder = async ({
88
path: string
99
}): Promise<void> => {
1010
const paths = path.split('/')
11-
1211
for (const name of paths) {
13-
await page.click(`[data-test-resource-name="${name}"]`)
12+
const resource = page.locator(`[data-test-resource-name="${name}"]`)
13+
await resource.click()
14+
await page.waitForResponse(
15+
(resp) => resp.url().includes(encodeURIComponent(name)) && resp.status() === 200
16+
)
1417
}
1518
}
1619

@@ -32,7 +35,6 @@ export const resourceExists = async ({
3235
timeout?: number
3336
}): Promise<boolean> => {
3437
let exist = true
35-
3638
await page.waitForSelector(`[data-test-resource-name="${name}"]`, { timeout }).catch((e) => {
3739
if (!(e instanceof errors.TimeoutError)) {
3840
throw e

tests/smoke/support/page/files/allFiles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ export class AllFilesPage {
271271
}
272272
await page.click('button.oc-files-actions-delete-trigger')
273273
await page.click('.oc-modal-body-actions-confirm')
274+
await page.waitForResponse(
275+
(resp) => resp.url().includes(encodeURIComponent(resouceName)) && resp.status() === 204
276+
)
274277

275278
await page.goto(startUrl)
276279
}

tests/smoke/support/page/files/sharedWithMe.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ export class SharedWithMePage {
1414

1515
async acceptShare({ name }: { name: string }): Promise<void> {
1616
const { page } = this.actor
17+
const acceptShareButton = page.locator(
18+
`//*[@data-test-resource-name="${name}"]/ancestor::tr//button[contains(@class, "file-row-share-status-accept")]`
19+
)
1720

18-
await page
19-
.locator(
20-
`//*[@data-test-resource-name="${name}"]/ancestor::tr//button[contains(@class, "file-row-share-status-accept")]`
21-
)
22-
.click()
21+
await acceptShareButton.click()
22+
await page.waitForResponse((resp) => resp.url().includes('shares') && resp.status() === 200)
2323
}
2424

2525
async declineShare({ name }: { name: string }): Promise<void> {
2626
const { page } = this.actor
27+
const declineShareButton = page.locator(
28+
`//*[@data-test-resource-name="${name}"]/ancestor::tr//button[contains(@class, "file-row-share-decline")]`
29+
)
2730

28-
await page
29-
.locator(
30-
`//*[@data-test-resource-name="${name}"]/ancestor::tr//button[contains(@class, "file-row-share-decline")]`
31-
)
32-
.click()
31+
await declineShareButton.click()
32+
await page.waitForResponse((resp) => resp.url().includes('shares') && resp.status() === 200)
3333
}
3434
}

0 commit comments

Comments
 (0)