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 041985c109..7de1646704 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 @@ -215,6 +215,89 @@ test("a successful site runner finishes the current publish and retains its repo document.body.querySelector('[role="tabpanel"][data-state="active"]') ?.textContent ).toContain("Published"); + await act(async () => + document.body + .querySelector( + '[role="dialog"] button[aria-label="Close"]' + ) + ?.click() + ); + await act(async () => builderStates.$publishDialog.set("publish")); + const validate = Array.from( + document.body.querySelectorAll("button") + ).find((button) => button.textContent?.trim() === "Validate"); + expect(validate).toBeDefined(); + await act(async () => validate?.click()); + await act(async () => + vi.waitFor(() => + expect( + Array.from( + document.body.querySelectorAll("button") + ).some((button) => button.textContent?.trim() === "See issues") + ).toBe(true) + ) + ); + expect(document.body.textContent).not.toContain("Published successfully."); +}); + +test("a rejected publish replaces an older success notice with its findings", async () => { + jobStatus = "success"; + publishResponse = { + success: true, + buildId: "build-1", + logHandle: "log-handle", + findings: [], + }; + await mount(); + const domain = document.body.querySelector( + 'input[name="domainToPublish[]"]' + )!; + if (domain.checked === false) { + await act(async () => + document.body.querySelector('[role="checkbox"]')?.click() + ); + } + const publish = Array.from( + document.body.querySelectorAll("button") + ) + .filter((button) => button.textContent?.trim() === "Publish") + .at(-1)!; + await act(async () => publish.click()); + await act(async () => + vi.waitFor(() => + expect(stores.$project.get()?.latestBuildVirtual?.buildId).toBe("build-1") + ) + ); + expect(document.body.textContent).toContain("Published successfully."); + + publishResponse = { + success: false, + auditFindings: [{ severity: "error", message: "new audit failure" }], + }; + const publishAgain = Array.from( + document.body.querySelectorAll("button") + ) + .filter((button) => button.textContent?.trim() === "Publish") + .at(-1)!; + expect(publishAgain.disabled).toBe(false); + await act(async () => publishAgain.click()); + await act(async () => + vi.waitFor(() => + expect( + requests.filter(({ path }) => path === "/trpc/domain.publish") + ).toHaveLength(2) + ) + ); + const seeIssues = () => + Array.from( + document.body.querySelectorAll("button") + ).find((button) => button.textContent?.trim() === "See issues"); + await act(async () => vi.waitFor(() => expect(seeIssues()).toBeDefined())); + expect(document.body.textContent).not.toContain("Published successfully."); + await act(async () => seeIssues()?.click()); + expect(document.body.querySelector('[role="dialog"]')?.textContent).toContain( + "new audit failure" + ); }); test("a successful static export links to its publish report until another export starts", async () => { 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 e3c83db699..c77432c286 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 @@ -523,6 +523,47 @@ test("a site transport error appears only for its attempted domain", async () => ); }); +test("an accepted publish failure appears only for its attempted domain", async () => { + stores.$project.set({ + id: "project", + domain: "example", + domainsVirtual: [ + { + domain: "other.example", + projectId: "project", + domainId: "other-id", + status: "ACTIVE", + verified: true, + updatedAt: new Date().toISOString(), + latestBuildVirtual: null, + }, + ], + latestStaticBuild: null, + } as unknown as Project); + await mount("site"); + await clickPublish("site"); + await completeChecks(false); + await act(async () => { + dispatch.resolve({ + success: true, + buildId: "accepted-build", + logHandle: "handle", + findings: [], + }); + await dispatch.promise; + }); + const otherDomainStatus = document.body.querySelector( + 'button[aria-label="Publish log: other.example"]' + ); + expect(otherDomainStatus).toBeDefined(); + await act(async () => otherDomainStatus?.click()); + expect( + Array.from(document.body.querySelectorAll('[role="tab"]')).some((tab) => + tab.textContent?.startsWith("Errors") + ) + ).toBe(false); +}); + test.each(["site", "static"] as const)( "%s check failure has one notice while Publish is open", async (target) => { diff --git a/apps/builder/app/builder/features/publish/publish-ui.tsx b/apps/builder/app/builder/features/publish/publish-ui.tsx index 054e595ae1..9d90ba96da 100644 --- a/apps/builder/app/builder/features/publish/publish-ui.tsx +++ b/apps/builder/app/builder/features/publish/publish-ui.tsx @@ -113,6 +113,7 @@ type PublishUiState = { siteError?: string | JSX.Element; siteErrorSource?: "request" | "transport" | "status"; siteFindings: DiagnosticFinding[]; + siteHasValidationResult: boolean; staticFailureFinding?: DiagnosticFinding; openSiteReport: ( domain: string | undefined, @@ -534,7 +535,9 @@ const Publish = ({ - ) : latestSitePublish?.status === "success" && !isPublishInProgress ? ( + ) : latestSitePublish?.status === "success" && + !isPublishInProgress && + !flow.siteHasValidationResult ? ( onOpenReport(undefined, "publish")} diff --git a/apps/builder/app/builder/features/publish/publish.tsx b/apps/builder/app/builder/features/publish/publish.tsx index 50673fcce6..db857ca890 100644 --- a/apps/builder/app/builder/features/publish/publish.tsx +++ b/apps/builder/app/builder/features/publish/publish.tsx @@ -816,7 +816,11 @@ export const PublishButton = ({ projectId }: PublishProps) => { findings.push(...manualFindings); } const publishError = publishErrorState?.value; - const publishErrorDomains = publishErrorState?.domains; + const publishErrorDomains = + publishErrorState?.domains ?? + visiblePublishes.find( + (item) => item.buildId === publishErrorState?.buildId + )?.domains; if ( publishError !== undefined && (domain === undefined || @@ -1060,6 +1064,10 @@ export const PublishButton = ({ projectId }: PublishProps) => { siteError: publishErrorState?.value, siteErrorSource: publishErrorState?.source, siteFindings, + siteHasValidationResult: + publishDiagnostics.site.rejected === true || + manualDomains !== undefined || + validationState === "passed", staticFailureFinding, publishes: visiblePublishes, loadLog, diff --git a/packages/design-system/src/components/panel-banner.tsx b/packages/design-system/src/components/panel-banner.tsx index b32ca67b5d..91af24024a 100644 --- a/packages/design-system/src/components/panel-banner.tsx +++ b/packages/design-system/src/components/panel-banner.tsx @@ -19,14 +19,23 @@ export const PanelBanner = styled(Box, { info: {}, warning: { backgroundColor: cssVar("--background-warning-subtle"), + boxShadow: `inset 0 0 0 1px light-dark(transparent, ${cssVar( + "--border-warning" + )})`, [iconColor]: cssVar("--foreground-warning"), }, error: { backgroundColor: cssVar("--background-negative-subtle"), + boxShadow: `inset 0 0 0 1px light-dark(transparent, ${cssVar( + "--background-negative" + )})`, [iconColor]: cssVar("--foreground-negative"), }, success: { backgroundColor: cssVar("--background-positive-subtle"), + boxShadow: `inset 0 0 0 1px light-dark(transparent, ${cssVar( + "--background-positive" + )})`, [iconColor]: cssVar("--foreground-positive"), }, neutral: {