Skip to content

Commit 8041609

Browse files
committed
Fix hanging tests
I am not really sure what ws.connected is doing but it seems to somehow block updates. Something to do with `act()` maybe? Basically, the useEffect creating the terminal never updates once the config query finishes, so the web socket is never created, and the test hangs forever. It might have been working before only because the web socket was created using xstate rather than useEffect and once it connected it would unblock and React could update again but this is just a guess.
1 parent 0fabcb7 commit 8041609

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

site/src/pages/TerminalPage/TerminalPage.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("TerminalPage", () => {
127127
const { container } = await renderTerminal();
128128

129129
// Then
130-
await ws.connected;
130+
await ws.nextMessage;
131131
ws.send(text);
132132
await expectTerminalText(container, text);
133133
ws.close();
@@ -143,7 +143,6 @@ describe("TerminalPage", () => {
143143
await renderTerminal();
144144

145145
// Then
146-
await ws.connected;
147146
const msg = await ws.nextMessage;
148147
const req = JSON.parse(new TextDecoder().decode(msg as Uint8Array));
149148
expect(req.height).toBeGreaterThan(0);
@@ -164,7 +163,7 @@ describe("TerminalPage", () => {
164163
);
165164

166165
// Then
167-
await ws.connected;
166+
await ws.nextMessage;
168167
ws.send(text);
169168
await expectTerminalText(container, text);
170169
ws.close();

0 commit comments

Comments
 (0)