Test rate-limiting, stories in mock server

This commit is contained in:
Fedor Indutny 2022-09-19 15:08:55 -07:00 committed by GitHub
parent 450051e541
commit f9453c64dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 212 additions and 10 deletions

View file

@ -4,6 +4,11 @@
import type { ElectronApplication, Page } from 'playwright';
import { _electron as electron } from 'playwright';
import type {
IPCRequest as ChallengeRequestType,
IPCResponse as ChallengeResponseType,
} from '../challenge';
export type AppLoadedInfoType = Readonly<{
loadTime: number;
messagesPerSec: number;
@ -57,6 +62,18 @@ export class App {
return this.waitForEvent('conversation:open');
}
public async waitForChallenge(): Promise<ChallengeRequestType> {
return this.waitForEvent('challenge');
}
public async solveChallenge(response: ChallengeResponseType): Promise<void> {
const window = await this.getWindow();
await window.evaluate(
`window.CI.solveChallenge(${JSON.stringify(response)})`
);
}
public async close(): Promise<void> {
await this.app.close();
}