From a124e114635649afabc817533424300e4d92f1a0 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 15:03:16 +0900 Subject: [PATCH] =?UTF-8?q?test(e2e):=20Service=20Worker=20=EA=B0=B1?= =?UTF-8?q?=EC=8B=A0=20=EC=8B=9C=ED=97=98=EC=9D=84=20=EC=9D=B4=20=EC=A0=9C?= =?UTF-8?q?=ED=92=88=EC=9D=98=20=EB=B9=8C=EB=93=9C=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=98=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit service-worker-update 시험이 두 가지를 템플릿 빌드 기준으로 가정한다. - 빌드 B에서 바꿀 route 화면으로 src/presentation/pages/not-found-page.tsx를 연다. 이 제품에는 없는 파일이라 beforeAll이 ENOENT로 떨어지고, 이 파일의 시험 넷이 전부 돌지 않는다. - 캐시 목록을 dist/assets/의 모든 파일과 비교한다. 템플릿 빌드는 그 폴더가 곧 정적 자산 집합이다. 이 제품은 두 방향으로 다르다. IBM Plex Mono의 .woff 대체 파일은 캐시 대상 확장자가 아니고(SW-RR-03, .woff2만), dist/media/의 SVG는 캐시 대상이다. 바꿀 화면은 같은 방식으로 lazy load되는 TechLog Public not-found 화면이다. 기대하는 캐시 목록은 빌드가 선언한 집합, 즉 생성기의 collectStaticAssets 결과다. route 청크가 사라졌는지 보는 곳은 그대로 dist/assets를 쓴다. 검증: service-worker-update.spec.ts 4개 시험이 chromium·firefox·webkit 모두 통과한다. --- tests/e2e/service-worker-update.spec.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/e2e/service-worker-update.spec.ts b/tests/e2e/service-worker-update.spec.ts index 3d0f2a7..77d2e8b 100644 --- a/tests/e2e/service-worker-update.spec.ts +++ b/tests/e2e/service-worker-update.spec.ts @@ -1,6 +1,7 @@ import { appendFile, readdir, readFile } from "node:fs/promises"; import path from "node:path"; +import { collectStaticAssets } from "../../scripts/generate-service-worker-assets.ts"; import { expect, test, type Page } from "../support/browser/strict-browser-test.ts"; import { prepareServiceWorkerBuilds, @@ -39,8 +40,10 @@ let builds: ServiceWorkerBuilds | undefined; // because they embedded the build ID; since 09-02 they do not, so two builds // of the same source emit the same route chunks. A dynamically imported // module keeps all its exports, so the extra export survives the bundler. +// Template sync (af3d8e6): upstream's not-found page is TechLog's Public one, +// lazy-loaded like upstream's by `tech-log-route-runtime.tsx`. const CHANGED_ROUTE_SOURCE = - "src/presentation/pages/not-found-page.tsx"; + "src/features/tech-log/presentation/public/pages/public-not-found-page.tsx"; test.beforeAll(async () => { test.setTimeout(180_000); @@ -89,6 +92,16 @@ async function hashedAssets(dist: string): Promise { .sort(); } +// Template sync (af3d8e6). Upstream compares the cache with every file under +// assets/, which is its whole static asset set. This product's set differs +// from that folder both ways: IBM Plex Mono's `.woff` fallbacks there are not +// cacheable (SW-RR-03), and `media/` files outside it are. So the expected set +// is the one the build declares, from the generator's own scan. +async function staticAssetSet(dist: string): Promise { + const manifest = await collectStaticAssets(dist, "expected", "expected"); + return manifest.assets.map((asset) => asset.url).sort(); +} + const headerCases = [ { name: "Content-Type: application/javascript", @@ -121,7 +134,7 @@ for (const { name, headers } of headerCases) { return { names, paths }; }); expect(cached.names).toHaveLength(1); - expect(cached.paths.sort()).toEqual(await hashedAssets(dist.a)); + expect(cached.paths.sort()).toEqual(await staticAssetSet(dist.a)); // The server really sent the headers under test. const assets = server.served.filter((response) =>