test(desktop): disarm channel read latch on release

Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz>
Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz>
This commit is contained in:
npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta
2026-08-02 23:14:13 -04:00
parent 15b0c9647c
commit 86c7fb185b
2 changed files with 51 additions and 2 deletions
+3 -2
View File
@@ -1254,9 +1254,9 @@ declare global {
__BUZZ_E2E_RELEASE_OBSERVER_ARCHIVE_POLICY__?: () => number;
/** Number of observer archive policy commands currently held by the seam. */
__BUZZ_E2E_OBSERVER_ARCHIVE_POLICY_PENDING__?: number;
/** Hold channel reads until released. */
/** Hold the next channel read until released. */
__BUZZ_E2E_DEFER_NEXT_CHANNELS_READ__?: () => void;
/** Release every channel read held by the explicit E2E seam. */
/** Disarm the latch and release the held channel read, if any. */
__BUZZ_E2E_RELEASE_CHANNELS_READ__?: () => number;
/** Number of channel reads currently held by the seam. */
__BUZZ_E2E_CHANNELS_READ_PENDING__?: number;
@@ -9798,6 +9798,7 @@ export function maybeInstallE2eTauriMocks() {
deferNextChannelsRead = true;
};
window.__BUZZ_E2E_RELEASE_CHANNELS_READ__ = () => {
deferNextChannelsRead = false;
const queued = deferredChannelsReadQueue.splice(0);
window.__BUZZ_E2E_CHANNELS_READ_PENDING__ = 0;
for (const resolve of queued) resolve();
+48
View File
@@ -467,6 +467,31 @@ test.describe("community rail", () => {
),
)
.not.toBeNull();
expect(
await page.evaluate(async () => {
const testWindow = window as Window & {
__BUZZ_E2E_DEFER_NEXT_CHANNELS_READ__?: () => void;
__BUZZ_E2E_RELEASE_CHANNELS_READ__?: () => number;
__BUZZ_E2E_CHANNELS_READ_PENDING__?: number;
__BUZZ_E2E_INVOKE_MOCK_COMMAND__?: (
command: string,
) => Promise<unknown>;
};
const deferNext = testWindow.__BUZZ_E2E_DEFER_NEXT_CHANNELS_READ__;
const release = testWindow.__BUZZ_E2E_RELEASE_CHANNELS_READ__;
const invoke = testWindow.__BUZZ_E2E_INVOKE_MOCK_COMMAND__;
if (!deferNext || !release || !invoke) {
throw new Error("missing channel-read latch seam");
}
deferNext();
const released = release();
await invoke("get_channels");
return {
released,
pending: testWindow.__BUZZ_E2E_CHANNELS_READ_PENDING__,
};
}),
).toEqual({ released: 0, pending: 0 });
await page.evaluate(() => {
const source = window.localStorage.getItem(
"buzz-channels.v1:ws://localhost:3000",
@@ -567,6 +592,15 @@ test.describe("community rail", () => {
),
)
.toBe(1);
await page.evaluate(() => {
const deferNext = (
window as Window & {
__BUZZ_E2E_DEFER_NEXT_CHANNELS_READ__?: () => void;
}
).__BUZZ_E2E_DEFER_NEXT_CHANNELS_READ__;
if (!deferNext) throw new Error("missing channel-read defer seam");
deferNext();
});
const released = await page.evaluate(
() =>
(
@@ -576,6 +610,20 @@ test.describe("community rail", () => {
).__BUZZ_E2E_RELEASE_CHANNELS_READ__?.() ?? 0,
);
expect(released).toBe(1);
await page.evaluate(async () => {
const testWindow = window as Window & {
__BUZZ_E2E_INVOKE_MOCK_COMMAND__?: (
command: string,
) => Promise<unknown>;
__BUZZ_E2E_CHANNELS_READ_PENDING__?: number;
};
const invoke = testWindow.__BUZZ_E2E_INVOKE_MOCK_COMMAND__;
if (!invoke) throw new Error("missing mock command seam");
await invoke("get_channels");
if (testWindow.__BUZZ_E2E_CHANNELS_READ_PENDING__ !== 0) {
throw new Error("release left the channel-read latch armed");
}
});
await expect
.poll(() =>
page.evaluate(