mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: make publish diagnostics actionable and complete
This commit is contained in:
1 parent
7fd14db3e8
commit
b9914b387b
4 files changed
+187
-16
No files matched your search
@@ -27,7 +27,8 @@ const render = (
|
||||
findings: PublishValidationFinding[],
|
||||
canViewPublishLogs = true,
|
||||
items: PublishLog[] = [],
|
||||
onLoadLog?: (item: PublishLog) => void
|
||||
onLoadLog?: (item: PublishLog) => void,
|
||||
open?: boolean
|
||||
) => {
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
@@ -40,6 +41,7 @@ const render = (
|
||||
canViewPublishLogs={canViewPublishLogs}
|
||||
items={items}
|
||||
onLoadLog={onLoadLog}
|
||||
open={open}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
);
|
||||
@@ -274,6 +276,134 @@ test("shows unavailable instead of loading forever when a publish has no log han
|
||||
expect(document.body.textContent).toContain("Publish logs are unavailable.");
|
||||
});
|
||||
|
||||
test("lists each publish domain and copies the full loaded log", async () => {
|
||||
const writeText = vi.fn(async (_text: string) => {});
|
||||
Object.defineProperty(navigator, "clipboard", {
|
||||
configurable: true,
|
||||
value: { writeText },
|
||||
});
|
||||
render(
|
||||
[],
|
||||
true,
|
||||
[
|
||||
{
|
||||
buildId: "build-1",
|
||||
target: "site",
|
||||
domains: ["first.example", "second.example"],
|
||||
findings: [],
|
||||
status: "failed",
|
||||
logState: "available",
|
||||
logText: "First complete runner log",
|
||||
},
|
||||
{
|
||||
buildId: "build-2",
|
||||
target: "site",
|
||||
domains: ["third.example"],
|
||||
findings: [],
|
||||
status: "success",
|
||||
logState: "available",
|
||||
logText: "Second complete runner log",
|
||||
},
|
||||
],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
expect(document.body.textContent).toContain("first.example");
|
||||
expect(document.body.textContent).toContain("second.example");
|
||||
expect(document.body.textContent).toContain("third.example");
|
||||
expect(document.body.textContent).not.toContain(
|
||||
"first.example, second.example"
|
||||
);
|
||||
const copyButton = document.body.querySelector<HTMLButtonElement>(
|
||||
'button[aria-label="Copy all reports"]'
|
||||
);
|
||||
expect(copyButton).not.toBeNull();
|
||||
await act(async () => userEvent.click(copyButton!));
|
||||
expect(writeText).toHaveBeenCalledOnce();
|
||||
const copied = writeText.mock.calls[0][0];
|
||||
expect(copied).toContain("First complete runner log");
|
||||
expect(copied).toContain("Second complete runner log");
|
||||
expect(copied).toContain("first.example");
|
||||
expect(copied).toContain("second.example");
|
||||
expect(copied).toContain("third.example");
|
||||
});
|
||||
|
||||
test("publish failure is plain text and links to the Publish tab", async () => {
|
||||
render(
|
||||
[
|
||||
{
|
||||
severity: "error",
|
||||
source: "publish",
|
||||
title: "Build failed before deployment",
|
||||
summary: "Build failed before deployment",
|
||||
reportText: "Build failed before deployment",
|
||||
},
|
||||
],
|
||||
true,
|
||||
[
|
||||
{
|
||||
buildId: "build-1",
|
||||
target: "site",
|
||||
domains: ["first.example"],
|
||||
findings: [],
|
||||
status: "failed",
|
||||
},
|
||||
],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
expect(document.body.textContent).toContain("Build failed before deployment");
|
||||
expect(document.body.textContent).not.toContain("Audit");
|
||||
expect(
|
||||
Array.from(document.body.querySelectorAll("button")).some(
|
||||
(button) => button.textContent === "Build failed before deployment"
|
||||
)
|
||||
).toBe(false);
|
||||
const publishLink = Array.from(document.body.querySelectorAll("button")).find(
|
||||
(button) =>
|
||||
button.getAttribute("role") !== "tab" && button.textContent === "Publish"
|
||||
);
|
||||
expect(publishLink).toBeDefined();
|
||||
await act(async () => userEvent.click(publishLink!));
|
||||
expect(
|
||||
Array.from(document.body.querySelectorAll('[role="tab"]'))
|
||||
.find((tab) => tab.textContent === "Publish")
|
||||
?.getAttribute("aria-selected")
|
||||
).toBe("true");
|
||||
});
|
||||
|
||||
test("pre-dispatch failure has no link to an absent Publish tab", () => {
|
||||
render(
|
||||
[
|
||||
{
|
||||
severity: "error",
|
||||
source: "publish",
|
||||
title: "Publish request failed",
|
||||
reportText: "Publish request failed",
|
||||
},
|
||||
],
|
||||
true,
|
||||
[],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
expect(document.body.textContent).toContain("Publish request failed");
|
||||
expect(document.body.textContent).not.toContain("Audit");
|
||||
expect(
|
||||
Array.from(document.body.querySelectorAll("button")).some(
|
||||
(button) => button.textContent === "Publish request failed"
|
||||
)
|
||||
).toBe(false);
|
||||
expect(document.body.querySelector('[role="tab"]')?.textContent).toBe(
|
||||
"Errors"
|
||||
);
|
||||
expect(
|
||||
Array.from(document.body.querySelectorAll("button")).some(
|
||||
(button) => button.textContent === "Publish"
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test("Free audit summaries do not expose long cached details", () => {
|
||||
const longSummary = `Short reason ${"private context ".repeat(30)}`;
|
||||
const element = render(
|
||||
|
||||
@@ -25,7 +25,7 @@ import { getPublishDuration } from "./use-publish-logs";
|
||||
|
||||
export type PublishValidationFinding = {
|
||||
severity: "error" | "warning";
|
||||
source?: "audit" | "build";
|
||||
source?: "audit" | "build" | "publish";
|
||||
title: ReactNode;
|
||||
summary?: string;
|
||||
details?: ReactNode;
|
||||
@@ -83,20 +83,35 @@ const FindingList = ({
|
||||
findings,
|
||||
canViewPublishLogs,
|
||||
onSelect,
|
||||
onOpenPublish,
|
||||
}: {
|
||||
findings: PublishValidationFinding[];
|
||||
canViewPublishLogs: boolean;
|
||||
onSelect: (finding: PublishValidationFinding) => void;
|
||||
onOpenPublish?: () => void;
|
||||
}) => (
|
||||
<ScrollArea css={{ height: "100%" }}>
|
||||
<PanelContent as={Flex} direction="column" gap={3}>
|
||||
{findings.map((finding, index) => (
|
||||
<Fragment key={`${finding.severity}-${index}`}>
|
||||
<Flex direction="column" gap={2}>
|
||||
<Text color="subtle" variant="labels">
|
||||
{finding.source === "build" ? "Build" : "Audit"}
|
||||
</Text>
|
||||
{canViewPublishLogs ? (
|
||||
{finding.source !== "publish" && (
|
||||
<Text color="subtle" variant="labels">
|
||||
{finding.source === "build" ? "Build" : "Audit"}
|
||||
</Text>
|
||||
)}
|
||||
{finding.source === "publish" ? (
|
||||
<>
|
||||
<Text variant="labels" userSelect="text">
|
||||
{canViewPublishLogs ? finding.title : shortFinding(finding)}
|
||||
</Text>
|
||||
{onOpenPublish !== undefined && (
|
||||
<Button type="button" color="ghost" onClick={onOpenPublish}>
|
||||
Publish
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
) : canViewPublishLogs ? (
|
||||
<Button
|
||||
type="button"
|
||||
color="ghost"
|
||||
@@ -156,6 +171,18 @@ export const PublishDiagnosticsDialog = ({
|
||||
? "warnings"
|
||||
: "publish";
|
||||
const reportText = findings.map(({ reportText }) => reportText).join("\n\n");
|
||||
const publishText = items
|
||||
.filter(
|
||||
(item) => item.logState === "available" && item.logText !== undefined
|
||||
)
|
||||
.map((item) =>
|
||||
[
|
||||
...(item.domains.length > 0 ? item.domains : ["Static export"]),
|
||||
item.logText,
|
||||
].join("\n")
|
||||
)
|
||||
.join("\n\n");
|
||||
const copyText = activeTab === "publish" ? publishText : reportText;
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedFinding(undefined);
|
||||
@@ -205,11 +232,8 @@ export const PublishDiagnosticsDialog = ({
|
||||
<DialogTitle
|
||||
suffix={
|
||||
<DialogTitleActions>
|
||||
{canViewPublishLogs && reportText.length > 0 && (
|
||||
<CopyToClipboard
|
||||
text={reportText}
|
||||
copyText="Copy all reports"
|
||||
>
|
||||
{canViewPublishLogs && copyText.length > 0 && (
|
||||
<CopyToClipboard text={copyText} copyText="Copy all reports">
|
||||
<IconButton
|
||||
type="button"
|
||||
aria-label="Copy all reports"
|
||||
@@ -289,6 +313,9 @@ export const PublishDiagnosticsDialog = ({
|
||||
findings={warnings}
|
||||
canViewPublishLogs={canViewPublishLogs}
|
||||
onSelect={setSelectedFinding}
|
||||
onOpenPublish={
|
||||
items.length > 0 ? () => setTab("publish") : undefined
|
||||
}
|
||||
/>
|
||||
</PanelTabsContent>
|
||||
<PanelTabsContent
|
||||
@@ -299,6 +326,9 @@ export const PublishDiagnosticsDialog = ({
|
||||
findings={errors}
|
||||
canViewPublishLogs={canViewPublishLogs}
|
||||
onSelect={setSelectedFinding}
|
||||
onOpenPublish={
|
||||
items.length > 0 ? () => setTab("publish") : undefined
|
||||
}
|
||||
/>
|
||||
</PanelTabsContent>
|
||||
<PanelTabsContent
|
||||
@@ -314,9 +344,17 @@ export const PublishDiagnosticsDialog = ({
|
||||
const duration = getPublishDuration(item);
|
||||
return (
|
||||
<Flex key={item.buildId} direction="column" gap={2}>
|
||||
<Text variant="labels">
|
||||
{item.domains.join(", ") || "Static export"}
|
||||
</Text>
|
||||
{item.domains.length > 0 ? (
|
||||
<Flex direction="column" gap={1}>
|
||||
{item.domains.map((domain) => (
|
||||
<Text key={domain} variant="labels">
|
||||
{domain}
|
||||
</Text>
|
||||
))}
|
||||
</Flex>
|
||||
) : (
|
||||
<Text variant="labels">Static export</Text>
|
||||
)}
|
||||
<Text color="subtle">
|
||||
{item.status === "pending"
|
||||
? "Publishing started"
|
||||
|
||||
@@ -2402,6 +2402,7 @@ export const PublishButton = ({ projectId }: PublishProps) => {
|
||||
: [
|
||||
{
|
||||
severity: "error" as const,
|
||||
source: "publish" as const,
|
||||
title: publishProgress.publishError,
|
||||
summary:
|
||||
typeof publishProgress.publishError === "string"
|
||||
|
||||
@@ -36,8 +36,10 @@ may still appear after reload, without a session log.
|
||||
|
||||
Free plans show validation findings and a short publish failure notice, but not
|
||||
build-log issues or detailed build errors. Pro and Team plans can open finding
|
||||
details and, when GitHub provides them, view the full build logs. Build logs may
|
||||
be unavailable even when publishing succeeds or fails.
|
||||
details and view publish logs. Successful publishes show the publish steps.
|
||||
Failed publishes show every executed step, with the failed step first. If a step
|
||||
log is unavailable, Webstudio tries the full job log. GitHub may provide no log
|
||||
even when publishing succeeds or fails.
|
||||
|
||||
## Adding a custom domain
|
||||
|
||||
|
||||
Reference in new issue
Block a user