Skip to content

Commit 8188fd7

Browse files
authored
fix(client): fix crashes, endless loading and lost links found by e2e tests (#389)
2 parents 5e9415c + 3d312a3 commit 8188fd7

42 files changed

Lines changed: 243 additions & 89 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎boardgametracker.client/e2e/auth/redirects.spec.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const protectedPages = [
3434
"/games?view=table",
3535
];
3636

37-
const losesDeepLink = ["/games/import/start", "/sessions/new", "/sessions/new/1", "/sessions/update/1", "/chat"];
37+
const switchedOffPages: Record<string, string> = { "/games/import/start": "/games", "/chat": "/" };
3838

3939
for (const path of protectedPages) {
4040
test(`sends a visitor from ${path} to the login page`, async ({ guestPage: page }) => {
@@ -43,11 +43,7 @@ for (const path of protectedPages) {
4343
await expect(page.getByRole("button", { name: "Sign in" })).toBeVisible();
4444
await expect(page).toHaveURL(/\/login\?/);
4545
await expect(page.getByRole("complementary")).toHaveCount(0);
46-
test.fail(
47-
losesDeepLink.includes(path),
48-
"BUG: a visitor loses the deep link to this page and lands elsewhere after signing in",
49-
);
50-
expect(new URL(page.url()).searchParams.get("redirect")).toBe(path);
46+
expect(new URL(page.url()).searchParams.get("redirect")).toBe(switchedOffPages[path] ?? path);
5147
});
5248
}
5349

‎boardgametracker.client/e2e/compare/compare.spec.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ test("explains when the comparison cannot be loaded", async ({ page }) => {
375375

376376
await page.goto(compareUrl(busiest, rival));
377377

378-
test.fail(true, "BUG: /compare keeps spinning forever when the comparison request fails");
379378
await expect(page.getByText("Couldn't load this page")).toBeVisible({ timeout: 3000 });
380379
});
381380

@@ -384,6 +383,5 @@ test("explains when the players cannot be loaded", async ({ page }) => {
384383

385384
await page.goto("/compare");
386385

387-
test.fail(true, "BUG: /compare says there are not enough players when the player list fails to load");
388386
await expect(page.getByText("Couldn't load this page")).toBeVisible({ timeout: 3000 });
389387
});

‎boardgametracker.client/e2e/game-nights/detail.spec.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,14 @@ test.describe("a finished night as a reader", () => {
402402
});
403403
});
404404

405-
test("shows an error instead of a crash for an address that is no number", async ({ readerPage: page }) => {
406-
await page.goto("/game-nights/abc");
405+
test.describe("an address that is no number", () => {
406+
test.use({ allowedApiStatuses: [401, 404] });
407+
408+
test("shows an error instead of a crash for an address that is no number", async ({ readerPage: page }) => {
409+
await page.goto("/game-nights/abc");
407410

408-
test.fail(true, "BUG: /game-nights/abc throws in the route params and lands on the generic error page");
409-
await expect(page.getByRole("main").getByRole("button", { name: "Game nights" })).toBeVisible({ timeout: 3_000 });
411+
await expect(page.getByRole("main").getByRole("button", { name: "Game nights" })).toBeVisible({ timeout: 3_000 });
412+
});
410413
});
411414

412415
test("ignores an unknown start value in the address", async ({ page }) => {
@@ -427,7 +430,6 @@ test.describe("a night that does not exist", () => {
427430
test("explains it instead of loading forever", async ({ page }) => {
428431
await openMissing(page);
429432

430-
test.fail(true, "BUG: /game-nights/9999 stays on Loading data... forever, the detail page has no not-found state");
431433
await expect(page.getByRole("main").getByText("Loading data...")).toHaveCount(0, { timeout: 5_000 });
432434
});
433435

‎boardgametracker.client/e2e/games/sessions.spec.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ test("keeps a session when deleting is cancelled", async ({ page }) => {
124124
await expect(rowsOf(page)).toHaveCount(played.length);
125125
});
126126

127+
test.describe("a session that does not exist", () => {
128+
test.use({ allowedApiStatuses: [401, 404] });
129+
130+
test("explains it instead of loading forever", async ({ page }) => {
131+
await page.goto("/sessions/update/999999");
132+
133+
await expect(page.getByRole("main").getByRole("heading", { name: "Couldn't load this page" })).toBeVisible();
134+
});
135+
});
136+
127137
test.describe("a game that does not exist", () => {
128138
test.use({ allowedApiStatuses: [401, 404] });
129139

‎boardgametracker.client/e2e/leaderboard/leaderboard.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ test("explains when the leaderboard cannot be loaded", async ({ page }) => {
307307

308308
await page.goto("/leaderboard");
309309

310-
test.fail(true, "BUG: /leaderboard keeps spinning forever when the leaderboard request fails");
311310
await expect(page.getByText("Couldn't load this page")).toBeVisible({ timeout: 3000 });
312311
});
313312

‎boardgametracker.client/e2e/loans/loans.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ test.describe("other data", () => {
383383
await page.route("**/api/loans", (route) => route.fulfill({ status: 400, json: {} }));
384384
await page.goto("/loans");
385385

386-
test.fail(true, "BUG: a failed /api/loans request shows the empty page 'No loans yet' instead of an error");
387386
await expect(page.getByRole("main").getByRole("button", { name: "Try again" })).toBeVisible({ timeout: 3_000 });
388387
});
389388
});

‎boardgametracker.client/e2e/locations/locations.spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ test.describe("not found", () => {
244244
test(`treats the id ${id} as not found`, async ({ page }) => {
245245
await page.goto(`/locations/${id}`);
246246

247-
test.fail(true, "BUG: an invalid location id shows the generic error page instead of 'Location not found'");
248247
await expect(page.getByRole("heading", { name: "Location not found", level: 1 })).toBeVisible({
249248
timeout: 3_000,
250249
});

‎boardgametracker.client/e2e/phone/dialogs.spec.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,6 @@ test("every action of the last user can be reached", async ({ page }) => {
292292
.last()
293293
.click();
294294

295-
test.fail(
296-
true,
297-
"BUG: the actions menu of the last row opens downward behind the bottom bar and Delete cannot be reached",
298-
);
299295
await page.getByRole("menuitem").last().click({ trial: true, timeout: 3000 });
300296
});
301297

‎boardgametracker.client/e2e/phone/layout.spec.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ for (const { path, heading, allowed404, content } of pages) {
282282

283283
await expect(page.getByRole("heading", { name: heading, level: 1, exact: true })).toBeVisible();
284284
await expectContentClearsBars(page);
285-
test.fixme(
286-
path === `/players/${kermit}`,
287-
"BUG: in about a third of the loads the Head-to-head and Most played cards make the player page 4px too wide",
288-
);
289285
await expectNoSidewaysScroll(page);
290286
});
291287

@@ -385,7 +381,6 @@ test("reloading the edit page of a session opens the form", async ({ page }) =>
385381
await page.setViewportSize(phone);
386382
await page.goto("/sessions/update/1");
387383

388-
test.fail(true, "BUG: a reload of the session edit page shows the error page because the loader runs before auth");
389384
await expect(page.getByRole("heading", { name: "Something went wrong" })).toHaveCount(0);
390385
await expect(page.getByRole("spinbutton", { name: "Duration" })).toBeVisible({ timeout: 3000 });
391386
});

‎boardgametracker.client/e2e/phone/manage.spec.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ test("a long game title in most played keeps the player page on a phone", async
237237
await settled(page);
238238
await expect(page.getByRole("heading", { name: "Most played games", level: 2 })).toBeVisible();
239239

240-
test.fail(
241-
true,
242-
"BUG: a long title in Most played widens the grid of the player page, so the page scrolls sideways",
243-
);
244240
await expectNoSidewaysScroll(page);
245241
} finally {
246242
await api.tidy(`/api/session/${session.id}`);

0 commit comments

Comments
 (0)