test: accept batched lobby responses
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user