mirror of
https://github.com/block/buzz.git
synced 2026-11-12 12:22:06 +00:00
Signed-off-by: Tyler Longwell <109685178+tlongwell-block@users.noreply.github.com> Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Dawn (sprout agent) <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co>
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { installMockBridge } from "../helpers/bridge";
|
|
|
|
async function setMockWebsocketSendsStalled(
|
|
page: import("@playwright/test").Page,
|
|
stall: boolean,
|
|
) {
|
|
await page.evaluate((shouldStall) => {
|
|
const setter = (
|
|
window as Window & {
|
|
__SPROUT_E2E_SET_STALL_WEBSOCKET_SENDS__?: (stall: boolean) => void;
|
|
}
|
|
).__SPROUT_E2E_SET_STALL_WEBSOCKET_SENDS__;
|
|
if (!setter) {
|
|
throw new Error("E2E websocket stall setter is not installed.");
|
|
}
|
|
setter(shouldStall);
|
|
}, stall);
|
|
}
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await installMockBridge(page);
|
|
});
|
|
|
|
test("passive relay watchdog does not write while the websocket is half-open", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
"Welcome to #general",
|
|
);
|
|
|
|
await setMockWebsocketSendsStalled(page, true);
|
|
|
|
// Wait longer than the old active-probe interval. If the watchdog still
|
|
// writes probes, the mocked plugin send would never resolve and mark the
|
|
// mock plugin mutex as wedged. Future reconnects would then be unable to
|
|
// register, matching the tauri-plugin-websocket failure mode. The passive
|
|
// watchdog should perform no writes of its own during this window.
|
|
await page.waitForTimeout(22_000);
|
|
|
|
await setMockWebsocketSendsStalled(page, false);
|
|
const message = `recovered after passive idle ${Date.now()}`;
|
|
await page.getByTestId("message-input").fill(message);
|
|
await page.getByTestId("send-message").click();
|
|
await expect(page.getByTestId("message-timeline")).toContainText(message);
|
|
});
|