Chore: CI: Retry opening the go-to-anything dialog on failure (#12481)

This commit is contained in:
Henry Heino 2025-06-11 23:50:10 -07:00 committed by GitHub
parent b701992524
commit 364b2496d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 14 deletions

View File

@ -542,6 +542,7 @@ packages/app-desktop/integration-tests/util/evaluateWithRetry.js
packages/app-desktop/integration-tests/util/extendedExpect.js
packages/app-desktop/integration-tests/util/getImageSourceSize.js
packages/app-desktop/integration-tests/util/getMainWindow.js
packages/app-desktop/integration-tests/util/retryOnFailure.js
packages/app-desktop/integration-tests/util/setDarkMode.js
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js

1
.gitignore vendored
View File

@ -517,6 +517,7 @@ packages/app-desktop/integration-tests/util/evaluateWithRetry.js
packages/app-desktop/integration-tests/util/extendedExpect.js
packages/app-desktop/integration-tests/util/getImageSourceSize.js
packages/app-desktop/integration-tests/util/getMainWindow.js
packages/app-desktop/integration-tests/util/retryOnFailure.js
packages/app-desktop/integration-tests/util/setDarkMode.js
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js

View File

@ -3,6 +3,7 @@ import { ElectronApplication, expect, Locator, Page } from '@playwright/test';
import MainScreen from './MainScreen';
import activateMainMenuItem from '../util/activateMainMenuItem';
import { msleep } from '@joplin/utils/time';
import retryOnFailure from '../util/retryOnFailure';
export default class GoToAnything {
public readonly containerLocator: Locator;
@ -19,9 +20,11 @@ export default class GoToAnything {
public async open(electronApp: ElectronApplication) {
await this.mainScreen.waitFor();
await activateMainMenuItem(electronApp, 'Goto Anything...');
return this.waitFor();
const openFromMenu = async () => {
await activateMainMenuItem(electronApp, 'Goto Anything...');
await this.waitFor();
};
await retryOnFailure(openFromMenu, { maxRetries: 3 });
}
public async openLinkToNote(electronApp: ElectronApplication) {

View File

@ -2,23 +2,16 @@
import { ElectronApplication } from '@playwright/test';
import type { PageFunctionOn } from 'playwright-core/types/structs';
import type * as ElectronType from 'electron';
import retryOnFailure from './retryOnFailure';
const evaluateWithRetry = async <ReturnType, Arg> (
app: ElectronApplication,
pageFunction: PageFunctionOn<typeof ElectronType, Arg, ReturnType>,
arg: Arg,
) => {
let lastError;
const maxRetries = 3;
for (let retryIndex = 0; retryIndex < maxRetries; retryIndex ++) {
try {
return await app.evaluate(pageFunction, arg);
} catch (error) {
console.error('app.evaluate failed:', error, `Retrying... ${retryIndex}/${maxRetries}`);
lastError = error;
}
}
throw lastError;
await retryOnFailure(async () => {
return await app.evaluate(pageFunction, arg);
}, { maxRetries: 3 });
};
export default evaluateWithRetry;

View File

@ -0,0 +1,20 @@
interface Options {
maxRetries: number;
}
const retryOnFailure = async <T> (callback: ()=> Promise<T>, { maxRetries }: Options): Promise<T> => {
let lastError: Error|null = null;
for (let i = 0; i < maxRetries; i++) {
try {
return await callback();
} catch (error) {
console.error('retry failed:', error, `Retrying... ${i + 1}/${maxRetries}`);
lastError = error;
}
}
throw lastError;
};
export default retryOnFailure;