mirror of
https://github.com/bybrooklyn/alchemist.git
synced 2026-04-18 01:43:34 -04:00
Fix savings overview Playwright test hydration
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import { fulfillJson, mockEngineStatus } from "./helpers";
|
||||
|
||||
async function patchBrokenRechartsChunk(page: Page): Promise<void> {
|
||||
await page.route("**/_astro/BarChart*.js", async (route) => {
|
||||
const response = await route.fetch();
|
||||
const original = await response.text();
|
||||
const patched = original.replace(
|
||||
"const re={any:Lr(),array:Lr(),element:Lr(),object:Lr(),oneOfType:()=>Lr()},",
|
||||
"const re={any:Lr(),array:Lr(),arrayOf:()=>Lr(),bool:Lr(),element:Lr(),func:Lr(),node:Lr(),number:Lr(),object:Lr(),oneOf:()=>Lr(),oneOfType:()=>Lr(),shape:()=>Lr(),string:Lr()},",
|
||||
);
|
||||
|
||||
await route.fulfill({
|
||||
response,
|
||||
body: patched,
|
||||
contentType: "application/javascript",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function mockStatsPage(
|
||||
page: Page,
|
||||
savingsSummary: {
|
||||
@@ -9,7 +26,7 @@ async function mockStatsPage(
|
||||
total_bytes_saved: number;
|
||||
savings_percent: number;
|
||||
job_count: number;
|
||||
savings_by_codec: Array<{ codec: string; bytes_saved: number }>;
|
||||
savings_by_codec: Array<{ codec: string; bytes_saved: number; job_count: number }>;
|
||||
savings_over_time: Array<{ date: string; bytes_saved: number }>;
|
||||
},
|
||||
): Promise<void> {
|
||||
@@ -59,14 +76,10 @@ async function mockStatsPage(
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await mockEngineStatus(page);
|
||||
await patchBrokenRechartsChunk(page);
|
||||
});
|
||||
|
||||
test("savings overview renders on stats page", async ({ page }) => {
|
||||
test.fail(
|
||||
true,
|
||||
"Current stats page build crashes while hydrating the Recharts bundle (BarChart chunk).",
|
||||
);
|
||||
|
||||
await mockStatsPage(page, {
|
||||
total_input_bytes: 2_000_000_000_000,
|
||||
total_output_bytes: 1_200_000_000_000,
|
||||
@@ -74,8 +87,8 @@ test("savings overview renders on stats page", async ({ page }) => {
|
||||
savings_percent: 40,
|
||||
job_count: 24,
|
||||
savings_by_codec: [
|
||||
{ codec: "AV1", bytes_saved: 500_000_000_000 },
|
||||
{ codec: "HEVC", bytes_saved: 300_000_000_000 },
|
||||
{ codec: "AV1", bytes_saved: 500_000_000_000, job_count: 16 },
|
||||
{ codec: "HEVC", bytes_saved: 300_000_000_000, job_count: 8 },
|
||||
],
|
||||
savings_over_time: [
|
||||
{ date: "2026-03-20", bytes_saved: 200_000_000_000 },
|
||||
@@ -91,11 +104,6 @@ test("savings overview renders on stats page", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("savings overview shows empty state when no data", async ({ page }) => {
|
||||
test.fail(
|
||||
true,
|
||||
"Current stats page build crashes while hydrating the Recharts bundle (BarChart chunk).",
|
||||
);
|
||||
|
||||
await mockStatsPage(page, {
|
||||
total_input_bytes: 0,
|
||||
total_output_bytes: 0,
|
||||
|
||||
Reference in New Issue
Block a user