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 f858054abb..54f043ff3a 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
@@ -26,6 +26,7 @@ let stores: typeof import("~/shared/sync/data-stores");
let nanoStates: typeof import("~/shared/nano-states");
let builderStates: typeof import("~/builder/shared/nano-states");
const requests: Array<{ path: string; input: unknown }> = [];
+let publishResponse: unknown = { success: false, error: "Publish blocked" };
beforeAll(async () => {
Object.defineProperty(Element.prototype, "scrollIntoView", {
@@ -45,7 +46,10 @@ beforeAll(async () => {
let data: unknown;
switch (url.pathname) {
case "/trpc/domain.publish":
- data = { success: false, error: "Publish blocked" };
+ data = publishResponse;
+ break;
+ case "/trpc/api.publish.getJob":
+ data = { status: "failed", code: "BUILD_FAILED" };
break;
default:
throw new Error(`Unexpected request: ${url.pathname}`);
@@ -65,6 +69,8 @@ beforeAll(async () => {
beforeEach(() => {
reactEnvironment.IS_REACT_ACT_ENVIRONMENT = true;
+ publishResponse = { success: false, error: "Publish blocked" };
+ requests.length = 0;
});
afterEach(() => {
@@ -216,3 +222,106 @@ test("keeps Diagnostics visible but disabled before there is anything to show",
expect(diagnostics).toBeDefined();
expect(diagnostics?.getAttribute("data-disabled")).not.toBeNull();
});
+
+test.each([
+ ["Validate", "Errors", false],
+ ["Publish", "Errors", false],
+ ["Publish", "Publish", true],
+] as const)(
+ "%s keeps the result in the popover until See issues opens %s",
+ async (action, expectedTab, accepted) => {
+ if (accepted) {
+ publishResponse = {
+ success: true,
+ buildId: "build-1",
+ logHandle: "log-handle",
+ findings: [],
+ };
+ }
+ 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 domain = document.body.querySelector(
+ 'input[name="domainToPublish[]"]'
+ );
+ expect(domain).not.toBeNull();
+ if (domain?.checked === false) {
+ const checkbox =
+ document.body.querySelector('[role="checkbox"]');
+ expect(checkbox).not.toBeNull();
+ await act(async () => checkbox?.click());
+ }
+ expect(
+ new FormData(domain?.closest("form")!).getAll("domainToPublish[]")
+ ).toEqual(["example"]);
+
+ const actionButton = Array.from(
+ document.body.querySelectorAll("button")
+ )
+ .filter((button) => button.textContent?.trim() === action)
+ .at(-1);
+ expect(actionButton).toBeDefined();
+ expect(actionButton?.disabled).toBe(false);
+ await act(async () => actionButton?.click());
+ await vi.waitFor(() => {
+ expect(
+ Array.from(document.body.querySelectorAll("button")).some(
+ (button) => button.textContent?.trim() === "See issues"
+ )
+ ).toBe(true);
+ });
+ if (accepted) {
+ await vi.waitFor(() => {
+ const seeIssues = Array.from(
+ document.body.querySelectorAll("button")
+ ).find((button) => button.textContent?.trim() === "See issues");
+ expect(seeIssues?.parentElement?.textContent).toContain(
+ "Publish failed"
+ );
+ });
+ }
+
+ expect(builderStates.$publishDialog.get()).toBe("publish");
+ if (accepted) {
+ expect(requests.map(({ path }) => path)).toContain(
+ "/trpc/api.publish.getJob"
+ );
+ }
+ expect(document.body.querySelector('[role="tablist"]')).toBeNull();
+ const seeIssues = Array.from(
+ document.body.querySelectorAll("button")
+ ).find((button) => button.textContent?.trim() === "See issues");
+ await act(async () => seeIssues?.click());
+ expect(builderStates.$publishDialog.get()).toBe("none");
+ expect(document.body.querySelector('[role="tablist"]')).not.toBeNull();
+ expect(
+ document.body.querySelector(
+ '[role="tab"][aria-selected="true"]'
+ )?.textContent
+ ).toBe(expectedTab);
+ }
+);
diff --git a/apps/builder/app/builder/features/publish/publish.tsx b/apps/builder/app/builder/features/publish/publish.tsx
index 609b352d4c..e32709fd85 100644
--- a/apps/builder/app/builder/features/publish/publish.tsx
+++ b/apps/builder/app/builder/features/publish/publish.tsx
@@ -122,6 +122,7 @@ import {
import { getContentDatabasePublishFindings } from "./content-database-publish-warning";
import {
PublishDiagnosticsDialog,
+ PublishValidationBanner,
type PublishValidationFinding,
} from "./publish-diagnostics-dialog";
import {
@@ -866,6 +867,7 @@ const usePublishProgress = (projectId: Project["id"]) => {
setPublishFindings,
beginPublishDiagnostics,
publishError: publishErrorState?.value,
+ publishErrorSource: publishErrorState?.source,
publishErrorDomains: publishErrorState?.domains,
setPublishError,
setPublishStatusError,
@@ -1214,7 +1216,6 @@ const Publish = ({
progress.setPublishFindings(
getServerPublishFindings(publishResult.auditFindings)
);
- onOpenReport(domains[0], "errors");
return;
}
console.error(publishResult.error);
@@ -1320,12 +1321,6 @@ const Publish = ({
return;
}
validationFindings.update(session, checks.findings);
- onOpenReport(
- undefined,
- checks.findings.some(({ severity }) => severity === "error")
- ? "errors"
- : "warnings"
- );
if (checks.passed === false) {
onValidationStateChange("idle");
return;
@@ -1339,7 +1334,6 @@ const Publish = ({
reportPublishValidationFailure(error, (findings) =>
validationFindings.update(session, findings)
);
- onOpenReport(undefined, "errors");
}
};
@@ -1376,9 +1370,54 @@ const Publish = ({
};
const getForm = () => buttonRef.current?.closest("form");
+ const findings = [
+ ...validationFindings.findings,
+ ...progress.publishFindings,
+ ];
+ const hasSessionPublish = publishLogs.items.some(
+ ({ target }) => target === "site"
+ );
return (
+ {progress.publishError !== undefined ? (
+
+
+
+ {typeof progress.publishError === "string"
+ ? progress.publishError.slice(0, 160)
+ : progress.publishError}
+
+
+
+
+ ) : (
+
+ onOpenReport(
+ undefined,
+ findings.some(({ severity }) => severity === "error")
+ ? "errors"
+ : "warnings"
+ )
+ }
+ />
+ )}