From 82bd484b9df30ca31c84f14e8ecf3da5800125e6 Mon Sep 17 00:00:00 2001 From: Oleg Isonen Date: Sun, 15 Nov 2026 19:27:18 +0000 Subject: [PATCH] fix: Make publish diagnostics selectable and align static export status (#6703) Warnings and publish logs should be easy to select, and static export should show the same kind of result alert as site publish. This PR fixes those Builder behaviors without changing the publish pipeline. ## Checklist - [x] Make warning text selectable while keeping finding details on a separate link. Publish-log text remains selectable, with collapsibles and copy buttons unchanged. - [x] Show static-export success and failure in result alerts that open the matching Diagnostics tab; remove the redundant status icon while keeping button progress. - [x] Notify the user if a static-export audit rejection arrives after the Export popover closes; keep the inline-only notice while it is open. - [x] Preserve a persisted static-build failure indicator after Builder reload, without linking to session-only diagnostics. - [x] Add regression tests for both cases and verify 197 publish tests, Builder typecheck, root lint, formatting, and diff checks locally. Each new test failed without its fix and passed afterward. - [x] Update the authoritative static-export guide to explain what remains after reload. - [x] Confirm the main workflow, PR lint, submodule check, and approved visual regression pass on the final commit. No database or package contract changes. Wrangler telemetry is a separate SaaS publish-job setting and is not changed here. No local screenshots were taken, as previously requested. The intended visual changes were reviewed from CI screenshots and approved. A live staging publish/log read across this Builder PR and SaaS #684 remains unverified because the staging account reached its daily publish limit. No quota was changed. Replaces #6702. Closes #6701 --- .../features/publish/diagnostics.test.tsx | 27 ++++- .../builder/features/publish/diagnostics.tsx | 26 +++-- .../publish/publish-flow.render.test.tsx | 104 +++++++++++------- .../publish/publish-progress.render.test.tsx | 41 ++----- .../features/publish/publish-static.test.tsx | 49 +++++++-- .../builder/features/publish/publish-ui.tsx | 68 +++++------- .../app/builder/features/publish/publish.tsx | 30 ++++- docs/university/self-hosting/download.md | 7 +- 8 files changed, 209 insertions(+), 143 deletions(-) diff --git a/apps/builder/app/builder/features/publish/diagnostics.test.tsx b/apps/builder/app/builder/features/publish/diagnostics.test.tsx index bac95a1852..31e00a1bc8 100644 --- a/apps/builder/app/builder/features/publish/diagnostics.test.tsx +++ b/apps/builder/app/builder/features/publish/diagnostics.test.tsx @@ -146,7 +146,7 @@ test.each(["findings", "details", "publish"] as const)( ); if (view === "details") { const finding = Array.from(document.body.querySelectorAll("button")).find( - (button) => button.textContent === "finding" + (button) => button.textContent === "Show more" ); await act(async () => userEvent.click(finding!)); } @@ -222,7 +222,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as expect(document.body.querySelector('[draggable="true"]')).not.toBeNull(); const firstFinding = Array.from( document.body.querySelectorAll("button") - ).find((button) => button.textContent === "error-0"); + ).find((button) => button.textContent === "Show more"); expect(firstFinding).toBeDefined(); await act(async () => userEvent.click(firstFinding as HTMLElement)); const selectableText = Array.from(document.body.querySelectorAll("*")).find( @@ -244,7 +244,7 @@ test("shows all mixed findings, counted tabs, selectable text, and copy-all", as expect(document.body.textContent).not.toContain("error-0"); const warningFinding = Array.from( document.body.querySelectorAll("button") - ).find((button) => button.textContent === "warning-0"); + ).find((button) => button.textContent === "Show more"); await act(async () => userEvent.click(warningFinding as HTMLElement)); const warningBack = Array.from(document.body.querySelectorAll("button")).find( (button) => button.textContent === "Back" @@ -282,6 +282,25 @@ test.each(["error", "warning"] as const)( } ); +test("warning text can be selected without opening its details", async () => { + render([createFinding("warning", 0)], { open: true }); + const warning = Array.from( + document.body.querySelectorAll('[role="tabpanel"] div') + ).find( + (element) => + element.textContent === "warning-0" && + getComputedStyle(element).userSelect === "text" + ); + expect(warning).toBeDefined(); + await act(async () => userEvent.click(warning!)); + expect(document.body.textContent).not.toContain("Back"); + const showMore = Array.from(document.body.querySelectorAll("button")).find( + (button) => button.textContent === "Show more" + ); + await act(async () => userEvent.click(showMore!)); + expect(document.body.textContent).toContain("details-warning-0"); +}); + test("Free shows the actual short error without details, navigation, or report copy", () => { const element = render( [ @@ -773,7 +792,7 @@ test("Show element closes the diagnostics dialog on ordinary navigation", async ]); openDetails(element); const finding = Array.from(document.body.querySelectorAll("button")).find( - (button) => button.textContent === "Invalid element" + (button) => button.textContent === "Show more" ); await act(async () => userEvent.click(finding as HTMLElement)); const link = diff --git a/apps/builder/app/builder/features/publish/diagnostics.tsx b/apps/builder/app/builder/features/publish/diagnostics.tsx index a77030ba86..553a86db4a 100644 --- a/apps/builder/app/builder/features/publish/diagnostics.tsx +++ b/apps/builder/app/builder/features/publish/diagnostics.tsx @@ -141,13 +141,25 @@ const FindingList = ({ )} ) : canViewPublishLogs ? ( - + + + {finding.title} + + {(finding.details !== undefined || + finding.link !== undefined) && ( + onSelect(finding)} + > + Show more + + )} + ) : ( {shortFinding(finding)} diff --git a/apps/builder/app/builder/features/publish/publish-flow.render.test.tsx b/apps/builder/app/builder/features/publish/publish-flow.render.test.tsx index c77432c286..bd0e67a0c5 100644 --- a/apps/builder/app/builder/features/publish/publish-flow.render.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-flow.render.test.tsx @@ -245,19 +245,25 @@ const completeChecks = async (fail: boolean) => { }; const openErrors = async (target: "site" | "static") => { - if (target === "site") { - const issues = Array.from( + const findIssues = () => + Array.from( document.body.querySelectorAll("button") ).find((button) => button.textContent?.trim() === "See issues"); + if (target === "static") { + await vi.waitFor(async () => { + await act(async () => {}); + expect(findIssues()).toBeDefined(); + }); + } + const issues = findIssues(); + if (issues !== undefined) { + await act(async () => userEvent.click(issues)); + } else if (target === "site") { const status = document.body.querySelector( 'button[aria-label^="Publish log:"]' ); - expect(issues ?? status).toBeDefined(); - if (issues !== undefined) { - await act(async () => userEvent.click(issues)); - } else { - await act(async () => status?.click()); - } + expect(status).not.toBeNull(); + await act(async () => status?.click()); } const findErrors = () => Array.from( @@ -325,6 +331,27 @@ test.each([ } ); +test("static audit rejection notifies after Export closes", async () => { + await mount("static"); + await clickPublish("static"); + await completeChecks(false); + await act(async () => publishDialog.set("none")); + await act(async () => { + dispatch.resolve({ + success: false, + auditFindings: [{ severity: "error", message: "server rejection" }], + }); + await dispatch.promise; + }); + await vi.waitFor(async () => { + await act(async () => {}); + expect(toast.error).toHaveBeenCalledExactlyOnceWith("server rejection"); + }); + await mount("static"); + const errors = await openErrors("static"); + expect(errors?.textContent).toContain("server rejection"); +}); + test("closing Publish clears a completed validation", async () => { stores.$pages.set({ pages: new Map(), @@ -394,10 +421,6 @@ test.each([ if (order === "server-first") { await completeChecks(false); } - const status = document.body.querySelector( - 'button[aria-label="Publish log: Static export"]' - ); - await act(async () => status?.click()); const errors = await openErrors("static"); expect(errors?.textContent).toContain(message); } @@ -449,18 +472,8 @@ test.each(["request", "transport"] as const)( } await dispatch.promise.catch(() => {}); }); - await act(async () => - vi.waitFor(() => - expect(toast.error).toHaveBeenCalledWith( - failure === "request" ? "static rejection" : "static transport" - ) - ) - ); - const staticStatus = document.body.querySelector( - 'button[aria-label="Publish log: Static export"]' - ); - expect(staticStatus).toBeDefined(); - await act(async () => staticStatus?.click()); + expect(toast.error).not.toHaveBeenCalled(); + expect(document.body.querySelector('[role="alert"]')).not.toBeNull(); const staticErrors = await openErrors("static"); expect(staticErrors?.textContent).toContain( failure === "request" ? "static rejection" : "static transport" @@ -579,6 +592,23 @@ test.each(["site", "static"] as const)( } ); +test("static check failure stays in the Export alert without a toast", async () => { + await mount("static"); + await clickPublish("static"); + await completeChecks(true); + expect(toast.error).not.toHaveBeenCalled(); + await act(async () => { + dispatch.resolve({ + success: false, + auditFindings: [{ severity: "error", message: "server rejection" }], + }); + await dispatch.promise; + }); + const errors = await openErrors("static"); + expect(errors?.textContent).toContain("server rejection"); + expect(toast.error).not.toHaveBeenCalled(); +}); + test("an accepted site failure links to its own publish log", async () => { await mount("site"); await clickPublish("site"); @@ -716,15 +746,17 @@ test.each([ }); await dispatch.promise; }); - await act(async () => - vi.waitFor(() => - expect( - document.body.querySelector( - 'button[aria-label^="Publish log:"]' - ) - ).not.toBeNull() - ) - ); + if (target === "site") { + await act(async () => + vi.waitFor(() => + expect( + document.body.querySelector( + 'button[aria-label^="Publish log:"]' + ) + ).not.toBeNull() + ) + ); + } checks = deferred(); dispatch = deferred(); await mount(target); @@ -746,12 +778,6 @@ test.each([ await dispatch.promise.catch(() => {}); }); await completeChecks(false); - if (target === "static") { - const status = document.body.querySelector( - 'button[aria-label="Publish log: Static export"]' - ); - await act(async () => status?.click()); - } const errors = await openErrors(target); expect(errors?.textContent).toContain(message); expect(errors?.textContent).not.toContain("older build issue"); diff --git a/apps/builder/app/builder/features/publish/publish-progress.render.test.tsx b/apps/builder/app/builder/features/publish/publish-progress.render.test.tsx index 04f394a1d9..64e4496e72 100644 --- a/apps/builder/app/builder/features/publish/publish-progress.render.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-progress.render.test.tsx @@ -641,7 +641,7 @@ test.each(["validation", "publish"] as const)( await toggle("publish"); expect(banner()).toBeDefined(); const report = await openReport("Warnings"); - expect(report?.querySelector("button")).not.toBeNull(); + expect(report?.textContent?.trim()).toBeTruthy(); } ); @@ -665,7 +665,7 @@ test("an older validation cannot replace a newer report", async () => { expect(banner()).toBeDefined(); expect(button("Validated")).toBeDefined(); const report = await openReport("Warnings"); - expect(report?.querySelector("button")).not.toBeNull(); + expect(report?.textContent?.trim()).toBeTruthy(); }); test("older publish diagnostics cannot replace a newer operation", async () => { @@ -685,7 +685,7 @@ test("older publish diagnostics cannot replace a newer operation", async () => { await act(async () => old.resolve(checks)); expect(banner()).toBeDefined(); const report = await openReport("Warnings"); - expect(report?.querySelector("button")).not.toBeNull(); + expect(report?.textContent?.trim()).toBeTruthy(); }); test("reopening restores validated domains and publishes only those domains", async () => { @@ -785,19 +785,14 @@ test.each(["site", "static"] as const)( ); await waitFor(() => { if (first === "static") { - expect(document.body.querySelector('[role="tablist"]')).not.toBeNull(); + expect(button("See issues")).toBeDefined(); } else { expect(banner()).toBeDefined(); expect(button("Publish")?.disabled).toBe(false); } }); if (first === "static") { - // Close the report before returning to the other publish target. - const close = document.body.querySelector( - '[role="dialog"] button[aria-label="Close"]' - ); - expect(close).not.toBeNull(); - await act(async () => close?.click()); + await toggle("none"); } target = first === "site" ? "static" : "site"; if (target === "static") { @@ -814,16 +809,8 @@ test.each(["site", "static"] as const)( ).toHaveLength(2) ); if (target === "static") { - await waitFor(() => - expect(document.body.querySelector('[role="tablist"]')).not.toBeNull() - ); - await act(async () => - document.body - .querySelector( - '[role="dialog"] button[aria-label="Close"]' - ) - ?.click() - ); + await waitFor(() => expect(button("See issues")).toBeDefined()); + await toggle("none"); } if (first === "site") { await toggle("publish"); @@ -832,18 +819,8 @@ test.each(["site", "static"] as const)( expect(report?.textContent).not.toContain("static diagnostic"); } else { await selectStatic(); - const reportButton = document.body.querySelector( - 'button[aria-label="Publish log: Static export"]' - ); - expect(reportButton).not.toBeNull(); - await act(async () => reportButton?.click()); - await waitFor(() => - expect(document.body.querySelector('[role="tablist"]')).not.toBeNull() - ); - expect( - document.body.querySelector('[role="tabpanel"][data-state="active"]') - ?.textContent - ).toContain("static diagnostic"); + const report = await openReport("Errors"); + expect(report.textContent).toContain("static diagnostic"); } } ); diff --git a/apps/builder/app/builder/features/publish/publish-static.test.tsx b/apps/builder/app/builder/features/publish/publish-static.test.tsx index e3e8caaca9..bdff01914a 100644 --- a/apps/builder/app/builder/features/publish/publish-static.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-static.test.tsx @@ -62,7 +62,7 @@ beforeAll(async () => { ...projectStore.get(), latestStaticBuild: publishRequests === 0 - ? null + ? (projectStore.get()?.latestStaticBuild ?? null) : { buildId: "static-1", updatedAt: new Date().toISOString(), @@ -187,11 +187,32 @@ test("reopening an active static publish keeps one status owner and one download expect(downloads).toHaveBeenCalledExactlyOnceWith("/cgi/static/ssg/site.zip"); expect(staticButton()?.dataset.state).not.toBe("pending"); expect(staticButton()?.disabled).toBe(false); + expect(document.body.querySelector('[role="status"]')).not.toBeNull(); expect(document.body.textContent).toContain("Downloaded"); expect(publishRequests).toBe(1); expect(jobRequests).toBe(2); }); +test("a persisted static failure remains visible without session diagnostics", async () => { + projectStore.set({ + ...createProject(), + latestStaticBuild: { + buildId: "previous-static-build", + projectId: "project-a", + updatedAt: new Date().toISOString(), + publishStatus: "FAILED", + }, + }); + await render(true); + expect(document.body.querySelector('[role="alert"]')).not.toBeNull(); + expect(document.body.textContent).toContain("Download failed"); + expect( + Array.from(document.body.querySelectorAll("button")).some( + (button) => button.textContent === "See issues" + ) + ).toBe(false); +}); + test("project navigation suppresses an old static download and error toast", async () => { vi.useFakeTimers(); const errorToast = vi.spyOn(toast, "error").mockImplementation(() => ""); @@ -246,14 +267,13 @@ test("a failed static runner clears progress without starting a download", async await act(async () => vi.advanceTimersByTimeAsync(15_100)); expect(jobRequests).toBe(2); expect(downloads).not.toHaveBeenCalled(); - expect(errorToast).toHaveBeenCalledOnce(); + expect(errorToast).not.toHaveBeenCalled(); expect(staticButton()?.dataset.state).not.toBe("pending"); expect(staticButton()?.disabled).toBe(false); + expect(document.body.querySelector('[role="alert"]')).not.toBeNull(); await act(async () => - document.body - .querySelector( - 'button[aria-label="Publish log: Static export"]' - ) + Array.from(document.body.querySelectorAll("button")) + .find((button) => button.textContent === "See issues") ?.click() ); const errors = Array.from( @@ -277,7 +297,7 @@ test("a failed static runner clears progress without starting a download", async ).not.toBeNull(); }); -test("the static status reopens an audit rejection instead of an older successful publish", async () => { +test("the static failure alert opens an audit rejection instead of an older successful publish", async () => { getJobStatus = "success"; projectStore.set(createProject()); await render(true); @@ -298,8 +318,15 @@ test("the static status reopens an audit rejection instead of an older successfu ?.textContent; await vi.waitFor(async () => { await act(async () => {}); - expect(activeTab()).toBe("Errors"); + expect(document.body.querySelector('[role="alert"]')).not.toBeNull(); }); + expect(activeTab()).toBeUndefined(); + await act(async () => + Array.from(document.body.querySelectorAll("button")) + .find((button) => button.textContent === "See issues") + ?.click() + ); + expect(activeTab()).toBe("Errors"); await act(async () => document.body .querySelector('button[aria-label="Close"]') @@ -311,10 +338,8 @@ test("the static status reopens an audit rejection instead of an older successfu }); await render(true); await act(async () => - document.body - .querySelector( - 'button[aria-label="Publish log: Static export"]' - ) + Array.from(document.body.querySelectorAll("button")) + .find((button) => button.textContent === "See issues") ?.click() ); expect(activeTab()).toBe("Errors"); diff --git a/apps/builder/app/builder/features/publish/publish-ui.tsx b/apps/builder/app/builder/features/publish/publish-ui.tsx index 4fd0553a64..184e0d76b9 100644 --- a/apps/builder/app/builder/features/publish/publish-ui.tsx +++ b/apps/builder/app/builder/features/publish/publish-ui.tsx @@ -68,7 +68,6 @@ import { CollapsibleDomainSection } from "./collapsible-domain-section"; import { ActivityIcon, AlertIcon, - CheckCircleIcon, CopyIcon, GearIcon, UpgradeIcon, @@ -618,19 +617,13 @@ const PublishStatic = ({ const { status, statusContent } = project.latestStaticBuild == null - ? { status: "LOADED" as const, statusContent: "Not published" } + ? { status: "LOADED" as const, statusContent: undefined } : getStaticPublishStatusDisplay(project.latestStaticBuild); const latestPublish = publishes.find((item) => item.target === "static"); - const logStatus = - staticFailureFinding !== undefined - ? "FAILED" - : latestPublish?.status === "pending" - ? "PENDING" - : latestPublish?.status === "failed" - ? "FAILED" - : latestPublish?.status === "success" - ? "PUBLISHED" - : status; + const hasSessionFailure = + staticFailureFinding !== undefined || latestPublish?.status === "failed"; + const persistedFailure = latestPublish === undefined && status === "FAILED"; + const hasFailed = hasSessionFailure || persistedFailure; const isPublishInProgress = isPublishing || @@ -641,40 +634,35 @@ const PublishStatic = ({ return ( - {latestPublish?.status === "success" && + {hasFailed && ( + + + + {staticFailureFinding?.title ?? + (persistedFailure ? statusContent : "Publish failed")} + + {hasSessionFailure && ( + + )} + + + )} + {!hasFailed && + latestPublish?.status === "success" && latestPublish.staticName !== undefined && - !isPublishInProgress && - staticFailureFinding === undefined && ( + !isPublishInProgress && ( onOpenReport("publish")} /> )} - - - onOpenReport()} - > - {logStatus === "FAILED" ? ( - - ) : logStatus === "PUBLISHED" ? ( - - ) : ( - - )} - - - - diff --git a/apps/builder/app/builder/features/publish/publish.tsx b/apps/builder/app/builder/features/publish/publish.tsx index e3dd8c3042..712ac15aa1 100644 --- a/apps/builder/app/builder/features/publish/publish.tsx +++ b/apps/builder/app/builder/features/publish/publish.tsx @@ -341,7 +341,10 @@ export const PublishButton = ({ projectId }: PublishProps) => { setPublishError: setPublishStatusError, isCurrentProject, }); - } else if (result?.status === "FAILED") { + } else if ( + result?.status === "FAILED" && + $publishDialog.get() !== "export" + ) { toast.error(result.statusContent); } onResult?.(result); @@ -411,7 +414,10 @@ export const PublishButton = ({ projectId }: PublishProps) => { domains, }); } - if (target === "static" || $publishDialog.get() !== "publish") { + if ( + $publishDialog.get() !== + (target === "static" ? "export" : "publish") + ) { toast.error(target === "static" ? message.slice(0, 200) : message); } } @@ -1040,7 +1046,7 @@ export const PublishButton = ({ projectId }: PublishProps) => { if (isCurrentProject() && diagnostics.isCurrent()) { reportPublishValidationFailure(error, diagnostics.setFindings, { publishingContinues: true, - showToast: true, + showToast: $publishDialog.get() !== "export", }); } }, @@ -1060,14 +1066,22 @@ export const PublishButton = ({ projectId }: PublishProps) => { ...findings, ...getServerPublishFindings(publishResult.auditFindings), ]); - openStaticReport("errors"); + if ($publishDialog.get() !== "export") { + toast.error( + publishResult.auditFindings + .find((finding) => finding.severity === "error") + ?.message.slice(0, 200) ?? "Publish failed" + ); + } return; } diagnostics.finish((findings) => [ ...findings, getPublishErrorFinding(publishResult.error), ]); - toast.error(publishResult.error.slice(0, 200)); + if ($publishDialog.get() !== "export") { + toast.error(publishResult.error.slice(0, 200)); + } return; } const accepted = record({ @@ -1082,7 +1096,11 @@ export const PublishButton = ({ projectId }: PublishProps) => { toast.error('File name must be defined in "result"'); } const outcome = await waitForCompletion(accepted); - if (isCurrentProject() && outcome?.status === "FAILED") { + if ( + isCurrentProject() && + outcome?.status === "FAILED" && + $publishDialog.get() !== "export" + ) { toast.error(outcome.statusContent); } }, diff --git a/docs/university/self-hosting/download.md b/docs/university/self-hosting/download.md index 26ef765831..07f9e37e8c 100644 --- a/docs/university/self-hosting/download.md +++ b/docs/university/self-hosting/download.md @@ -35,9 +35,10 @@ the **Publish** tab. Free plans can open the tab but cannot view its logs. The export contains a static site consisting of HTML, CSS, JS, and images ready to be uploaded to another platform. -To check an export, open **Publish**, choose **Export**, and click the status -icon beside the static-site build button. -Its **Warnings**, **Errors**, and **Publish** tabs work like the [publish details for a domain](../foundations/publishing-and-custom-domains.md#publish-details): +If an export fails while Builder remains open, choose **See issues** in the +failure notice to open Diagnostics. After reloading Builder, the last failure +remains visible, but that session's issues and logs are no longer available. +The **Warnings**, **Errors**, and **Publish** tabs work like the [publish details for a domain](../foundations/publishing-and-custom-domains.md#publish-details): Publish shows exports started in this Builder tab, while Warnings and Errors show current project checks. Full logs, when available on your plan, open from Publish in the same dialog.