merge: accept batched lobby responses in E2E
This commit is contained in:
@@ -29,6 +29,13 @@ const operationNames = (route: Route): string[] => {
|
|||||||
const url = new URL(route.request().url());
|
const url = new URL(route.request().url());
|
||||||
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6)).split(',');
|
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> => {
|
const readReferenceImage = async (filename: string): Promise<Buffer> => {
|
||||||
for (const imageRoot of imageRoots) {
|
for (const imageRoot of imageRoots) {
|
||||||
@@ -232,7 +239,7 @@ const installFixture = async (page: Page, state: AuctionFixture) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const gotoAuction = async (page: Page, suffix = 'auction') => {
|
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 page.goto(suffix);
|
||||||
await lobbyResponse;
|
await lobbyResponse;
|
||||||
await expect(page.locator('#container')).toBeVisible();
|
await expect(page.locator('#container')).toBeVisible();
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ const operationName = (route: Route): string => {
|
|||||||
const url = new URL(route.request().url());
|
const url = new URL(route.request().url());
|
||||||
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6));
|
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) =>
|
const fulfillJson = (route: Route, body: unknown) =>
|
||||||
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
|
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 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 page.goto(path);
|
||||||
await lobbyResponse;
|
await lobbyResponse;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ const operationName = (route: Route): string => {
|
|||||||
const url = new URL(route.request().url());
|
const url = new URL(route.request().url());
|
||||||
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6));
|
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) => {
|
const fulfillJson = async (route: Route, body: unknown) => {
|
||||||
await route.fulfill({
|
await route.fulfill({
|
||||||
@@ -106,7 +113,7 @@ const fulfillJson = async (route: Route, body: unknown) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const gotoTroop = async (page: Page) => {
|
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 page.goto('troop');
|
||||||
await lobbyResponse;
|
await lobbyResponse;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user