web: settings destination with connection, workspace and templates (L1)
Completes the item: the Settings view, its pure helpers and the client's socket-replacement path, plus the fix the review required (a header-side URL correction clears the Settings field's own error) and a smoke check for it.
This commit is contained in:
@@ -182,3 +182,26 @@ test("disconnect goes idle and does not schedule a reconnect", () => {
|
||||
assert.equal(client.state.retrying, false);
|
||||
assert.deepEqual(ws.closed, { code: 1000, reason: "client closing" });
|
||||
});
|
||||
|
||||
test("connecting again replaces the socket and ignores the superseded one", async () => {
|
||||
// The Settings `Connect` action is connect-only and must be safe to press while
|
||||
// connected: it re-opens the endpoint (Android's connectLocked replaces the
|
||||
// socket) instead of leaving two live sockets or letting the old one's late
|
||||
// close mark the new connection disconnected.
|
||||
const { client, ws } = connectedClient();
|
||||
const pending = client.call({ type: "ping" }); // sent on the old socket
|
||||
await flush();
|
||||
client.connect(VALID);
|
||||
const replacement = FakeWebSocket.instances.at(-1);
|
||||
assert.notEqual(replacement, ws);
|
||||
assert.equal(client.state.kind, "connecting");
|
||||
await assert.rejects(() => pending, /Connection replaced/);
|
||||
assert.deepEqual(ws.closed, { code: 1000, reason: "superseded" });
|
||||
|
||||
replacement.open();
|
||||
assert.equal(client.state.kind, "connected");
|
||||
// The superseded socket's late failure must not touch the live connection.
|
||||
ws.drop(1006);
|
||||
assert.equal(client.state.kind, "connected");
|
||||
assert.equal(client.state.retrying, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user