Open History to see the last commit
1import { beforeEach, describe, expect, it } from "vite-plus/test";
2
3import {
4 completeRelayClientInstallDialogClose,
5 finishRelayClientInstall,
6 readRelayClientInstallDialogState,
7 reportRelayClientInstallProgress,
8 requestRelayClientInstallConfirmation,
9 resetRelayClientInstallDialogForTests,
10 respondToRelayClientInstallConfirmation,
11} from "./relayClientInstallDialog";
12
13describe("relay client install dialog coordinator", () => {
14 beforeEach(() => {
15 resetRelayClientInstallDialogForTests();
16 });
17
18 it("moves a confirmed installation through streamed progress stages", async () => {
19 const confirmation = requestRelayClientInstallConfirmation("2026.5.2");
20 expect(readRelayClientInstallDialogState()).toEqual({
21 status: "confirming",
22 version: "2026.5.2",
23 });
24
25 respondToRelayClientInstallConfirmation(true);
26 await expect(confirmation).resolves.toBe(true);
27 expect(readRelayClientInstallDialogState()).toEqual({
28 status: "installing",
29 version: "2026.5.2",
30 stage: "checking",
31 });
32
33 reportRelayClientInstallProgress({ type: "progress", stage: "downloading" });
34 expect(readRelayClientInstallDialogState()).toEqual({
35 status: "installing",
36 version: "2026.5.2",
37 stage: "downloading",
38 });
39
40 finishRelayClientInstall();
41 expect(readRelayClientInstallDialogState()).toEqual({
42 status: "closing",
43 view: {
44 status: "installing",
45 version: "2026.5.2",
46 stage: "downloading",
47 },
48 });
49
50 completeRelayClientInstallDialogClose();
51 expect(readRelayClientInstallDialogState()).toEqual({ status: "idle" });
52 });
53
54 it("returns to idle when installation is declined", async () => {
55 const confirmation = requestRelayClientInstallConfirmation("2026.5.2");
56 respondToRelayClientInstallConfirmation(false);
57
58 await expect(confirmation).resolves.toBe(false);
59 expect(readRelayClientInstallDialogState()).toEqual({
60 status: "closing",
61 view: {
62 status: "confirming",
63 version: "2026.5.2",
64 },
65 });
66
67 completeRelayClientInstallDialogClose();
68 expect(readRelayClientInstallDialogState()).toEqual({ status: "idle" });
69 });
70});