diff --git a/apps/builder/app/builder/features/publish/publish-click.render.test.tsx b/apps/builder/app/builder/features/publish/publish-click.render.test.tsx index 6fec4316ea..fab51f6c15 100644 --- a/apps/builder/app/builder/features/publish/publish-click.render.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-click.render.test.tsx @@ -10,6 +10,7 @@ import { vi, } from "vitest"; import { TooltipProvider } from "@webstudio-is/design-system"; +import { userEvent } from "@vitest/browser/context"; import type { Project } from "@webstudio-is/project"; const reactEnvironment = globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }; @@ -173,3 +174,42 @@ test("static export reaches the server without waiting for diagnostics", async ( ) ).toBe(false); }, 10_000); + +test("keeps Diagnostics visible but disabled before there is anything to show", async () => { + stores.$project.set({ + id: "project-1", + domain: "example", + domainsVirtual: [], + latestStaticBuild: null, + } as unknown as Project); + nanoStates.$authTokenPermissions.set({ + canClone: true, + canCopy: true, + canPublish: true, + }); + builderStates.$publishDialog.set("publish"); + resetStores = () => { + stores.$project.set(undefined); + builderStates.$publishDialog.set("none"); + }; + const container = document.createElement("div"); + document.body.appendChild(container); + root = createRoot(container); + await act(async () => { + root?.render( + + + + ); + }); + const options = document.body.querySelector( + 'button[aria-label="Publish options"]' + ); + expect(options).not.toBeNull(); + await act(async () => userEvent.click(options!)); + const diagnostics = Array.from( + document.body.querySelectorAll('[role="menuitem"]') + ).find((item) => item.textContent?.trim() === "Diagnostics"); + expect(diagnostics).toBeDefined(); + expect(diagnostics?.getAttribute("data-disabled")).not.toBeNull(); +}); diff --git a/apps/builder/app/builder/features/publish/publish.tsx b/apps/builder/app/builder/features/publish/publish.tsx index 2c27eb1ab9..087c9f5f41 100644 --- a/apps/builder/app/builder/features/publish/publish.tsx +++ b/apps/builder/app/builder/features/publish/publish.tsx @@ -1843,6 +1843,17 @@ const Content = (props: { const hasCustomDomains = project.domainsVirtual.some( (domain) => domain.status === "ACTIVE" && domain.verified ); + const hasSitePublish = props.publishLogs.items.some( + ({ target }) => target === "site" + ); + const diagnosticFindings = [ + ...props.progress.manualValidationFindings.findings, + ...props.progress.publishFindings, + ]; + const hasDiagnostics = + hasSitePublish || + diagnosticFindings.length > 0 || + props.progress.publishError !== undefined; return ( <> @@ -1868,15 +1879,24 @@ const Content = (props: { > Export - {props.publishLogs.items.some( - ({ target }) => target === "site" - ) && ( - props.onOpenReport(undefined, "publish")} - > - Diagnostics - - )} + + props.onOpenReport( + undefined, + hasSitePublish + ? "publish" + : props.progress.publishError !== undefined || + diagnosticFindings.some( + ({ severity }) => severity === "error" + ) + ? "errors" + : "warnings" + ) + } + > + Diagnostics + }