test: accept batched lobby responses

This commit is contained in:
2026-07-31 17:33:37 +00:00
parent b7a387cdbc
commit d7d47943e9
3 changed files with 24 additions and 3 deletions
+8 -1
View File
@@ -29,6 +29,13 @@ const operationNames = (route: Route): string[] => {
const url = new URL(route.request().url());
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6)).split(',');
};
const responseHasOperation = (url: string, operation: string): boolean => {
const pathname = decodeURIComponent(new URL(url).pathname);
return pathname
.slice(pathname.lastIndexOf('/trpc/') + 6)
.split(',')
.includes(operation);
};
const readReferenceImage = async (filename: string): Promise<Buffer> => {
for (const imageRoot of imageRoots) {
@@ -232,7 +239,7 @@ const installFixture = async (page: Page, state: AuctionFixture) => {
};
const gotoAuction = async (page: Page, suffix = 'auction') => {
const lobbyResponse = page.waitForResponse((response) => response.url().includes('/trpc/lobby.info'));
const lobbyResponse = page.waitForResponse((response) => responseHasOperation(response.url(), 'lobby.info'));
await page.goto(suffix);
await lobbyResponse;
await expect(page.locator('#container')).toBeVisible();
+8 -1
View File
@@ -48,6 +48,13 @@ const operationName = (route: Route): string => {
const url = new URL(route.request().url());
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6));
};
const responseHasOperation = (url: string, operation: string): boolean => {
const pathname = decodeURIComponent(new URL(url).pathname);
return pathname
.slice(pathname.lastIndexOf('/trpc/') + 6)
.split(',')
.includes(operation);
};
const fulfillJson = (route: Route, body: unknown) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
@@ -251,7 +258,7 @@ const installFixture = async (page: Page, state: FixtureState) => {
};
const gotoOffice = async (page: Page, path: 'nation/personnel' | 'nation/finance') => {
const lobbyResponse = page.waitForResponse((response) => response.url().includes('/trpc/lobby.info'));
const lobbyResponse = page.waitForResponse((response) => responseHasOperation(response.url(), 'lobby.info'));
await page.goto(path);
await lobbyResponse;
};
+8 -1
View File
@@ -96,6 +96,13 @@ const operationName = (route: Route): string => {
const url = new URL(route.request().url());
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6));
};
const responseHasOperation = (url: string, operation: string): boolean => {
const pathname = decodeURIComponent(new URL(url).pathname);
return pathname
.slice(pathname.lastIndexOf('/trpc/') + 6)
.split(',')
.includes(operation);
};
const fulfillJson = async (route: Route, body: unknown) => {
await route.fulfill({
@@ -106,7 +113,7 @@ const fulfillJson = async (route: Route, body: unknown) => {
};
const gotoTroop = async (page: Page) => {
const lobbyResponse = page.waitForResponse((response) => response.url().includes('/trpc/lobby.info'));
const lobbyResponse = page.waitForResponse((response) => responseHasOperation(response.url(), 'lobby.info'));
await page.goto('troop');
await lobbyResponse;
};