@assistant-ui/react-statewire 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/StatewireThread.d.ts +15 -4
- package/dist/StatewireThread.d.ts.map +1 -1
- package/dist/StatewireThread.js +30 -22
- package/dist/StatewireThread.js.map +1 -1
- package/dist/runCommands.d.ts.map +1 -1
- package/dist/runCommands.js +2 -1
- package/dist/runCommands.js.map +1 -1
- package/package.json +2 -2
- package/src/StatewireThread.drafts.test.tsx +12 -16
- package/src/StatewireThread.failed.test.tsx +5 -5
- package/src/StatewireThread.retract.test.tsx +3 -3
- package/src/StatewireThread.runs.test.tsx +13 -9
- package/src/StatewireThread.test.tsx +93 -30
- package/src/StatewireThread.ts +99 -53
- package/src/runCommands.test.ts +31 -0
- package/src/runCommands.ts +8 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
3
|
// Contract tests for the composer draft storage seam: restore on mount,
|
|
4
|
-
//
|
|
4
|
+
// write-through in the commit that applies a change, clear when consumed.
|
|
5
5
|
|
|
6
6
|
import { act, render, waitFor } from "@testing-library/react";
|
|
7
7
|
import type { FC } from "react";
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { describe, expect, it } from "vitest";
|
|
10
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
10
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
11
11
|
import { flushTapSync, resource } from "@assistant-ui/tap";
|
|
12
12
|
import {
|
|
13
13
|
StatewireReject,
|
|
@@ -84,7 +84,7 @@ const mountThread = (
|
|
|
84
84
|
const [storage, setStorage] =
|
|
85
85
|
useState<StatewireThread.Options<ServerState>["storage"]>();
|
|
86
86
|
knobs.setStorage = (element) => setStorage({ composer: element });
|
|
87
|
-
const
|
|
87
|
+
const config = AuiConfig({
|
|
88
88
|
thread: StatewireThread({
|
|
89
89
|
initialState: { messages: [], status: "ready", runs: [] },
|
|
90
90
|
converter,
|
|
@@ -93,7 +93,7 @@ const mountThread = (
|
|
|
93
93
|
}),
|
|
94
94
|
});
|
|
95
95
|
return (
|
|
96
|
-
<AuiProvider
|
|
96
|
+
<AuiProvider config={config}>
|
|
97
97
|
<Capture />
|
|
98
98
|
</AuiProvider>
|
|
99
99
|
);
|
|
@@ -136,13 +136,11 @@ describe("StatewireThread composer draft storage", () => {
|
|
|
136
136
|
});
|
|
137
137
|
await waitFor(() => expect(composerOf(aui).getState().type).toBe("thread"));
|
|
138
138
|
|
|
139
|
-
act(() =>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
expect(store.cell.draft).toEqual({ text: "hello", attachments: [] });
|
|
145
|
-
});
|
|
139
|
+
act(() => flushTapSync(() => composerOf(aui).setText("hel")));
|
|
140
|
+
// the write landed in the commit that applied the text — no await, no timers
|
|
141
|
+
expect(store.cell.draft).toEqual({ text: "hel", attachments: [] });
|
|
142
|
+
act(() => flushTapSync(() => composerOf(aui).setText("hello")));
|
|
143
|
+
expect(store.cell.draft).toEqual({ text: "hello", attachments: [] });
|
|
146
144
|
expect(store.cell.log).toEqual(["write:hel", "write:hello"]);
|
|
147
145
|
});
|
|
148
146
|
|
|
@@ -155,11 +153,9 @@ describe("StatewireThread composer draft storage", () => {
|
|
|
155
153
|
});
|
|
156
154
|
await waitFor(() => expect(composerOf(aui).getState().type).toBe("thread"));
|
|
157
155
|
|
|
158
|
-
act(() =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
expect(store.cell.draft).toBeUndefined();
|
|
162
|
-
});
|
|
156
|
+
act(() => flushTapSync(() => composerOf(aui).setText("hello")));
|
|
157
|
+
act(() => flushTapSync(() => composerOf(aui).send()));
|
|
158
|
+
expect(store.cell.draft).toBeUndefined();
|
|
163
159
|
expect(store.cell.log).toEqual(["write:hello", "clear"]);
|
|
164
160
|
await waitFor(() => expect(server.received).toHaveLength(1));
|
|
165
161
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { act, render, waitFor } from "@testing-library/react";
|
|
8
8
|
import type { FC } from "react";
|
|
9
9
|
import { describe, expect, it } from "vitest";
|
|
10
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
10
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
11
11
|
import { StatewireHttp } from "statewire";
|
|
12
12
|
import { asStatewireExtras, StatewireThread } from "./StatewireThread";
|
|
13
13
|
import { useStatewireRuns } from "./hooks";
|
|
@@ -94,9 +94,9 @@ const createSettlingServer = (init?: Partial<ServerState>) => {
|
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
96
|
syn: {
|
|
97
|
-
version: "2026-09-
|
|
97
|
+
version: "2026-09-30",
|
|
98
98
|
protocols: [
|
|
99
|
-
{ name: "default", version: "2026-09-
|
|
99
|
+
{ name: "default", version: "2026-09-30", seq: rec.seq },
|
|
100
100
|
],
|
|
101
101
|
},
|
|
102
102
|
}),
|
|
@@ -145,7 +145,7 @@ const mountThread = (
|
|
|
145
145
|
return null;
|
|
146
146
|
};
|
|
147
147
|
const App: FC = () => {
|
|
148
|
-
const
|
|
148
|
+
const config = AuiConfig({
|
|
149
149
|
thread: StatewireThread<ServerState>({
|
|
150
150
|
initialState: INITIAL_STATE,
|
|
151
151
|
converter,
|
|
@@ -153,7 +153,7 @@ const mountThread = (
|
|
|
153
153
|
}),
|
|
154
154
|
});
|
|
155
155
|
return (
|
|
156
|
-
<AuiProvider
|
|
156
|
+
<AuiProvider config={config}>
|
|
157
157
|
<Capture />
|
|
158
158
|
</AuiProvider>
|
|
159
159
|
);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { act, render, waitFor } from "@testing-library/react";
|
|
9
9
|
import type { FC } from "react";
|
|
10
10
|
import { describe, expect, it } from "vitest";
|
|
11
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
11
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
12
12
|
import { resource } from "@assistant-ui/tap";
|
|
13
13
|
import {
|
|
14
14
|
StatewireReject,
|
|
@@ -96,7 +96,7 @@ const mountThread = (
|
|
|
96
96
|
return null;
|
|
97
97
|
};
|
|
98
98
|
const App: FC = () => {
|
|
99
|
-
const
|
|
99
|
+
const config = AuiConfig({
|
|
100
100
|
thread: StatewireThread<ServerState>({
|
|
101
101
|
initialState: { messages: [], status: "ready", runs: [] },
|
|
102
102
|
converter,
|
|
@@ -104,7 +104,7 @@ const mountThread = (
|
|
|
104
104
|
}),
|
|
105
105
|
});
|
|
106
106
|
return (
|
|
107
|
-
<AuiProvider
|
|
107
|
+
<AuiProvider config={config}>
|
|
108
108
|
<Capture />
|
|
109
109
|
</AuiProvider>
|
|
110
110
|
);
|
|
@@ -9,7 +9,7 @@ import { useState } from "react";
|
|
|
9
9
|
import type { FC } from "react";
|
|
10
10
|
import type { ExternalThreadMessage } from "@assistant-ui/core/store";
|
|
11
11
|
import { describe, expect, it } from "vitest";
|
|
12
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
12
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
13
13
|
import { resource, withKey } from "@assistant-ui/tap";
|
|
14
14
|
import { StatewireHttp } from "statewire";
|
|
15
15
|
import { useStatewireCommands, useStatewireState } from "statewire/host";
|
|
@@ -172,8 +172,12 @@ const createRemoteServer = (
|
|
|
172
172
|
const body = new ReadableStream<Uint8Array>({
|
|
173
173
|
start: (c) => {
|
|
174
174
|
stream = c;
|
|
175
|
-
// Reattach attempts after a fin
|
|
176
|
-
|
|
175
|
+
// Reattach attempts after a fin fail, so the immediate redial
|
|
176
|
+
// gives way to the retrying state that carries the episode.
|
|
177
|
+
if (finSent) {
|
|
178
|
+
c.close();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
177
181
|
const sendSnapshot = () => {
|
|
178
182
|
c.enqueue(
|
|
179
183
|
encoder.encode(
|
|
@@ -187,9 +191,9 @@ const createRemoteServer = (
|
|
|
187
191
|
},
|
|
188
192
|
],
|
|
189
193
|
syn: {
|
|
190
|
-
version: "2026-09-
|
|
194
|
+
version: "2026-09-30",
|
|
191
195
|
protocols: [
|
|
192
|
-
{ name: protocol, version: "2026-09-
|
|
196
|
+
{ name: protocol, version: "2026-09-30", seq: rec.seq },
|
|
193
197
|
],
|
|
194
198
|
},
|
|
195
199
|
}),
|
|
@@ -246,7 +250,7 @@ const mountThread = (
|
|
|
246
250
|
return null;
|
|
247
251
|
};
|
|
248
252
|
const App: FC = () => {
|
|
249
|
-
const
|
|
253
|
+
const config = AuiConfig({
|
|
250
254
|
thread: StatewireThread<RunsServerState>({
|
|
251
255
|
initialState: INITIAL_STATE,
|
|
252
256
|
converter,
|
|
@@ -254,7 +258,7 @@ const mountThread = (
|
|
|
254
258
|
}),
|
|
255
259
|
});
|
|
256
260
|
return (
|
|
257
|
-
<AuiProvider
|
|
261
|
+
<AuiProvider config={config}>
|
|
258
262
|
<Capture />
|
|
259
263
|
</AuiProvider>
|
|
260
264
|
);
|
|
@@ -774,7 +778,7 @@ describe("StatewireThread runs mode", () => {
|
|
|
774
778
|
withKey("a", serverA.transport),
|
|
775
779
|
);
|
|
776
780
|
cell.swap = () => setTransport(() => withKey("b", serverB.transport));
|
|
777
|
-
const
|
|
781
|
+
const config = AuiConfig({
|
|
778
782
|
thread: StatewireThread<RunsServerState>({
|
|
779
783
|
initialState: preload,
|
|
780
784
|
converter,
|
|
@@ -782,7 +786,7 @@ describe("StatewireThread runs mode", () => {
|
|
|
782
786
|
}),
|
|
783
787
|
});
|
|
784
788
|
return (
|
|
785
|
-
<AuiProvider
|
|
789
|
+
<AuiProvider config={config}>
|
|
786
790
|
<Capture />
|
|
787
791
|
</AuiProvider>
|
|
788
792
|
);
|
|
@@ -7,7 +7,7 @@ import { act, render, waitFor } from "@testing-library/react";
|
|
|
7
7
|
import type { FC, ReactNode } from "react";
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { describe, expect, it } from "vitest";
|
|
10
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
10
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
11
11
|
import { resource } from "@assistant-ui/tap";
|
|
12
12
|
import {
|
|
13
13
|
StatewireReject,
|
|
@@ -225,11 +225,11 @@ const mountThread = (
|
|
|
225
225
|
return null;
|
|
226
226
|
};
|
|
227
227
|
const App: FC = () => {
|
|
228
|
-
const
|
|
228
|
+
const config = AuiConfig({
|
|
229
229
|
thread: StatewireThread({ initialState: INITIAL_STATE, ...options }),
|
|
230
230
|
});
|
|
231
231
|
return (
|
|
232
|
-
<AuiProvider
|
|
232
|
+
<AuiProvider config={config}>
|
|
233
233
|
<Capture />
|
|
234
234
|
{children}
|
|
235
235
|
</AuiProvider>
|
|
@@ -586,7 +586,7 @@ describe("StatewireThread", () => {
|
|
|
586
586
|
expect(seen).toHaveLength(2);
|
|
587
587
|
});
|
|
588
588
|
|
|
589
|
-
it("fires onConnectionChange with the status
|
|
589
|
+
it("fires onConnectionChange with the initial status, then once per transition", async () => {
|
|
590
590
|
const statuses: string[] = [];
|
|
591
591
|
const mock = createMockTransport<ServerState>(INITIAL_STATE);
|
|
592
592
|
mountThread({
|
|
@@ -595,11 +595,15 @@ describe("StatewireThread", () => {
|
|
|
595
595
|
onConnectionChange: (connection) => statuses.push(connection.status),
|
|
596
596
|
});
|
|
597
597
|
|
|
598
|
-
await waitFor(() =>
|
|
598
|
+
await waitFor(() =>
|
|
599
|
+
expect(statuses).toEqual(["connecting", "connected"]),
|
|
600
|
+
);
|
|
599
601
|
await mock.finish("gone");
|
|
600
|
-
await waitFor(() =>
|
|
602
|
+
await waitFor(() =>
|
|
603
|
+
expect(statuses).toEqual(["connecting", "connected", "stopped"]),
|
|
604
|
+
);
|
|
601
605
|
await new Promise((r) => setTimeout(r, 20));
|
|
602
|
-
expect(statuses).toEqual(["connected", "stopped"]);
|
|
606
|
+
expect(statuses).toEqual(["connecting", "connected", "stopped"]);
|
|
603
607
|
});
|
|
604
608
|
|
|
605
609
|
it("stays quiet on unrelated re-renders and callback identity changes", async () => {
|
|
@@ -610,7 +614,7 @@ describe("StatewireThread", () => {
|
|
|
610
614
|
const App: FC = () => {
|
|
611
615
|
const [, setTick] = useState(0);
|
|
612
616
|
knobs.rerender = () => setTick((t) => t + 1);
|
|
613
|
-
const
|
|
617
|
+
const config = AuiConfig({
|
|
614
618
|
thread: StatewireThread({
|
|
615
619
|
initialState: INITIAL_STATE,
|
|
616
620
|
transport: server.transport,
|
|
@@ -620,7 +624,7 @@ describe("StatewireThread", () => {
|
|
|
620
624
|
statuses.push(connection.status),
|
|
621
625
|
}),
|
|
622
626
|
});
|
|
623
|
-
return <AuiProvider
|
|
627
|
+
return <AuiProvider config={config}>{null}</AuiProvider>;
|
|
624
628
|
};
|
|
625
629
|
render(<App />);
|
|
626
630
|
|
|
@@ -637,21 +641,14 @@ describe("StatewireThread", () => {
|
|
|
637
641
|
});
|
|
638
642
|
|
|
639
643
|
describe("contextSync: command-send", () => {
|
|
640
|
-
const contextValueOf = (
|
|
641
|
-
protocol
|
|
642
|
-
|
|
643
|
-
params: unknown[];
|
|
644
|
-
}) => {
|
|
645
|
-
expect([command.protocol, command.method]).toEqual([
|
|
646
|
-
"default/context",
|
|
647
|
-
"set",
|
|
648
|
-
]);
|
|
649
|
-
return command.params[0] as Record<string, unknown>;
|
|
644
|
+
const contextValueOf = (entry: { protocol: string; value: unknown }) => {
|
|
645
|
+
expect(entry.protocol).toBe("default");
|
|
646
|
+
return entry.value as Record<string, unknown>;
|
|
650
647
|
};
|
|
651
648
|
|
|
652
649
|
it("sends the ambient model context on connect and on every change", async () => {
|
|
653
650
|
const mock = createMockTransport<ServerState>(INITIAL_STATE, "default", {
|
|
654
|
-
ephemeral: [
|
|
651
|
+
ephemeral: [],
|
|
655
652
|
});
|
|
656
653
|
const { aui } = mountThread({
|
|
657
654
|
transport: mock.transport,
|
|
@@ -659,28 +656,28 @@ describe("StatewireThread", () => {
|
|
|
659
656
|
contextSync: "command-send",
|
|
660
657
|
});
|
|
661
658
|
|
|
662
|
-
await waitFor(() => expect(mock.
|
|
663
|
-
const initial = contextValueOf(mock.
|
|
659
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(1));
|
|
660
|
+
const initial = contextValueOf(mock.contexts[0]!);
|
|
664
661
|
expect(initial["system"]).toBeUndefined();
|
|
665
662
|
|
|
666
663
|
aui()
|
|
667
664
|
.modelContext()
|
|
668
665
|
.register({ getModelContext: () => ({ system: "be nice" }) });
|
|
669
666
|
|
|
670
|
-
await waitFor(() => expect(mock.
|
|
671
|
-
expect(contextValueOf(mock.
|
|
667
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(2));
|
|
668
|
+
expect(contextValueOf(mock.contexts[1]!)["system"]).toBe("be nice");
|
|
672
669
|
});
|
|
673
670
|
|
|
674
671
|
it("skips resends while the serialized context is unchanged", async () => {
|
|
675
672
|
const mock = createMockTransport<ServerState>(INITIAL_STATE, "default", {
|
|
676
|
-
ephemeral: [
|
|
673
|
+
ephemeral: [],
|
|
677
674
|
});
|
|
678
675
|
const { aui } = mountThread({
|
|
679
676
|
transport: mock.transport,
|
|
680
677
|
converter,
|
|
681
678
|
contextSync: "command-send",
|
|
682
679
|
});
|
|
683
|
-
await waitFor(() => expect(mock.
|
|
680
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(1));
|
|
684
681
|
|
|
685
682
|
// notifies subscribers without changing the merged context
|
|
686
683
|
aui()
|
|
@@ -690,14 +687,35 @@ describe("StatewireThread", () => {
|
|
|
690
687
|
.modelContext()
|
|
691
688
|
.register({ getModelContext: () => ({ system: "be nice" }) });
|
|
692
689
|
|
|
693
|
-
await waitFor(() => expect(mock.
|
|
694
|
-
expect(contextValueOf(mock.
|
|
690
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(2));
|
|
691
|
+
expect(contextValueOf(mock.contexts[1]!)["system"]).toBe("be nice");
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
it("restores native context on reconnect without an ephemeral command lane", async () => {
|
|
695
|
+
const mock = createMockTransport<ServerState>(INITIAL_STATE);
|
|
696
|
+
const { aui } = mountThread({
|
|
697
|
+
transport: mock.transport,
|
|
698
|
+
converter,
|
|
699
|
+
contextSync: "command-send",
|
|
700
|
+
});
|
|
701
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(1));
|
|
702
|
+
aui()
|
|
703
|
+
.modelContext()
|
|
704
|
+
.register({ getModelContext: () => ({ system: "be nice" }) });
|
|
705
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(2));
|
|
706
|
+
act(() =>
|
|
707
|
+
asStatewireExtras(aui().thread().getState().extras).reconnect(),
|
|
708
|
+
);
|
|
709
|
+
await waitFor(() => expect(mock.contexts).toHaveLength(3));
|
|
710
|
+
expect(contextValueOf(mock.contexts[2]!)).toEqual({ system: "be nice" });
|
|
711
|
+
expect(mock.commands).toEqual([]);
|
|
695
712
|
});
|
|
696
713
|
|
|
697
714
|
it("stays off the wire without the option", async () => {
|
|
698
715
|
const mock = createMockTransport<ServerState>(INITIAL_STATE);
|
|
699
716
|
const { aui } = mountThread({ transport: mock.transport, converter });
|
|
700
717
|
await waitFor(() => expect(threadStatus(aui())).toBe("ready"));
|
|
718
|
+
expect(mock.contexts).toEqual([]);
|
|
701
719
|
expect(mock.commands).toEqual([]);
|
|
702
720
|
});
|
|
703
721
|
});
|
|
@@ -898,6 +916,7 @@ describe("StatewireThread", () => {
|
|
|
898
916
|
id: expect.any(String),
|
|
899
917
|
role: "user",
|
|
900
918
|
parts: [{ type: "text", text: "better question" }],
|
|
919
|
+
metadata: {},
|
|
901
920
|
},
|
|
902
921
|
}),
|
|
903
922
|
);
|
|
@@ -937,6 +956,7 @@ describe("StatewireThread", () => {
|
|
|
937
956
|
id: expect.any(String),
|
|
938
957
|
role: "user",
|
|
939
958
|
parts: [{ type: "text", text: "better question" }],
|
|
959
|
+
metadata: {},
|
|
940
960
|
},
|
|
941
961
|
},
|
|
942
962
|
]),
|
|
@@ -1328,6 +1348,45 @@ describe("StatewireThread", () => {
|
|
|
1328
1348
|
return trackingConverter;
|
|
1329
1349
|
};
|
|
1330
1350
|
|
|
1351
|
+
it("hands the converter and extras the documents, mounted map, invoke and connection", async () => {
|
|
1352
|
+
const passes: StatewireThread.ConnectionMetadata[] = [];
|
|
1353
|
+
const mock = createMockTransport<ServerState>(INITIAL_STATE);
|
|
1354
|
+
const { aui } = mountThread({
|
|
1355
|
+
transport: mock.transport,
|
|
1356
|
+
converter: (state, meta) => {
|
|
1357
|
+
passes.push(meta);
|
|
1358
|
+
return { ...converter(state, meta), state: { pass: passes.length } };
|
|
1359
|
+
},
|
|
1360
|
+
});
|
|
1361
|
+
await waitFor(() => expect(threadStatus(aui())).toBe("ready"));
|
|
1362
|
+
await mock.setState({
|
|
1363
|
+
...INITIAL_STATE,
|
|
1364
|
+
messages: [{ id: "m1", role: "user", text: "hi" }],
|
|
1365
|
+
});
|
|
1366
|
+
await waitFor(() => expect(threadTexts(aui)).toEqual(["hi"]));
|
|
1367
|
+
|
|
1368
|
+
const first = passes[0]!;
|
|
1369
|
+
const last = passes.at(-1)!;
|
|
1370
|
+
expect(passes.length).toBeGreaterThan(1);
|
|
1371
|
+
expect(last.documents).toBe(first.documents);
|
|
1372
|
+
expect(last.invoke).toBe(first.invoke);
|
|
1373
|
+
expect(last.mounted.get(0)?.value).toMatchObject({
|
|
1374
|
+
messages: [{ id: "m1" }],
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
const extras = asStatewireExtras(aui().thread().getState().extras);
|
|
1378
|
+
expect(extras.connection.status).toBe("connected");
|
|
1379
|
+
expect(extras.documents).toBe(first.documents);
|
|
1380
|
+
expect(extras.invoke).toBe(first.invoke);
|
|
1381
|
+
expect(extras.state).toEqual({ pass: passes.length });
|
|
1382
|
+
void extras.invoke("default", "ping", [1]);
|
|
1383
|
+
await waitFor(() =>
|
|
1384
|
+
expect(mock.commands).toEqual([
|
|
1385
|
+
{ protocol: "default", method: "ping", params: [1] },
|
|
1386
|
+
]),
|
|
1387
|
+
);
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1331
1390
|
it("projects connection transitions into the converter", async () => {
|
|
1332
1391
|
const seen: string[] = [];
|
|
1333
1392
|
const mock = createMockTransport<ServerState>(INITIAL_STATE);
|
|
@@ -1366,9 +1425,13 @@ describe("StatewireThread", () => {
|
|
|
1366
1425
|
await mock.finish("gone");
|
|
1367
1426
|
await waitFor(() => expect(seen.at(-1)).toBe("stopped"));
|
|
1368
1427
|
|
|
1369
|
-
|
|
1428
|
+
act(() =>
|
|
1429
|
+
asStatewireExtras(aui().thread().getState().extras).reconnect(),
|
|
1430
|
+
);
|
|
1370
1431
|
|
|
1371
|
-
|
|
1432
|
+
// A fresh episode: first dial at attempt 0, then the dead server fails it.
|
|
1433
|
+
expect(seen.at(-1)).toBe("connecting");
|
|
1434
|
+
await waitFor(() => expect(seen.at(-1)).toBe("retrying"));
|
|
1372
1435
|
});
|
|
1373
1436
|
});
|
|
1374
1437
|
});
|