fix: show current publish findings and readable status notices

This commit is contained in:
Oleg Isonen committed 2026-11-15 16:14:42 +00:00
1 parent d206589a7b
commit e2784fa6f7
5 files changed
+146 -2

No files matched your search

@@ -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<HTMLButtonElement>(
'[role="dialog"] button[aria-label="Close"]'
)
?.click()
);
await act(async () => builderStates.$publishDialog.set("publish"));
const validate = Array.from(
document.body.querySelectorAll<HTMLButtonElement>("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<HTMLButtonElement>("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<HTMLInputElement>(
'input[name="domainToPublish[]"]'
)!;
if (domain.checked === false) {
await act(async () =>
document.body.querySelector<HTMLElement>('[role="checkbox"]')?.click()
);
}
const publish = Array.from(
document.body.querySelectorAll<HTMLButtonElement>("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<HTMLButtonElement>("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<HTMLButtonElement>("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 () => {
@@ -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<HTMLButtonElement>(
'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) => {
@@ -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 = ({
</Button>
</Flex>
</PanelBanner>
) : latestSitePublish?.status === "success" && !isPublishInProgress ? (
) : latestSitePublish?.status === "success" &&
!isPublishInProgress &&
!flow.siteHasValidationResult ? (
<PublishSuccessBanner
message="Published successfully."
onOpen={() => onOpenReport(undefined, "publish")}
@@ -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,
@@ -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: {