Skip to content

Commit b63a2e4

Browse files
wpfleger96npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
andauthored
fix(desktop): sync sidebar update card copy with global installing state (#1827)
Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
1 parent 34dcd13 commit b63a2e4

2 files changed

Lines changed: 56 additions & 5 deletions

File tree

‎desktop/src/features/settings/SidebarUpdateCard.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function SidebarUpdateCompactCard({
2121
onDismiss,
2222
testId = "sidebar-update-card-compact",
2323
}: SidebarUpdateCompactCardProps) {
24-
const { installAndRelaunch } = useUpdaterContext();
24+
const { installAndRelaunch, status } = useUpdaterContext();
2525
const [isUpdatePending, setIsUpdatePending] = React.useState(false);
2626
const updatePendingRef = React.useRef(false);
2727
const updateFrameRef = React.useRef<number | null>(null);
@@ -62,21 +62,23 @@ export function SidebarUpdateCompactCard({
6262
});
6363
}, [installAndRelaunch]);
6464

65+
const pending = isUpdatePending || status.state === "installing";
66+
6567
return (
6668
<SidebarCompactActionCard
6769
actionAriaLabel="Update now"
68-
actionDisabled={isUpdatePending}
70+
actionDisabled={pending}
6971
actionTestId={actionTestId}
70-
description={isUpdatePending ? "Updating" : "Click to update"}
72+
description={pending ? "Updating" : "Click to update"}
7173
dismissLabel="Dismiss update notification"
7274
icon={
73-
isUpdatePending ? (
75+
pending ? (
7476
<Spinner aria-hidden="true" className="h-5 w-5 border-2" />
7577
) : (
7678
<CircleArrowUp aria-hidden="true" className="h-5 w-5" />
7779
)
7880
}
79-
iconKey={isUpdatePending ? "pending" : "idle"}
81+
iconKey={pending ? "pending" : "idle"}
8082
onAction={handleUpdate}
8183
onDismiss={onDismiss}
8284
testId={testId}

‎desktop/tests/e2e/sidebar.spec.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,55 @@ test("shows a sidebar update card when an update is ready", async ({
328328
);
329329
});
330330

331+
// Regression test for the sidebar card not reflecting an install started from
332+
// another surface (follow-up to #1820). The header UpdateIndicator and the
333+
// sidebar compact card both render in the "ready" state; starting the install
334+
// from the header must flip the sidebar card's copy too, not just the header's.
335+
test("reflects an install started from the header update button on the sidebar card", async ({
336+
page,
337+
}) => {
338+
await page.goto("/");
339+
await expect(page.getByTestId("app-sidebar")).toBeVisible();
340+
341+
await page.evaluate(() => {
342+
const testWindow = window as Window & {
343+
__BUZZ_E2E__?: { mock?: { updateAvailable?: boolean } };
344+
};
345+
346+
testWindow.__BUZZ_E2E__ = {
347+
...(testWindow.__BUZZ_E2E__ ?? {}),
348+
mock: {
349+
...(testWindow.__BUZZ_E2E__?.mock ?? {}),
350+
restartDelayMs: 500,
351+
updateAvailable: true,
352+
},
353+
};
354+
});
355+
356+
await page.getByTestId("sidebar-profile-card").click();
357+
await page.getByTestId("profile-popover-settings").click();
358+
await page.getByTestId("settings-nav-updates").click();
359+
await page.getByRole("button", { name: "Check for Updates" }).click();
360+
await expect(page.getByTestId("settings-panel-updates")).toContainText(
361+
"Update downloaded. Click to apply.",
362+
);
363+
await page.getByTestId("settings-back-to-app").click();
364+
365+
await page.getByTestId("channel-general").click();
366+
367+
const updateCard = page.getByTestId("sidebar-update-card");
368+
await expect(updateCard).toBeVisible();
369+
await expect(updateCard).toContainText("Click to update");
370+
371+
await page
372+
.getByTestId("chat-header")
373+
.getByRole("button", { name: "Update now" })
374+
.click();
375+
376+
await expect(updateCard).toContainText("Updating");
377+
await expect(page.getByTestId("sidebar-update-now")).toBeDisabled();
378+
});
379+
331380
// Regression test for the Linux .deb auto-update guard (PR #1535).
332381
// When auto-update is not supported (e.g. Linux .deb install), the update
333382
// check must surface a "manual-required" card with a GitHub link and

0 commit comments

Comments
 (0)