mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: show free log upgrade and order publishes chronologically
This commit is contained in:
1 parent
904763c67d
commit
fe5bbb7a8c
2 files changed
+68
-17
No files matched your search
@@ -364,21 +364,21 @@ test("collapses each complete publish and copies its full log from the header",
|
||||
document.body.querySelectorAll<HTMLButtonElement>("button[aria-labelledby]")
|
||||
);
|
||||
expect(triggers).toHaveLength(2);
|
||||
expect(triggers[0]?.getAttribute("aria-expanded")).toBe("true");
|
||||
expect(triggers[1]?.getAttribute("aria-expanded")).toBe("false");
|
||||
expect(triggers[0]?.getAttribute("aria-expanded")).toBe("false");
|
||||
expect(triggers[1]?.getAttribute("aria-expanded")).toBe("true");
|
||||
expect(document.body.textContent).toContain("Complete first publish log");
|
||||
expect(document.body.textContent).not.toContain(
|
||||
"Complete second publish log"
|
||||
);
|
||||
await act(async () => userEvent.click(triggers[1]!));
|
||||
await act(async () => userEvent.click(triggers[0]!));
|
||||
expect(document.body.textContent).toContain("Complete second publish log");
|
||||
const copyButtons = document.body.querySelectorAll<HTMLButtonElement>(
|
||||
'button[aria-label="Copy log"]'
|
||||
);
|
||||
expect(copyButtons).toHaveLength(2);
|
||||
await act(async () => userEvent.click(copyButtons[1]!));
|
||||
await act(async () => userEvent.click(copyButtons[0]!));
|
||||
expect(writeText).toHaveBeenCalledWith("Complete second publish log");
|
||||
expect(triggers[1]?.getAttribute("aria-expanded")).toBe("true");
|
||||
expect(triggers[0]?.getAttribute("aria-expanded")).toBe("true");
|
||||
});
|
||||
|
||||
test("publish failure is plain text and links to the Publish tab", async () => {
|
||||
@@ -429,7 +429,7 @@ test("publish failure is plain text and links to the Publish tab", async () => {
|
||||
).toBe("true");
|
||||
});
|
||||
|
||||
test("Free publish failures do not offer a log link", () => {
|
||||
test("Free publish failures link to a Publish upgrade banner without exposing logs", async () => {
|
||||
render(
|
||||
[
|
||||
{
|
||||
@@ -447,15 +447,65 @@ test("Free publish failures do not offer a log link", () => {
|
||||
domains: ["first.example"],
|
||||
findings: [],
|
||||
status: "failed",
|
||||
logState: "available",
|
||||
logText: "private runner output",
|
||||
},
|
||||
],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
expect(document.body.textContent).toContain("Publish failed");
|
||||
const link = Array.from(document.body.querySelectorAll("button")).find(
|
||||
(button) => button.textContent === "show logs"
|
||||
);
|
||||
expect(link).toBeDefined();
|
||||
await act(async () => userEvent.click(link!));
|
||||
expect(
|
||||
document.body.querySelector('[role="tabpanel"][data-state="active"] button')
|
||||
).toBeNull();
|
||||
document.body.querySelector('[role="tab"][aria-selected="true"]')
|
||||
?.textContent
|
||||
).toBe("Publish");
|
||||
expect(
|
||||
document.body.querySelector(
|
||||
'[role="tabpanel"][data-state="active"] [role="note"]'
|
||||
)
|
||||
).not.toBeNull();
|
||||
expect(document.body.textContent).not.toContain("private runner output");
|
||||
});
|
||||
|
||||
test("lists publishes oldest first and opens the newest entry", () => {
|
||||
render(
|
||||
[],
|
||||
true,
|
||||
[
|
||||
{
|
||||
buildId: "new",
|
||||
target: "site",
|
||||
domains: ["new.example"],
|
||||
findings: [],
|
||||
status: "success",
|
||||
},
|
||||
{
|
||||
buildId: "old",
|
||||
target: "site",
|
||||
domains: ["old.example"],
|
||||
findings: [],
|
||||
status: "failed",
|
||||
},
|
||||
],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
const triggers = Array.from(
|
||||
document.body.querySelectorAll<HTMLButtonElement>("button[aria-labelledby]")
|
||||
);
|
||||
const labels = triggers.map(
|
||||
(button) =>
|
||||
document.getElementById(button.getAttribute("aria-labelledby") ?? "")
|
||||
?.textContent
|
||||
);
|
||||
expect(labels).toEqual(["old.example", "new.example"]);
|
||||
expect(triggers[0]?.getAttribute("aria-expanded")).toBe("false");
|
||||
expect(triggers[1]?.getAttribute("aria-expanded")).toBe("true");
|
||||
});
|
||||
|
||||
test("pre-dispatch failure has no link to an absent Publish tab", () => {
|
||||
|
||||
@@ -107,7 +107,7 @@ const FindingList = ({
|
||||
{finding.source === "publish" ? (
|
||||
<Text variant="labels" userSelect="text">
|
||||
{canViewPublishLogs ? finding.title : shortFinding(finding)}
|
||||
{canViewPublishLogs && onOpenPublish !== undefined && (
|
||||
{onOpenPublish !== undefined && (
|
||||
<>
|
||||
{" "}
|
||||
<Link
|
||||
@@ -173,6 +173,7 @@ export const PublishDiagnosticsDialog = ({
|
||||
const warnings = findings.filter(({ severity }) => severity === "warning");
|
||||
const defaultTab = initialTab ?? (errors.length > 0 ? "errors" : "warnings");
|
||||
const [tab, setTab] = useState(defaultTab);
|
||||
const orderedItems = [...items].reverse();
|
||||
const activeTab =
|
||||
(tab === "warnings" && warnings.length > 0) ||
|
||||
(tab === "errors" && errors.length > 0) ||
|
||||
@@ -184,7 +185,7 @@ export const PublishDiagnosticsDialog = ({
|
||||
? "warnings"
|
||||
: "publish";
|
||||
const reportText = findings.map(({ reportText }) => reportText).join("\n\n");
|
||||
const publishText = items
|
||||
const publishText = orderedItems
|
||||
.filter(
|
||||
(item) => item.logState === "available" && item.logText !== undefined
|
||||
)
|
||||
@@ -350,16 +351,21 @@ export const PublishDiagnosticsDialog = ({
|
||||
>
|
||||
<ScrollArea css={{ height: "100%" }}>
|
||||
<PanelContent as={Flex} direction="column" gap={3}>
|
||||
{!canViewPublishLogs && (
|
||||
<PanelBanner variant="info" role="note">
|
||||
<Text>Upgrade to Pro to view publish logs.</Text>
|
||||
</PanelBanner>
|
||||
)}
|
||||
{items.length === 0 && (
|
||||
<Text color="subtle">No publishes in this session.</Text>
|
||||
)}
|
||||
{items.map((item, index) => {
|
||||
{orderedItems.map((item, index) => {
|
||||
const duration = getPublishDuration(item);
|
||||
return (
|
||||
<Collapsible.Root
|
||||
key={item.buildId}
|
||||
asChild
|
||||
defaultOpen={index === 0}
|
||||
defaultOpen={index === orderedItems.length - 1}
|
||||
>
|
||||
<Flex direction="column" gap={2}>
|
||||
<Collapsible.Trigger asChild>
|
||||
@@ -486,11 +492,6 @@ export const PublishDiagnosticsDialog = ({
|
||||
shown.
|
||||
</Text>
|
||||
)}
|
||||
{!canViewPublishLogs && (
|
||||
<Text color="subtle">
|
||||
Upgrade to Pro to view publish logs.
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Collapsible.Content>
|
||||
<Separator />
|
||||
|
||||
Reference in new issue
Block a user