fix: honor automatic updates preference and add Settings controls
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Update-banner render tests (Wave C, 2026-10-10): the banner is a pure
|
||||
* function of the last lh:update-status push — hidden without one (the
|
||||
* browser/dev world: no window.lh at all), visible with the downloaded
|
||||
* function of the shell's observational status — hidden without a bridge
|
||||
* or snapshot/event, visible with the downloaded
|
||||
* status, Restart wired to the bridge. The subscribe effect only runs
|
||||
* client-side, so the SSR pass pins the hidden state; the pushed state is
|
||||
* exercised by mounting with the bridge stubbed (classic-JSX shim as in
|
||||
@@ -17,6 +17,7 @@ import * as ReactDOMClient from "react-dom/client";
|
||||
import { flushSync } from "react-dom";
|
||||
import { parseHTML } from "linkedom";
|
||||
import UpdateBanner from "../components/update-banner.tsx";
|
||||
import type { UpdateState } from "../components/settings/update-settings.tsx";
|
||||
|
||||
// linkedom as the DOM for the interactive pass (first createRoot test in
|
||||
// the repo — the banner's push→render→click flow needs real effects).
|
||||
@@ -36,9 +37,9 @@ describe("update banner (Wave C)", () => {
|
||||
});
|
||||
|
||||
it("renders nothing when the bridge exists but no status has arrived", () => {
|
||||
const listeners: Array<(s: { status: string; version: string | null }) => void> = [];
|
||||
const listeners: Array<(s: UpdateState) => void> = [];
|
||||
(window as { lh?: unknown }).lh = {
|
||||
onUpdateStatus: (cb: (s: { status: string; version: string | null }) => void) => {
|
||||
onUpdateStatus: (cb: (s: UpdateState) => void) => {
|
||||
listeners.push(cb);
|
||||
return () => {};
|
||||
},
|
||||
@@ -50,10 +51,10 @@ describe("update banner (Wave C)", () => {
|
||||
});
|
||||
|
||||
it("shows the version + Restart once the downloaded push arrives, and Restart installs", async () => {
|
||||
let pushed: ((s: { status: string; version: string | null }) => void) | null = null;
|
||||
let pushed: ((s: UpdateState) => void) | null = null;
|
||||
let installed = 0;
|
||||
(window as { lh?: unknown }).lh = {
|
||||
onUpdateStatus: (cb: (s: { status: string; version: string | null }) => void) => {
|
||||
onUpdateStatus: (cb: (s: UpdateState) => void) => {
|
||||
pushed = cb;
|
||||
return () => {};
|
||||
},
|
||||
@@ -68,7 +69,7 @@ describe("update banner (Wave C)", () => {
|
||||
assert.equal(host.innerHTML, "", "hidden before the push");
|
||||
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
flushSync(() => pushed?.({ status: "downloaded", version: "0.3.1" }));
|
||||
flushSync(() => pushed?.({ status: "downloaded", version: "0.3.1", revision: 1 }));
|
||||
assert.ok(host.innerHTML.includes("0.3.1"), "the version renders");
|
||||
assert.ok(host.innerHTML.includes("Restart"), "the restart affordance renders");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user