fix: 브라우저 게이트를 초록으로(Studio mock·화면 도착 처리·부팅 실패 청크·visual 기준·WebKit 경합) #8

Merged
donghyeon.kang merged 16 commits from fix/browser-gates-green-v2 into main 2026-11-12 11:28:36 +00:00
151 changed files with 1099 additions and 68 deletions
@@ -11,6 +11,8 @@ import { createHttpStudioAssetGateway } from "./http/http-studio-asset-gateway.t
import { createHttpStudioGateway } from "./http/http-studio-gateway.ts";
import type { CsrfTokenProvider } from "./http/studio-session-csrf.ts";
import { createMockStudioAssetGateway } from "./mock/mock-studio-asset-gateway.ts";
import { createMockManagementGateway } from "./mock/mock-management-gateway.ts";
import { createMockStudioState } from "./mock/mock-state.ts";
import { createMockStudioGateway } from "./mock/mock-studio-gateway.ts";
import { createHttpManagementGateway } from "./http/http-management-gateway.ts";
import { createHttpPublicContentGateway } from "./http/http-public-content-gateway.ts";
@@ -66,10 +68,6 @@ export function createTechLogFeatureInstalledInput(
}),
});
const createStudioGateway = () =>
context.studioSource === "MOCK"
? createMockStudioGateway({ assets: mockAssets })
: createHttpStudioGateway({ http });
// The public read source switches independently of Studio: the two are
// different services, and the combination that matters today is an authoring
@@ -79,15 +77,26 @@ export function createTechLogFeatureInstalledInput(
? publicContentQueries
: createHttpPublicContentGateway({ http });
const createManagementGateway = () =>
createHttpManagementGateway({ http });
const createStudioApplication = () =>
createTechLogStudioApplication({
studio: createStudioGateway(),
// MOCK: one in-memory Studio state per application, shared by the document
// and management gateways, so deleting a draft from the management surface
// also takes it out of the document list. Management used to be HTTP even
// here, and a MOCK build (local development, the e2e and visual builds)
// asked an API that is not there for its topics and projects.
const createStudioApplication = () => {
if (context.studioSource === "MOCK") {
const state = createMockStudioState();
return createTechLogStudioApplication({
studio: createMockStudioGateway({ assets: mockAssets, state }),
assets: createStudioAssetGateway(),
management: createMockManagementGateway({ studioState: state }),
});
}
return createTechLogStudioApplication({
studio: createHttpStudioGateway({ http }),
assets: createStudioAssetGateway(),
management: createManagementGateway(),
management: createHttpManagementGateway({ http }),
});
};
const input: TechLogFeatureInput = Object.freeze({
publicContent,
@@ -0,0 +1,588 @@
import type {
DeletableDocumentKind,
ManagementGateway,
} from "../../application/ports/management-gateway.ts";
import { ManagementGatewayError } from "../../application/ports/management-gateway-error.ts";
import type {
IdempotentOptions,
RequestOptions,
} from "../../application/ports/studio-gateway.ts";
import type {
CreateDraftResponse,
DecisionResponse,
HomeFocusResponse,
ProjectActivityResponse,
ProjectEditResponse,
ProjectIndexItem,
PublishResponse,
ReleaseEditResponse,
ReleaseIndexItem,
TopicEdit,
TopicVariantEdit,
} from "../../contracts/management/contract.ts";
import type { WorkingCopy } from "../../contracts/studio/contract.ts";
import {
projects as staticProjects,
releases as staticReleases,
} from "../static/public-content.ts";
import { FIXTURE_IDS, MOCK_CATALOG } from "./fixtures.ts";
import { createMockStudioState, type MockStudioState } from "./mock-state.ts";
/**
* The MOCK `studioSource` half of the management surface (topics, projects,
* releases, home focus, document deletion).
*
* `create-tech-log-feature-input.ts` used to hand the HTTP gateway to Studio
* whatever the source was, so a MOCK build — local development, the e2e and
* visual builds — sent `/api/v1/studio/session` to an API that is not there
* as soon as the dashboard or an editor asked for its topics. Like the mock
* document gateway, this keeps everything in memory for the life of one
* Studio application and reports failures with the codes the backend uses.
*/
export type MockManagementDependencies = {
clock: { now(): Date };
idGenerator: { next(): string };
/**
* The working copies `deleteDocument` removes and `listQuestions` lists.
* `create-tech-log-feature-input.ts` passes the state of the mock document
* gateway it builds next to this one, so a deleted draft leaves the
* document list too. Defaults to a fresh seed.
*/
studioState: MockStudioState;
};
export const DEFAULT_MANAGEMENT_MOCK_NOW = "2026-08-14T01:00:00.000Z";
const HOME_FOCUS_ID = "99999999-0000-4000-8000-000000000001";
const RELEASE_0_1_0 = "99999999-0000-4000-8000-000000000101";
const PROJECT_IDS: Readonly<Record<string, string>> = {
"backend-skeleton": FIXTURE_IDS.projectBackend,
"auth-lab": FIXTURE_IDS.projectAuth,
};
const DOCUMENT_KIND: Readonly<Record<DeletableDocumentKind, string>> = {
CASE: "deleteCaseDraft",
REFERENCE: "deleteReferenceDraft",
QUESTION: "deleteQuestion",
CONCEPT: "deleteConceptDraft",
SETUP: "deleteSetupDraft",
};
const clone = <T>(value: T): T => structuredClone(value);
function problem(operationId: string, code: string, detail: string) {
return new ManagementGatewayError(operationId, code, detail);
}
function published(path: string, at: string, version: number) {
return {
state: "ACTIVE" as const,
publishedSourceVersion: version,
hasUnpublishedChanges: false,
canonicalPath: path,
publishedAt: at,
};
}
const NEVER_PUBLISHED = Object.freeze({
state: "NEVER_PUBLISHED" as const,
hasUnpublishedChanges: false,
});
function seedTopics(): TopicEdit[] {
return MOCK_CATALOG.filter((entry) => entry.type === "TOPIC").map((entry) => ({
id: entry.id,
version: 1,
name: entry.label,
slug: entry.publicPath!.slice("/topics/".length),
status: "ACTIVE",
}));
}
function seedProjects(topics: readonly TopicEdit[], updatedAt: string): ProjectEditResponse[] {
const topicIdBySlug = new Map(topics.map((topic) => [topic.slug, topic.id!]));
return staticProjects.flatMap((project) => {
const id = PROJECT_IDS[project.slug];
if (!id) return [];
return [
{
id,
version: 1,
name: project.title,
slug: project.slug,
oneLinePurpose: project.summary,
thesis: project.thesis,
purposeMarkdown: project.summary,
boundaryMarkdown: "",
phase: project.stage,
currentObjective: project.currentGoal,
nextStep: project.nextStep,
technologyLabels: project.topics.map((topic) => topic.name),
workflowStatus: "PUBLISHED",
targetVisibility: "PUBLIC",
publication: published(`/projects/${project.slug}`, updatedAt, 1),
updatedAt,
topicIds: project.topics.flatMap((topic) => {
const topicId = topicIdBySlug.get(topic.slug);
return topicId ? [topicId] : [];
}),
},
];
});
}
function seedReleases(): ReleaseEditResponse[] {
return staticReleases.map((release, index) => ({
id: index === 0 ? RELEASE_0_1_0 : `99999999-0000-4000-8000-${String(101 + index).padStart(12, "0")}`,
version: 1,
expectedVersion: 1,
versionLabel: release.version,
title: release.title,
summary: release.summary,
releasedOn: release.publishedAt.slice(0, 10),
changeTypes: ["FEATURE"],
changesMarkdown: release.changes.map((line) => `- ${line}`).join("\n"),
reasonMarkdown: release.reasons.map((line) => `- ${line}`).join("\n"),
userImpactMarkdown: release.impacts.map((line) => `- ${line}`).join("\n"),
verificationMarkdown: "",
workflowStatus: "PUBLISHED",
publication: published(release.path, release.publishedAt, 1),
}));
}
function page<T>(operationId: string, items: readonly T[], pageNumber = 0, size = 20) {
if (!Number.isInteger(pageNumber) || pageNumber < 0 || !Number.isInteger(size) || size < 1 || size > 100) {
throw problem(operationId, "REQUEST_VALIDATION_FAILED", "page must be 0 or more and size 1-100.");
}
const totalElements = items.length;
const totalPages = Math.ceil(totalElements / size);
return {
items: clone(items.slice(pageNumber * size, pageNumber * size + size)),
page: {
number: pageNumber,
size,
totalElements,
totalPages,
hasPrevious: pageNumber > 0,
hasNext: pageNumber + 1 < totalPages,
},
};
}
export function createMockManagementGateway(
supplied: Partial<MockManagementDependencies> = {},
): ManagementGateway {
let nextId = 9000;
const clock = supplied.clock ?? { now: () => new Date(DEFAULT_MANAGEMENT_MOCK_NOW) };
const ids = supplied.idGenerator ?? {
next: () => `bbbbbbbb-bbbb-4bbb-8bbb-${String(nextId++).padStart(12, "0")}`,
};
const studio = supplied.studioState ?? createMockStudioState();
const now = () => clock.now().toISOString();
const topics = new Map(seedTopics().map((topic) => [topic.id!, topic]));
const variants = new Map<string, TopicVariantEdit[]>();
const projects = new Map(seedProjects([...topics.values()], now()).map((project) => [project.id, project]));
const activities = new Map<string, ProjectActivityResponse[]>();
const decisions = new Map<string, DecisionResponse[]>();
const releases = new Map(seedReleases().map((release) => [release.id, release]));
let homeFocus: HomeFocusResponse = {
id: HOME_FOCUS_ID,
version: 1,
defaultType: "CURRENT_WORK",
currentProjectId: FIXTURE_IDS.projectBackend,
openQuestionId: FIXTURE_IDS.edgeTokenQuestion,
};
// The same key replays the first outcome, as the backend's idempotency
// store does; a retried create must not make a second draft.
const replay = new Map<string, unknown>();
async function boundary(options?: RequestOptions) {
options?.signal?.throwIfAborted();
await Promise.resolve();
options?.signal?.throwIfAborted();
}
async function read<T>(options: RequestOptions | undefined, run: () => T): Promise<T> {
await boundary(options);
return clone(run());
}
async function command<T>(options: IdempotentOptions, run: () => T): Promise<T> {
await boundary(options);
if (replay.has(options.idempotencyKey)) return clone(replay.get(options.idempotencyKey) as T);
const value = run();
replay.set(options.idempotencyKey, clone(value));
return clone(value);
}
function found<T>(map: ReadonlyMap<string, T>, id: string, operationId: string, code: string): T {
const value = map.get(id);
if (value === undefined) throw problem(operationId, code, `${id} does not exist.`);
return value;
}
function versionOf(current: number | undefined, expected: number | undefined, operationId: string) {
if (expected !== current) {
throw problem(operationId, "VERSION_CONFLICT", `Expected version ${String(expected)}, current ${String(current)}.`);
}
}
function questionItems() {
return [...studio.documents.values()]
.filter((document: WorkingCopy) => document.kind === "QUESTION")
.map((document: WorkingCopy) => {
const project = document.projectId ? projects.get(document.projectId) : undefined;
const publication = studio.publications.get(document.id);
return {
id: document.id,
question: document.title,
status: "OPEN",
targetVisibility: "PUBLIC",
...(project?.slug
? { primaryProject: { name: project.name, slug: project.slug, path: `/projects/${project.slug}` } }
: {}),
updatedAt: document.updatedAt,
version: document.version,
publication:
publication?.status === "PUBLISHED"
? published(publication.publicPath, document.updatedAt, publication.publishedVersion)
: NEVER_PUBLISHED,
};
});
}
function projectIndexItem(project: ProjectEditResponse): ProjectIndexItem {
return {
id: project.id,
name: project.name,
...(project.slug ? { slug: project.slug } : {}),
topicIds: project.topicIds ?? [],
phase: project.phase,
workflowStatus: project.workflowStatus,
targetVisibility: project.targetVisibility,
...(project.currentObjective ? { currentObjective: project.currentObjective } : {}),
...(project.nextStep ? { nextStep: project.nextStep } : {}),
updatedAt: project.updatedAt,
version: project.version,
publication: project.publication,
};
}
function releaseIndexItem(release: ReleaseEditResponse): ReleaseIndexItem {
return {
id: release.id,
versionLabel: release.versionLabel,
title: release.title,
...(release.releasedOn ? { releasedOn: release.releasedOn } : {}),
workflowStatus: release.workflowStatus,
updatedAt: now(),
version: release.version,
publication: release.publication,
};
}
function draft(): CreateDraftResponse {
return { id: ids.next(), status: "DRAFT", version: 1, createdAt: now() };
}
return Object.freeze({
listTopics: (options) => read(options, () => [...topics.values()]),
createTopic: (input, options) =>
command(options, () => {
const topic = { ...input, id: ids.next(), version: 1, status: input.status ?? "ACTIVE" };
delete topic.expectedVersion;
topics.set(topic.id, topic);
return topic;
}),
updateTopic: (id, body, options) =>
command(options, () => {
const current = found(topics, id, "updateTopic", "TOPIC_NOT_FOUND");
versionOf(current.version, body.expectedVersion, "updateTopic");
const next = { ...body, id, version: current.version! + 1 };
delete next.expectedVersion;
topics.set(id, next);
return next;
}),
deleteTopic: (id, expectedVersion, options) =>
command(options, () => {
const current = found(topics, id, "deleteTopic", "TOPIC_NOT_FOUND");
versionOf(current.version, expectedVersion, "deleteTopic");
topics.delete(id);
variants.delete(id);
}),
listTopicVariants: (topicId, options) =>
read(options, () => {
found(topics, topicId, "listTopicVariants", "TOPIC_NOT_FOUND");
return variants.get(topicId) ?? [];
}),
createTopicVariant: (topicId, body, options) =>
command(options, () => {
found(topics, topicId, "createTopicVariant", "TOPIC_NOT_FOUND");
const variant = { ...body, id: ids.next(), version: 1 };
delete variant.expectedVersion;
variants.set(topicId, [...(variants.get(topicId) ?? []), variant]);
return variant;
}),
updateTopicVariant: (topicId, variantId, body, options) =>
command(options, () => {
const list = variants.get(topicId) ?? [];
const current = list.find((variant) => variant.id === variantId);
if (!current) throw problem("updateTopicVariant", "TOPIC_NOT_FOUND", `${variantId} does not exist.`);
versionOf(current.version, body.expectedVersion, "updateTopicVariant");
const next = { ...body, id: variantId, version: current.version! + 1 };
delete next.expectedVersion;
variants.set(topicId, list.map((variant) => (variant.id === variantId ? next : variant)));
return next;
}),
deleteTopicVariant: (topicId, variantId, expectedVersion, options) =>
command(options, () => {
const list = variants.get(topicId) ?? [];
const current = list.find((variant) => variant.id === variantId);
if (!current) throw problem("deleteTopicVariant", "TOPIC_NOT_FOUND", `${variantId} does not exist.`);
versionOf(current.version, expectedVersion, "deleteTopicVariant");
variants.set(topicId, list.filter((variant) => variant.id !== variantId));
}),
listProjects: (pageNumber, size, options) =>
read(options, () => page("listStudioProjects", [...projects.values()].map(projectIndexItem), pageNumber, size)),
listQuestions: (pageNumber, size, options) =>
read(options, () => page("listStudioQuestions", questionItems(), pageNumber, size)),
listProjectDecisions: (projectId, options) =>
read(options, () => {
found(projects, projectId, "listProjectDecisions", "PROJECT_NOT_FOUND");
return decisions.get(projectId) ?? [];
}),
getProject: (id, options) =>
read(options, () => found(projects, id, "getProjectForEdit", "PROJECT_NOT_FOUND")),
createProject: (title, options) =>
command(options, () => {
const created = draft();
projects.set(created.id, {
id: created.id,
version: created.version,
name: title,
phase: "DESIGN",
workflowStatus: "DRAFT",
targetVisibility: "PRIVATE",
publication: NEVER_PUBLISHED,
updatedAt: created.createdAt,
});
return created;
}),
updateProject: (id, body, options) =>
command(options, () => {
const current = found(projects, id, "updateProject", "PROJECT_NOT_FOUND");
versionOf(current.version, body.expectedVersion, "updateProject");
const { expectedVersion, ...fields } = body;
void expectedVersion;
const next: ProjectEditResponse = {
...current,
...fields,
version: current.version + 1,
updatedAt: now(),
publication:
current.publication.state === "ACTIVE"
? { ...current.publication, hasUnpublishedChanges: true }
: current.publication,
};
projects.set(id, next);
return next;
}),
deleteProject: (id, expectedVersion, options) =>
command(options, () => {
const current = found(projects, id, "deleteProject", "PROJECT_NOT_FOUND");
versionOf(current.version, expectedVersion, "deleteProject");
if (current.publication.state === "ACTIVE") {
throw problem("deleteProject", "CONFLICT", "A published project is unpublished before it is deleted.");
}
projects.delete(id);
activities.delete(id);
decisions.delete(id);
}),
publishProject: (id, expectedVersion, visibility, options) =>
command(options, (): PublishResponse => {
const current = found(projects, id, "publishProject", "PROJECT_NOT_FOUND");
versionOf(current.version, expectedVersion, "publishProject");
const path = `/projects/${current.slug ?? current.id}`;
const at = now();
const version = current.version + 1;
projects.set(id, {
...current,
version,
workflowStatus: "PUBLISHED",
targetVisibility: visibility ?? "PUBLIC",
publication: published(path, at, version),
updatedAt: at,
});
return { id, status: "PUBLISHED", visibility: visibility ?? "PUBLIC", canonicalPath: path, publishedAt: at, version };
}),
unpublishProject: (id, expectedVersion, options) =>
command(options, () => {
const current = found(projects, id, "unpublishProject", "PROJECT_NOT_FOUND");
versionOf(current.version, expectedVersion, "unpublishProject");
const next: ProjectEditResponse = {
...current,
version: current.version + 1,
workflowStatus: "DRAFT",
publication: { ...current.publication, state: "WITHDRAWN" },
updatedAt: now(),
};
projects.set(id, next);
return next;
}),
listProjectActivities: (id, options) =>
read(options, () => {
found(projects, id, "listProjectActivities", "PROJECT_NOT_FOUND");
return activities.get(id) ?? [];
}),
createProjectActivity: (id, body, options) =>
command(options, () => {
const project = found(projects, id, "createProjectActivity", "PROJECT_NOT_FOUND");
versionOf(project.version, body.expectedProjectVersion, "createProjectActivity");
const { expectedProjectVersion, ...fields } = body;
void expectedProjectVersion;
const activity: ProjectActivityResponse = { ...fields, id: ids.next(), projectId: id, origin: "MANUAL", version: 1 };
activities.set(id, [...(activities.get(id) ?? []), activity]);
return activity;
}),
updateProjectActivity: (id, activityId, body, options) =>
command(options, () => {
const list = activities.get(id) ?? [];
const current = list.find((activity) => activity.id === activityId);
if (!current) throw problem("updateProjectActivity", "PROJECT_NOT_FOUND", `${activityId} does not exist.`);
versionOf(current.version, body.expectedVersion, "updateProjectActivity");
const { expectedVersion, ...fields } = body;
void expectedVersion;
const next = { ...current, ...fields, version: current.version + 1 };
activities.set(id, list.map((activity) => (activity.id === activityId ? next : activity)));
return next;
}),
deleteProjectActivity: (id, activityId, expectedVersion, options) =>
command(options, () => {
const list = activities.get(id) ?? [];
const current = list.find((activity) => activity.id === activityId);
if (!current) throw problem("deleteProjectActivity", "PROJECT_NOT_FOUND", `${activityId} does not exist.`);
versionOf(current.version, expectedVersion, "deleteProjectActivity");
activities.set(id, list.filter((activity) => activity.id !== activityId));
}),
getHomeFocus: (options) => read(options, () => homeFocus),
updateHomeFocus: (body, options) =>
command(options, () => {
versionOf(homeFocus.version, body.expectedVersion, "updateHomeFocus");
const { expectedVersion, ...fields } = body;
void expectedVersion;
homeFocus = { id: homeFocus.id, ...fields, version: homeFocus.version + 1 };
return homeFocus;
}),
listReleases: (pageNumber, size, options) =>
read(options, () => page("listStudioReleases", [...releases.values()].map(releaseIndexItem), pageNumber, size)),
getRelease: (id, options) =>
read(options, () => found(releases, id, "getReleaseForEdit", "RELEASE_NOT_FOUND")),
createRelease: (title, options) =>
command(options, () => {
const created = draft();
releases.set(created.id, {
id: created.id,
version: created.version,
expectedVersion: created.version,
versionLabel: "",
title,
summary: "",
changeTypes: [],
changesMarkdown: "",
verificationMarkdown: "",
workflowStatus: "DRAFT",
publication: NEVER_PUBLISHED,
});
return created;
}),
updateRelease: (id, body, options) =>
command(options, () => {
const current = found(releases, id, "updateRelease", "RELEASE_NOT_FOUND");
versionOf(current.version, body.expectedVersion, "updateRelease");
const version = current.version + 1;
const next: ReleaseEditResponse = {
...current,
...body,
expectedVersion: version,
version,
publication:
current.publication.state === "ACTIVE"
? { ...current.publication, hasUnpublishedChanges: true }
: current.publication,
};
releases.set(id, next);
return next;
}),
deleteRelease: (id, expectedVersion, options) =>
command(options, () => {
const current = found(releases, id, "deleteRelease", "RELEASE_NOT_FOUND");
versionOf(current.version, expectedVersion, "deleteRelease");
if (current.publication.state === "ACTIVE") {
throw problem("deleteRelease", "CONFLICT", "A published release is archived, not deleted.");
}
releases.delete(id);
}),
publishRelease: (id, expectedVersion, options) =>
command(options, (): PublishResponse => {
const current = found(releases, id, "publishRelease", "RELEASE_NOT_FOUND");
versionOf(current.version, expectedVersion, "publishRelease");
const path = `/releases/${current.versionLabel || current.id}`;
const at = now();
const version = current.version + 1;
releases.set(id, {
...current,
version,
expectedVersion: version,
workflowStatus: "PUBLISHED",
publication: published(path, at, version),
});
return { id, status: "PUBLISHED", visibility: "PUBLIC", canonicalPath: path, publishedAt: at, version };
}),
archiveRelease: (id, expectedVersion, options) =>
command(options, () => {
const current = found(releases, id, "archiveRelease", "RELEASE_NOT_FOUND");
versionOf(current.version, expectedVersion, "archiveRelease");
const version = current.version + 1;
const next: ReleaseEditResponse = {
...current,
version,
expectedVersion: version,
workflowStatus: "ARCHIVED",
publication: { ...current.publication, state: "WITHDRAWN" },
};
releases.set(id, next);
return next;
}),
deleteDocument: (kind, id, expectedVersion, options) =>
command(options, () => {
const operationId = DOCUMENT_KIND[kind];
const document = studio.documents.get(id);
if (!document || document.kind !== kind) {
throw problem(operationId, "DOCUMENT_NOT_FOUND", `${id} does not exist.`);
}
versionOf(document.version, expectedVersion, operationId);
if (studio.publications.get(id)?.status === "PUBLISHED") {
throw problem(operationId, "CONFLICT", "A published document is unpublished before it is deleted.");
}
studio.documents.delete(id);
studio.validations.delete(id);
studio.previews.delete(id);
}),
deleteDecision: (projectId, decisionId, expectedVersion, options) =>
command(options, () => {
const list = decisions.get(projectId) ?? [];
const current = list.find((decision) => decision.id === decisionId);
if (!current) throw problem("deleteDecision", "DECISION_NOT_FOUND", `${decisionId} does not exist.`);
versionOf(current.version, expectedVersion, "deleteDecision");
decisions.set(projectId, list.filter((decision) => decision.id !== decisionId));
}),
});
}
@@ -39,6 +39,13 @@ export type MockStudioDependencies = {
* seeing exactly today's behavior.
*/
assets: ReadonlyMap<string, Asset>;
/**
* The documents, validations, previews and publications this gateway
* serves. `create-tech-log-feature-input.ts` shares one with the mock
* management gateway, whose `deleteDocument` removes drafts from it.
* Defaults to a fresh seed per gateway, as before.
*/
state?: MockStudioState;
};
export const DEFAULT_STUDIO_MOCK_NOW = "2026-08-14T01:00:00.000Z";
@@ -136,7 +143,7 @@ export function createMockStudioGateway(supplied: Partial<MockStudioDependencies
const assets = supplied.assets ?? new Map<string, Asset>();
const fallback = defaults(assets);
const dependencies: MockStudioDependencies = { clock: supplied.clock ?? fallback.clock, idGenerator: supplied.idGenerator ?? fallback.idGenerator, dependencyRevision: supplied.dependencyRevision ?? fallback.dependencyRevision, assets };
const state: MockStudioState = createMockStudioState();
const state: MockStudioState = supplied.state ?? createMockStudioState();
async function boundary(options?: RequestOptions) {
options?.signal?.throwIfAborted(); await Promise.resolve(); options?.signal?.throwIfAborted();
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
import { publicSiteConfig } from "../../contracts/public-site-config.ts";
import { SiteHeader } from "./components/site-header.tsx";
import { useRouteArrival } from "./use-route-arrival.ts";
import { TechLogMessage } from "../tech-log-message.tsx";
type PublicShellProps = {
@@ -11,6 +12,7 @@ type PublicShellProps = {
};
export function PublicShell({ children, currentPath }: PublicShellProps) {
useRouteArrival();
return (
<div className="site-frame">
<a className="skip-link" href="#main-content">
@@ -0,0 +1,154 @@
import { useEffect, useRef } from "react";
import { useLocation, useNavigationType } from "react-router-dom";
/**
* What a Public page does when the reader arrives on it: focus, hash target
* and, on back/forward, the scroll position the reader left it at.
*
* The template does this with its router (focus `#main-content`) and its
* `PageHeader` (move focus to the h1, or to the hash target). TechLog's Public
* pages draw their own headings and fill in after their data arrives, so
* nothing did any of it: after a navigation focus stayed on the link that was
* clicked (or on a link inside the closed mobile menu), a link with `#section`
* opened at the top, and Back opened at the top because the browser restores
* the scroll before the page it returns to has drawn.
*
* - On a new path, once the page has drawn (an h1 in `#main-content`, nothing
* `aria-busy`): scroll the hash target into view, then focus it if it takes
* focus, otherwise the h1 (tabindex -1 and `data-route-heading`, so no
* focus ring, as PageHeader's). Focus never scrolls. On the first load, focus moves only if nothing has it yet.
* - Back/forward: the position saved for that history entry is restored once
* the page is tall enough for it. The browser's own restoration is off while
* the Public shell is mounted, since it runs before the page exists. A reload
* keeps the browser's restoration: the mode is set after the page mounts.
* - A query-only change or an in-page `#` link is not an arrival.
*
* jsdom implements no scrolling or layout, so, like the router's scroll reset,
* this does nothing there.
*/
const SETTLE_TIMEOUT_MS = 5_000;
/** Scroll position per history entry (`location.key`), for this tab's session. */
const positions = new Map<string, number>();
const inBrowser = () =>
typeof navigator !== "undefined" &&
!navigator.userAgent.toLowerCase().includes("jsdom");
function hashTarget(hash: string): HTMLElement | null {
if (hash.length < 2) return null;
try {
return document.getElementById(decodeURIComponent(hash.slice(1)));
} catch {
return null;
}
}
function pageHeading(): HTMLElement | null {
return document.querySelector<HTMLElement>("#main-content h1");
}
function pageDrawn(hash: string): boolean {
if (document.querySelector('.site-frame [aria-busy="true"]')) return false;
return pageHeading() !== null && (hash.length < 2 || hashTarget(hash) !== null);
}
/** Calls `ready` once `done()` holds, or when it gives up waiting. */
function waitFor(done: () => boolean, signal: AbortSignal, ready: () => void): void {
const deadline = performance.now() + SETTLE_TIMEOUT_MS;
const check = () => {
if (signal.aborted) return;
if (done() || performance.now() > deadline) {
ready();
return;
}
requestAnimationFrame(check);
};
check();
}
function focusOwnedByRoute(): boolean {
const active = document.activeElement;
return (
active === null ||
active === document.body ||
active === document.documentElement ||
active === document.getElementById("main-content")
);
}
export function useRouteArrival(): void {
const { pathname, hash, key } = useLocation();
const navigationType = useNavigationType();
const firstArrival = useRef(true);
const lastScroll = useRef(0);
const lastKey = useRef(key);
// The entry being left keeps the position the reader last scrolled to. It
// is taken while rendering the new entry, before its DOM replaces the old
// page: a shorter page clamps window.scrollY as soon as it is committed.
if (lastKey.current !== key) {
positions.set(lastKey.current, lastScroll.current);
lastKey.current = key;
}
useEffect(() => {
if (!inBrowser()) return undefined;
const { history } = window;
const previous = history.scrollRestoration;
history.scrollRestoration = "manual";
lastScroll.current = window.scrollY;
const onScroll = () => {
lastScroll.current = window.scrollY;
};
window.addEventListener("scroll", onScroll, { passive: true });
return () => {
window.removeEventListener("scroll", onScroll);
history.scrollRestoration = previous;
};
}, []);
useEffect(() => {
if (!inBrowser()) return undefined;
const first = firstArrival.current;
firstArrival.current = false;
const controller = new AbortController();
const restoreTo = navigationType === "POP" ? positions.get(key) : undefined;
if (restoreTo !== undefined) {
// A reader who scrolls, types or taps while the page fills in has
// chosen a position; the saved one no longer applies.
for (const type of ["wheel", "touchstart", "keydown", "pointerdown"] as const) {
window.addEventListener(type, () => controller.abort(), {
passive: true,
once: true,
signal: controller.signal,
});
}
}
waitFor(() => pageDrawn(hash), controller.signal, () => {
if (restoreTo !== undefined) {
waitFor(
() => document.documentElement.scrollHeight - window.innerHeight >= restoreTo,
controller.signal,
() => window.scrollTo({ top: restoreTo, left: 0, behavior: "auto" }),
);
}
const target = hashTarget(hash);
if (target && restoreTo === undefined) target.scrollIntoView();
if (first && !focusOwnedByRoute()) return;
const heading = pageHeading();
const focusTarget = target && target.tabIndex >= 0 ? target : heading;
if (!focusTarget) return;
if (focusTarget === heading) {
// As PageHeader's: reachable by script only, and `[data-route-heading]`
// draws no focus ring (globals.css, 3374f28) since it cannot be tabbed to.
if (!heading.hasAttribute("tabindex")) heading.tabIndex = -1;
heading.setAttribute("data-route-heading", "");
}
focusTarget.focus({ preventScroll: true });
});
return () => controller.abort();
// eslint-disable-next-line react-hooks/exhaustive-deps -- only a new path (or the first load) is an arrival; see above
}, [pathname]);
}
@@ -39,6 +39,19 @@ const HOME_FOCUS_SCHEMA = z.object({
decisionId: z.string(),
});
/**
* One object for the life of the module. useAppForm's `reset` depends on
* `defaultValues`, and the effect below resets the form when `reset` changes:
* a literal here made a new `reset` every render, so as soon as a home focus
* loaded the editor reset itself, re-rendered and reset again without end.
* release-editor.tsx keeps its defaults the same way (EMPTY_RELEASE_DRAFT).
*/
const EMPTY_HOME_FOCUS = Object.freeze({
projectId: "",
questionId: "",
decisionId: "",
});
export function HomeFocusEditor() {
const copy = useTechLogCopy();
const { setRequestAnnouncement } = useStudio();
@@ -51,11 +64,7 @@ export function HomeFocusEditor() {
const form = useAppForm({
schema: HOME_FOCUS_SCHEMA,
defaultValues: {
projectId: "",
questionId: "",
decisionId: "",
},
defaultValues: EMPTY_HOME_FOCUS,
allowedServerFields: ["projectId", "questionId", "decisionId"] as const,
mapToCommand(values) {
return {
@@ -1867,6 +1867,11 @@
.studio-app .studio-asset-kind-field--compact { display: flex; }
/* The block gutter (drag handle, block actions) sits in the page's side
margin, outside the reading column. It must not be wider than that margin
or the whole page scrolls sideways: the side margin is 38px or more from
936px up, 24px below that (single-surface .studio-main is 100% - 48px) and
14px at 760px and below (100% - 28px). See the two media rules below. */
.studio-app .studio-block-editor {
position: relative;
margin: 0 -38px;
@@ -1890,6 +1895,18 @@
border-radius: 5px;
}
@media (max-width: 935px) {
.studio-app .studio-block-editor {
margin-inline: -24px;
padding-inline: 24px;
}
.studio-app .studio-authoring-block {
grid-template-columns: 20px minmax(0, 1fr) auto;
margin-inline: -24px -6px;
}
}
.studio-app .studio-authoring-block:hover,
.studio-app .studio-authoring-block[data-active] {
background: color-mix(in srgb, var(--canvas) 56%, transparent);
@@ -2369,13 +2386,13 @@
.studio-app .studio-inline-asset-actions { justify-content: flex-start; }
.studio-app .studio-block-editor {
margin-inline: -18px;
padding-inline: 18px;
margin-inline: -14px;
padding-inline: 14px;
}
.studio-app .studio-authoring-block {
grid-template-columns: 22px minmax(0, 1fr);
margin-inline: -18px 0;
grid-template-columns: 14px minmax(0, 1fr);
margin-inline: -14px 0;
}
.studio-app .studio-authoring-block__actions { display: none; }
@@ -272,7 +272,9 @@ test("hands a bounded generated Blob to the real browser download path", async (
});
const state = globalThis as typeof globalThis & {
__browserDownloadResult?: Promise<unknown>;
__browserDownloadRuntime?: { dispose(): void };
};
state.__browserDownloadRuntime = runtime;
button.addEventListener("click", () => {
state.__browserDownloadResult = runtime.downloads
.deliver({
@@ -298,8 +300,7 @@ test("hands a bounded generated Blob to the real browser download path", async (
maxBufferedBytes: 1024,
signal: new AbortController().signal,
onProgress() {},
})
.finally(() => runtime.dispose());
});
});
});
@@ -313,11 +314,19 @@ test("hands a bounded generated Blob to the real browser download path", async (
for await (const chunk of stream) {
chunks.push(Buffer.from(chunk));
}
// dispose() revokes every live object URL at once. It used to run as soon
// as deliver() handed the URL to the anchor; WebKit starts the download
// after that, so it sometimes met a revoked URL and never started (no
// "download" event within the test timeout). The runtime is disposed once
// the browser has the file.
const result = await page.evaluate(async () => {
const state = globalThis as typeof globalThis & {
__browserDownloadResult?: Promise<unknown>;
__browserDownloadRuntime?: { dispose(): void };
};
return await state.__browserDownloadResult;
const delivered = await state.__browserDownloadResult;
state.__browserDownloadRuntime?.dispose();
return delivered;
});
expect(download.suggestedFilename()).toBe("report.bin");
@@ -182,6 +182,15 @@ async function startLifecycleRuntime(
__indexedDbLifecycleRuntime?: unknown;
}
).__indexedDbLifecycleRuntime = runtime;
// Every status the runtime passes through, so a short-lived one (BLOCKED
// lasts blockedTimeoutMs) is seen however late the test looks.
const statuses: unknown[] = [];
runtime.subscribeStatus((status) => statuses.push(status));
(
globalThis as unknown as {
__indexedDbLifecycleStatuses?: unknown[];
}
).__indexedDbLifecycleStatuses = statuses;
const opening = runtime.open();
(
globalThis as unknown as {
@@ -240,6 +249,17 @@ async function lifecycleStatus(page: Page): Promise<unknown> {
});
}
async function lifecycleStatuses(page: Page): Promise<unknown[]> {
return await page.evaluate(
() =>
(
globalThis as unknown as {
__indexedDbLifecycleStatuses?: unknown[];
}
).__indexedDbLifecycleStatuses ?? [],
);
}
async function closeLifecycleRuntime(page: Page): Promise<void> {
await page.evaluate(() => {
const runtime = (
@@ -1021,9 +1041,12 @@ test("fails a blocked v2 upgrade closed, then closes its late connection after t
expect(blocker).toBe("OPEN");
await startLifecycleRuntime(page, name, 2, 500);
// BLOCKED lasts 500 ms. Polling getStatus() from the test (100, 250, 500,
// 1000 ms apart) missed it whenever the blocked event came late, as it
// sometimes does in WebKit, and then saw only the CLOSED that follows.
await expect
.poll(async () => await lifecycleStatus(page))
.toEqual({
.poll(async () => await lifecycleStatuses(page))
.toContainEqual({
kind: "BLOCKED",
currentVersion: 1,
targetVersion: 2,
+3
View File
@@ -50,6 +50,9 @@ test("shows the boot error shell when a module throws while it evaluates", async
await page.goto(`${server.origin}/`);
const shell = page.getByRole("alert");
// The boot error shell replaces the loading shell once the boot has
// failed; see scroll-restoration.spec.ts for why this is not a 5 s window.
await shell.waitFor();
await expect(shell).toContainText("애플리케이션을 시작할 수 없습니다.");
await expect(shell).toContainText("BOOT_UNEXPECTED_FAILURE");
await expect(shell).toContainText("TypeError");
+7 -1
View File
@@ -93,6 +93,8 @@ test("an old tab reloads once into the new build, then stops reloading", async (
const server = await startBuildServer(builds.dist);
try {
await page.goto(`${server.origin}/`);
// The app draws after the document loads; see scroll-restoration.spec.ts.
await page.locator(".site-frame").waitFor();
await expect(
page.getByRole("link", { name: PLATFORM.navigationLabel!, exact: true }),
).toBeVisible();
@@ -107,7 +109,11 @@ test("an old tab reloads once into the new build, then stops reloading", async (
.getByRole("link", { name: PLATFORM.navigationLabel!, exact: true })
.click();
await expect(page.getByRole("heading", { name: PLATFORM.title })).toBeVisible();
// The page's h1: the home page the tab is still on has an h2 「프로젝트」
// of its own, which matched before the reload had happened.
await expect(
page.getByRole("heading", { level: 1, name: PLATFORM.title }),
).toBeVisible();
expect(loads).toBe(1);
const served = server.served.map((entry) => entry.path);
expect(served).not.toContain(aPlatform);
+2
View File
@@ -51,6 +51,8 @@ async function cspViolations(page: Page): Promise<string[]> {
test("boots and changes route under the production security headers", async ({ page }) => {
const response = await page.goto("/");
// The app draws after the document loads; see scroll-restoration.spec.ts.
await page.locator(".site-frame").waitFor();
expect(response?.headers()["content-security-policy"]).toBe(
securityHeaders["Content-Security-Policy"],
);
+11 -3
View File
@@ -1,9 +1,14 @@
import { expect, test, type Page } from "../support/browser/strict-browser-test.ts";
import { gotoTechLog } from "../support/browser/tech-log-fixtures.ts";
const scrollY = (page: Page) => page.evaluate(() => Math.round(window.scrollY));
// Template sync (af3d8e6). Upstream scrolls its long example page; this product
// deleted it, and a TechLog Case (about 6,000px at 1280x720) is the long page.
// Pages open through gotoTechLog, like the rest of this product's browser
// tests: it waits for the app to draw. After a bare page.goto the first
// expectation had 5 s for that, which WebKit on the desktop host sometimes
// needs more than while the other workers run.
const LONG_PAGE = "/cases/collection-fetch-join-pagination";
const LONG_PAGE_TITLE = "컬렉션 Fetch Join과 페이징은 왜 충돌하는가";
@@ -12,17 +17,20 @@ const LONG_PAGE_TITLE = "컬렉션 Fetch Join과 페이징은 왜 충돌하는
// scrolls.
test("restores the scroll position when navigating back", async ({ page }) => {
const heading = page.getByRole("heading", { level: 1 });
await page.goto(LONG_PAGE);
await gotoTechLog(page, LONG_PAGE);
await expect(heading).toHaveText(LONG_PAGE_TITLE);
await expect(page.locator("main [aria-busy='true']")).toHaveCount(0);
await expect(page.locator("#remaining-cost")).toBeAttached();
await page.evaluate(() => window.scrollTo(0, 900));
await expect.poll(() => scrollY(page)).toBe(900);
// TechLog's header is not sticky, so a real click first scrolls up to the
// link and the reader leaves from the top. The click is dispatched where the
// reader is, so the page is left at 900.
await page
.getByRole("navigation", { name: "주요 탐색" })
.getByRole("link", { name: "프로젝트" })
.click();
.dispatchEvent("click");
await expect(heading).toHaveText("프로젝트");
await expect.poll(() => scrollY(page)).toBe(0);
@@ -35,7 +43,7 @@ test("restores the scroll position when navigating back", async ({ page }) => {
test("opens a hash link at its target below the sticky header", async ({
page,
}) => {
await page.goto(`${LONG_PAGE}#separate-loading`);
await gotoTechLog(page, `${LONG_PAGE}#separate-loading`);
const target = page.locator("#separate-loading");
await expect(target).toBeInViewport();
const top = await target.evaluate((element) =>
+7 -2
View File
@@ -45,7 +45,9 @@ test("dirty-leave dialog is labelled, traps focus, and restores the invoking lin
"/studio/documents/11111111-1111-4111-8111-111111111111/edit",
);
await page.getByLabel("요약").fill("저장하지 않은 접근성 검증 변경");
const trigger = page.getByRole("link", { name: "게시 기록", exact: true }).first();
const trigger = page
.getByRole("navigation", { name: "Studio 주 탐색" })
.getByRole("link", { name: "게시", exact: true });
await trigger.click();
const dialog = page.getByRole("dialog", { name: "저장하지 않은 변경" });
await expect(dialog).toBeVisible();
@@ -71,7 +73,10 @@ test("open Public search and Studio leave dialogs have no blocking Axe findings"
"/studio/documents/11111111-1111-4111-8111-111111111111/edit",
);
await page.getByLabel("요약").fill("dialog axe state");
await page.getByRole("link", { name: "게시 기록", exact: true }).first().click();
await page
.getByRole("navigation", { name: "Studio 주 탐색" })
.getByRole("link", { name: "게시", exact: true })
.click();
results = await new AxeBuilder({ page })
.include("dialog")
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
+3
View File
@@ -34,6 +34,9 @@ for (const width of [1050, 1024, 980, 900, 820, 768, 767, 420, 390, 375] as cons
page,
"/studio/documents/11111111-1111-4111-8111-111111111111/edit",
);
// The body's block editor draws after the rest of the form. Measured
// before it, the page never overflowed; its gutter is what overflowed.
await page.locator("section.studio-block-editor").waitFor();
const dimensions = await horizontalOverflow(page);
expect(dimensions.scrollWidth).toBeLessThanOrEqual(dimensions.clientWidth);
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
@@ -0,0 +1,124 @@
import assert from "node:assert/strict";
import { test } from "vitest";
import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
import { FIXTURE_IDS } from "../../../src/features/tech-log/adapters/mock/fixtures.ts";
import { createMockManagementGateway } from "../../../src/features/tech-log/adapters/mock/mock-management-gateway.ts";
import { createMockStudioState } from "../../../src/features/tech-log/adapters/mock/mock-state.ts";
import { ManagementGatewayError } from "../../../src/features/tech-log/application/ports/management-gateway-error.ts";
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-context.ts";
function key(name: string) {
return { idempotencyKey: `mock-management-${name}` };
}
async function rejectsWith(promise: Promise<unknown>, code: string) {
await assert.rejects(promise, (error: unknown) => {
assert.ok(error instanceof ManagementGatewayError);
assert.equal(error.code, code);
return true;
});
}
test("MOCK Studio reads its management surface without the HTTP executor", async () => {
const calls: string[] = [];
const { input } = createTechLogFeatureInstalledInput({
...MOCK_STUDIO_INSTALL_CONTEXT,
http: Object.freeze({
async execute(...args: unknown[]) {
calls.push(JSON.stringify(args[0]));
throw new Error("a MOCK Studio call reached the HTTP executor");
},
}),
});
const studio = input.createStudioApplication();
const [topics, projects, questions, focus, releases] = await Promise.all([
studio.managementQueries.listTopics(),
studio.managementQueries.listProjects(),
studio.managementQueries.listQuestions(),
studio.managementQueries.getHomeFocus(),
studio.managementQueries.listReleases(),
]);
assert.deepEqual(calls, []);
assert.deepEqual(
topics.map((topic) => topic.slug),
["jpa", "redis", "authentication"],
);
assert.deepEqual(
projects.items.map((project) => project.slug),
["backend-skeleton", "auth-lab"],
);
assert.deepEqual(
questions.items.map((question) => question.id),
[FIXTURE_IDS.edgeTokenQuestion],
);
assert.equal(questions.items[0]?.primaryProject?.slug, "auth-lab");
assert.equal(focus.currentProjectId, FIXTURE_IDS.projectBackend);
assert.deepEqual(
releases.items.map((release) => release.versionLabel),
["0.1.0"],
);
});
test("the mock refuses a stale version with the backend's codes", async () => {
const gateway = createMockManagementGateway();
const project = await gateway.getProject(FIXTURE_IDS.projectBackend);
await rejectsWith(
gateway.updateProject(
project.id,
{
expectedVersion: project.version + 1,
name: project.name,
oneLinePurpose: "",
purposeMarkdown: "",
boundaryMarkdown: "",
phase: project.phase,
technologyLabels: [],
targetVisibility: "PUBLIC",
},
key("stale"),
),
"VERSION_CONFLICT",
);
await rejectsWith(gateway.getProject("99999999-9999-4999-8999-999999999999"), "PROJECT_NOT_FOUND");
await rejectsWith(gateway.getRelease("99999999-9999-4999-8999-999999999999"), "RELEASE_NOT_FOUND");
});
test("a replayed idempotency key returns the first draft instead of a second one", async () => {
const gateway = createMockManagementGateway();
const first = await gateway.createProject("새 프로젝트", key("create"));
const again = await gateway.createProject("새 프로젝트", key("create"));
assert.deepEqual(again, first);
const projects = await gateway.listProjects();
assert.equal(projects.page.totalElements, 3);
});
test("deleting a draft removes it from the shared document state", async () => {
const state = createMockStudioState();
const gateway = createMockManagementGateway({ studioState: state });
const draft = state.documents.get(FIXTURE_IDS.conflictCase)!;
await rejectsWith(
gateway.deleteDocument("CASE", FIXTURE_IDS.fetchJoinCase, state.documents.get(FIXTURE_IDS.fetchJoinCase)!.version, key("published")),
"CONFLICT",
);
await rejectsWith(
gateway.deleteDocument("REFERENCE", draft.id, draft.version, key("wrong-kind")),
"DOCUMENT_NOT_FOUND",
);
await gateway.deleteDocument("CASE", draft.id, draft.version, key("delete"));
assert.equal(state.documents.has(draft.id), false);
});
test("an aborted read rejects before it touches the store", async () => {
const gateway = createMockManagementGateway();
const controller = new AbortController();
controller.abort();
await assert.rejects(gateway.listTopics({ signal: controller.signal }), { name: "AbortError" });
});
+12 -1
View File
@@ -16,11 +16,22 @@ import {
const FIREFOX_PRETENDARD_NAME_ORDER =
/^\[JavaScript Warning: "downloadable font: name: name records are not sorted\. \(font-family: "Pretendard Variable" style:normal weight:45\.\.920 stretch:100 src index:0\) source: http:\/\/127\.0\.0\.1:\d+\/[\w./@-]*PretendardVariable(?:-[\w-]+)?\.woff2"\]$/u;
/**
* Template 1103/11-09. WebKit's guess, three seconds after the load event,
* that a preload went unused. It fires for chunks the page runs a moment
* later, which on the desktop host is often (WebKit takes about 4 s to open a
* page there). The template replaces it with a check of its own that every
* preloaded script ran (preload-use.ts); that check is not ported yet.
*/
const WEBKIT_UNUSED_PRELOAD_GUESS =
/^The resource \S+ was preloaded using link preload but not used within a few seconds from the window's load event\. Please make sure it wasn't preloaded for nothing\.$/u;
function ignoredConsole(message: ConsoleMessage) {
return (
message.type() === "warning" &&
(message.text().includes("NO_COLOR") ||
FIREFOX_PRETENDARD_NAME_ORDER.test(message.text()))
FIREFOX_PRETENDARD_NAME_ORDER.test(message.text()) ||
WEBKIT_UNUSED_PRELOAD_GUESS.test(message.text()))
);
}
@@ -151,6 +151,11 @@ export async function signInToStudio(page: Page) {
await page.locator("header.studio-header").waitFor();
await gate.waitFor({ state: "detached" });
await page.waitForLoadState("networkidle");
// The screen then loads its data (about 0.3 s, `aria-busy` while it does):
// a screenshot or a measurement taken before that sees the loading state.
await page.waitForFunction(
() => document.querySelector('main [aria-busy="true"]') === null,
);
}
/** `gotoTechLog` for a Studio route, signed in. */
@@ -94,6 +94,39 @@ describe("build variables in the bundle (13-06)", () => {
expect(reactDom(second)).toEqual(reactDom(first));
}, 120_000);
// 09-03. main.tsx imports the boot-failure screen when the application
// graph throws while its modules evaluate, so that screen must not import a
// chunk holding that graph. installed-feature-messages.ts (the module the
// boot-module-failure e2e makes throw) is found by its error text.
it("draws the boot-failure screen without the application graph", async () => {
const { run, contents } = await build({ VITE_BUILD_ID: "build-probe-boot" });
expect(run.status).toBe(0);
const chunks = new Map(
contents
.filter(({ file }) => file.endsWith(".js"))
.map(({ file, text }) => [path.basename(file), text]),
);
const staticImports = (text: string) =>
[...text.matchAll(/(?:from|import)\s*"\.\/([\w.-]+\.js)"/gu)].map(
([, name]) => name!,
);
const entry = [...chunks.keys()].find((name) =>
name.startsWith("render-boot-failure-"),
);
expect(entry).toBeDefined();
const reached = new Set<string>();
const pending = [entry!];
while (pending.length > 0) {
const name = pending.pop()!;
if (reached.has(name)) continue;
reached.add(name);
pending.push(...staticImports(chunks.get(name) ?? ""));
}
expect(
[...reached].filter((name) => chunks.get(name)?.includes("message key: ")),
).toEqual([]);
}, 120_000);
it("refuses a VITE_* variable the build does not declare", async () => {
const refused = await build({ VITE_PAYMENT_KEY: "sk_live_probe" });
expect(refused.run.status).not.toBe(0);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 KiB

After

Width:  |  Height:  |  Size: 686 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 556 KiB

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 KiB

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 KiB

After

Width:  |  Height:  |  Size: 686 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Some files were not shown because too many files have changed in this diff Show More