test(core): rewrite some flaky assertions (#5287)

This commit is contained in:
Peng Xiao
2023-12-13 07:51:59 +00:00
parent ad2c254ca3
commit 2a9a6855f4
7 changed files with 19 additions and 37 deletions

View File

@@ -185,27 +185,8 @@ export async function enableCloudWorkspaceFromShareButton(page: Page) {
const shareMenuButton = page.getByTestId('local-share-menu-button');
await expect(shareMenuButton).toBeVisible();
// FIXME: this is a workaround for the flaky test
// For unknown reasons,
// the online ci test on GitHub is unable to detect the local-share-menu,
// although it works fine in local testing.
// To ensure the tests pass consistently, Ive made the following temporary adjustments.
// {
const maxAttempts = 5;
let attempt = 0;
let menuVisible = false;
while (!menuVisible && attempt < maxAttempts) {
try {
await shareMenuButton.click();
menuVisible = await page.getByTestId('local-share-menu').isVisible();
} catch (e) {
console.error(`Attempt ${attempt + 1} failed: ${e}`);
attempt += 1;
}
}
expect(menuVisible).toBeTruthy();
// }
await shareMenuButton.click();
await expect(page.getByTestId('local-share-menu')).toBeVisible();
await page.getByTestId('share-menu-enable-affine-cloud-button').click();
await page.getByTestId('confirm-enable-affine-cloud-button').click();