diff --git a/app/game-frontend/e2e/auction.spec.ts b/app/game-frontend/e2e/auction.spec.ts index 576afc9..491574b 100644 --- a/app/game-frontend/e2e/auction.spec.ts +++ b/app/game-frontend/e2e/auction.spec.ts @@ -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 => { 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(); diff --git a/app/game-frontend/e2e/nationOffices.spec.ts b/app/game-frontend/e2e/nationOffices.spec.ts index 6a5eb84..3ba9f01 100644 --- a/app/game-frontend/e2e/nationOffices.spec.ts +++ b/app/game-frontend/e2e/nationOffices.spec.ts @@ -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; }; diff --git a/app/game-frontend/e2e/troop.spec.ts b/app/game-frontend/e2e/troop.spec.ts index c94bcb6..cb11f24 100644 --- a/app/game-frontend/e2e/troop.spec.ts +++ b/app/game-frontend/e2e/troop.spec.ts @@ -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; };