Add more timeouts, retries in mock tests

This commit is contained in:
Fedor Indutny 2023-09-19 19:02:37 +02:00 committed by GitHub
parent c25867c737
commit a1207aa136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 31 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import type {
IPCResponse as ChallengeResponseType,
} from '../challenge';
import type { ReceiptType } from '../types/Receipt';
import { SECOND } from '../util/durations';
export type AppLoadedInfoType = Readonly<{
loadTime: number;
@ -40,6 +41,8 @@ export type AppOptionsType = Readonly<{
config: string;
}>;
const WAIT_FOR_EVENT_TIMEOUT = 30 * SECOND;
export class App extends EventEmitter {
private privApp: ElectronApplication | undefined;
@ -152,11 +155,15 @@ export class App extends EventEmitter {
// Private
//
private async waitForEvent<T>(event: string): Promise<T> {
private async waitForEvent<T>(
event: string,
timeout = WAIT_FOR_EVENT_TIMEOUT
): Promise<T> {
const window = await this.getWindow();
const result = await window.evaluate(
`window.SignalCI.waitForEvent(${JSON.stringify(event)})`
`window.SignalCI.waitForEvent(${JSON.stringify(event)})`,
{ timeout }
);
return result as T;