Chore: CI: Retry opening the go-to-anything dialog on failure (#12481)
This commit is contained in:
parent
b701992524
commit
364b2496d6
@ -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/extendedExpect.js
|
||||||
packages/app-desktop/integration-tests/util/getImageSourceSize.js
|
packages/app-desktop/integration-tests/util/getImageSourceSize.js
|
||||||
packages/app-desktop/integration-tests/util/getMainWindow.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/setDarkMode.js
|
||||||
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
||||||
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -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/extendedExpect.js
|
||||||
packages/app-desktop/integration-tests/util/getImageSourceSize.js
|
packages/app-desktop/integration-tests/util/getImageSourceSize.js
|
||||||
packages/app-desktop/integration-tests/util/getMainWindow.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/setDarkMode.js
|
||||||
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
||||||
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
||||||
|
@ -3,6 +3,7 @@ import { ElectronApplication, expect, Locator, Page } from '@playwright/test';
|
|||||||
import MainScreen from './MainScreen';
|
import MainScreen from './MainScreen';
|
||||||
import activateMainMenuItem from '../util/activateMainMenuItem';
|
import activateMainMenuItem from '../util/activateMainMenuItem';
|
||||||
import { msleep } from '@joplin/utils/time';
|
import { msleep } from '@joplin/utils/time';
|
||||||
|
import retryOnFailure from '../util/retryOnFailure';
|
||||||
|
|
||||||
export default class GoToAnything {
|
export default class GoToAnything {
|
||||||
public readonly containerLocator: Locator;
|
public readonly containerLocator: Locator;
|
||||||
@ -19,9 +20,11 @@ export default class GoToAnything {
|
|||||||
|
|
||||||
public async open(electronApp: ElectronApplication) {
|
public async open(electronApp: ElectronApplication) {
|
||||||
await this.mainScreen.waitFor();
|
await this.mainScreen.waitFor();
|
||||||
await activateMainMenuItem(electronApp, 'Goto Anything...');
|
const openFromMenu = async () => {
|
||||||
|
await activateMainMenuItem(electronApp, 'Goto Anything...');
|
||||||
return this.waitFor();
|
await this.waitFor();
|
||||||
|
};
|
||||||
|
await retryOnFailure(openFromMenu, { maxRetries: 3 });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openLinkToNote(electronApp: ElectronApplication) {
|
public async openLinkToNote(electronApp: ElectronApplication) {
|
||||||
|
@ -2,23 +2,16 @@
|
|||||||
import { ElectronApplication } from '@playwright/test';
|
import { ElectronApplication } from '@playwright/test';
|
||||||
import type { PageFunctionOn } from 'playwright-core/types/structs';
|
import type { PageFunctionOn } from 'playwright-core/types/structs';
|
||||||
import type * as ElectronType from 'electron';
|
import type * as ElectronType from 'electron';
|
||||||
|
import retryOnFailure from './retryOnFailure';
|
||||||
|
|
||||||
const evaluateWithRetry = async <ReturnType, Arg> (
|
const evaluateWithRetry = async <ReturnType, Arg> (
|
||||||
app: ElectronApplication,
|
app: ElectronApplication,
|
||||||
pageFunction: PageFunctionOn<typeof ElectronType, Arg, ReturnType>,
|
pageFunction: PageFunctionOn<typeof ElectronType, Arg, ReturnType>,
|
||||||
arg: Arg,
|
arg: Arg,
|
||||||
) => {
|
) => {
|
||||||
let lastError;
|
await retryOnFailure(async () => {
|
||||||
const maxRetries = 3;
|
return await app.evaluate(pageFunction, arg);
|
||||||
for (let retryIndex = 0; retryIndex < maxRetries; retryIndex ++) {
|
}, { maxRetries: 3 });
|
||||||
try {
|
|
||||||
return await app.evaluate(pageFunction, arg);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('app.evaluate failed:', error, `Retrying... ${retryIndex}/${maxRetries}`);
|
|
||||||
lastError = error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw lastError;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default evaluateWithRetry;
|
export default evaluateWithRetry;
|
||||||
|
@ -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;
|
Loading…
x
Reference in New Issue
Block a user