fix: show clean validation in the publish popover

This commit is contained in:
Oleg Isonen committed 2026-11-13 23:29:02 +00:00
1 parent cbd90e1f24
commit d50d7e7ed0
4 files changed
+25 -1

No files matched your search

@@ -5,6 +5,7 @@ import { userEvent } from "@vitest/browser/context";
import { TooltipProvider } from "@webstudio-is/design-system";
import {
PublishDiagnosticsDialog,
PublishValidationBanner,
type PublishValidationFinding,
} from "./publish-diagnostics-dialog";
import type { PublishLog } from "./use-publish-logs";
@@ -71,6 +72,20 @@ test("renders no publish summary when there are no findings", () => {
expect(render([]).textContent).toBe("");
});
test("shows a clean validation result without offering an empty issues dialog", () => {
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
act(() => {
root?.render(
<PublishValidationBanner findings={[]} passed onOpen={vi.fn()} />
);
});
expect(container.querySelector('[role="status"]')).not.toBeNull();
expect(container.querySelector("button")).toBeNull();
});
test("shows all mixed findings, counted tabs, selectable text, and copy-all", async () => {
const findings = [
...Array.from({ length: 6 }, (_, index) => createFinding("error", index)),
@@ -45,15 +45,21 @@ const shortFinding = (finding: PublishValidationFinding) =>
export const PublishValidationBanner = ({
findings,
passed = false,
onOpen,
}: {
findings: PublishValidationFinding[];
passed?: boolean;
onOpen: () => void;
}) => {
const errors = findings.filter(({ severity }) => severity === "error");
const warnings = findings.filter(({ severity }) => severity === "warning");
if (findings.length === 0) {
return null;
return passed ? (
<PanelBanner variant="success" role="status">
<Text>Validation passed. Ready to publish.</Text>
</PanelBanner>
) : null;
}
const countLabel = [
errors.length > 0 &&
@@ -1339,6 +1339,7 @@ const Publish = ({
const handlePublish = (formData: FormData) => {
validationFindings.invalidate();
onValidationStateChange("idle");
progress.clearErrors();
const domains = getDomainsFromForm(formData);
const diagnostics = progress.beginPublishDiagnostics(domains);
@@ -1408,6 +1409,7 @@ const Publish = ({
) : (
<PublishValidationBanner
findings={findings}
passed={validationState === "passed"}
onOpen={() =>
onOpenReport(
undefined,
@@ -27,6 +27,7 @@ of the generated site.
Choose **Validate** to see a short result in the publish popover. When it finds
issues, choose **See issues** to open the **Warnings** or **Errors** tab.
When validation passes with no issues, the popover says it is ready to publish.
If publishing fails, the popover shows the failure and a **See issues** button.
It opens **Publish** for a publish that started, or **Errors** if the request
failed before a publish started.