feat: add extension update check

This commit is contained in:
2026-05-19 18:50:03 +08:00
parent 703a095c08
commit 02d9063a11
22 changed files with 919 additions and 18 deletions
+44
View File
@@ -48,6 +48,50 @@ describe("background-index", () => {
expect(sendResponse).toHaveBeenCalledWith({ ok: true });
});
test("downloads extension update assets", async () => {
const listeners: Array<
(message: unknown, sender: unknown, sendResponse: (response: unknown) => void) => boolean | void
> = [];
const download = vi.fn(async () => undefined);
const sendResponse = vi.fn();
registerBackgroundMessageHandler({
downloads: {
download
},
runtime: {
onMessage: {
addListener(listener) {
listeners.push(listener);
}
}
}
});
const result = listeners[0](
{
filename: "star-chart-search-enhancer-internal.zip",
type: "update:download",
url: "https://cos.example.com/star-chart-search-enhancer/releases/0.2.0421.3/star-chart-search-enhancer-internal.zip"
},
{},
sendResponse
);
expect(result).toBe(true);
await new Promise((resolve) => setTimeout(resolve, 0));
expect(download).toHaveBeenCalledWith({
filename: "star-chart-search-enhancer-internal.zip",
saveAs: true,
url: "https://cos.example.com/star-chart-search-enhancer/releases/0.2.0421.3/star-chart-search-enhancer-internal.zip"
});
expect(sendResponse).toHaveBeenCalledWith({
ok: true,
type: "update:download-ack"
});
});
test("responds to auth:get-state with auth status", async () => {
const listeners: Array<
(message: unknown, sender: unknown, sendResponse: (response: unknown) => void) => boolean | void