mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: keep publish diagnostics in the menu
This commit is contained in:
1 parent
604f7786ef
commit
ebb2c83bed
2 files changed
+69
-9
No files matched your search
@@ -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(
|
||||
<TooltipProvider>
|
||||
<publishModule.PublishButton projectId="project-1" />
|
||||
</TooltipProvider>
|
||||
);
|
||||
});
|
||||
const options = document.body.querySelector<HTMLButtonElement>(
|
||||
'button[aria-label="Publish options"]'
|
||||
);
|
||||
expect(options).not.toBeNull();
|
||||
await act(async () => userEvent.click(options!));
|
||||
const diagnostics = Array.from(
|
||||
document.body.querySelectorAll<HTMLElement>('[role="menuitem"]')
|
||||
).find((item) => item.textContent?.trim() === "Diagnostics");
|
||||
expect(diagnostics).toBeDefined();
|
||||
expect(diagnostics?.getAttribute("data-disabled")).not.toBeNull();
|
||||
});
|
||||
@@ -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
|
||||
</DropdownMenuItem>
|
||||
{props.publishLogs.items.some(
|
||||
({ target }) => target === "site"
|
||||
) && (
|
||||
<DropdownMenuItem
|
||||
onSelect={() => props.onOpenReport(undefined, "publish")}
|
||||
>
|
||||
Diagnostics
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
disabled={!hasDiagnostics}
|
||||
onSelect={() =>
|
||||
props.onOpenReport(
|
||||
undefined,
|
||||
hasSitePublish
|
||||
? "publish"
|
||||
: props.progress.publishError !== undefined ||
|
||||
diagnosticFindings.some(
|
||||
({ severity }) => severity === "error"
|
||||
)
|
||||
? "errors"
|
||||
: "warnings"
|
||||
)
|
||||
}
|
||||
>
|
||||
Diagnostics
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
icon={<GearIcon />}
|
||||
|
||||
Reference in new issue
Block a user