-
Notifications
You must be signed in to change notification settings - Fork 4.6k
test(desktop): stabilize unread and audio release smoke fixtures #7821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
| import { | ||
| createMockSubscription, | ||
| hasMockSubscription, | ||
| } from "./e2eBridgeSubscriptions.ts"; | ||
|
|
||
| const ready = (filters, channel = "channel", kind = 9, exact = true) => | ||
| hasMockSubscription([createMockSubscription(filters)], channel, kind, exact); | ||
|
|
||
| test("channel readiness rejects global-only, wrong-channel and wrong-kind REQs", () => { | ||
| for (const filter of [ | ||
| { kinds: [9] }, | ||
| { "#h": [], kinds: [9] }, | ||
| { "#h": ["other"], kinds: [9] }, | ||
| { "#h": ["channel"], kinds: [30078] }, | ||
| ]) | ||
| assert.equal(ready([filter]), false); | ||
| assert.equal(hasMockSubscription([], "channel", 9, true), false); | ||
| for (const kinds of [[9], [7, 9], undefined]) { | ||
| assert.equal(ready([{ "#h": ["channel"], kinds }]), true); | ||
| } | ||
| const emptyKinds = [ | ||
| createMockSubscription([{ "#h": ["channel"], kinds: [] }]), | ||
| ]; | ||
| assert.equal(hasMockSubscription(emptyKinds, "channel", 9, true), false); | ||
| assert.equal( | ||
| hasMockSubscription(emptyKinds, "channel", undefined, true), | ||
| false, | ||
| ); | ||
| assert.equal( | ||
| ready([ | ||
| { "#h": ["channel"], kinds: [] }, | ||
| { "#h": ["channel"], kinds: [9] }, | ||
| ]), | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| test("REQ storage preserves channel/kind correlation across OR filters", () => { | ||
| for (const unrelated of [{ kinds: [9] }, { "#h": ["other"], kinds: [9] }]) { | ||
| const filters = [{ "#h": ["channel"], kinds: [30078] }, unrelated]; | ||
| const stored = createMockSubscription(filters); | ||
| assert.deepEqual(stored.filters, filters); | ||
| assert.equal(hasMockSubscription([stored], "channel", 9, true), false); | ||
| assert.equal(hasMockSubscription([stored], "channel", 30078, true), true); | ||
| assert.equal(ready([...filters, { "#h": ["channel"], kinds: [9] }]), true); | ||
| } | ||
| }); | ||
|
|
||
| test("legacy readiness and explicit global queries retain their semantics", () => { | ||
| const global = [createMockSubscription([{ kinds: [30078] }])]; | ||
| assert.equal(hasMockSubscription(global, "channel"), true); | ||
| assert.equal(hasMockSubscription(global, "channel", 9), false); | ||
| assert.equal(hasMockSubscription(global, "channel", 30078), true); | ||
| assert.equal(hasMockSubscription(global, "*", 30078), true); | ||
| assert.equal(hasMockSubscription(global, "*", 9), false); | ||
| assert.equal(hasMockSubscription(global, "channel", 30078, true), false); | ||
| assert.equal( | ||
| ready( | ||
| [{ "#h": ["channel"], kinds: [30078] }, { kinds: [9] }], | ||
| "channel", | ||
| 9, | ||
| false, | ||
| ), | ||
| true, | ||
| ); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| type SubscriptionFilter = { | ||
| "#h"?: readonly string[]; | ||
| "#p"?: readonly string[]; | ||
| kinds?: readonly number[]; | ||
| }; | ||
|
|
||
| /** Preserve raw REQ correlation alongside legacy mock delivery projections. */ | ||
| export function createMockSubscription(filters: readonly SubscriptionFilter[]) { | ||
| const channelIds = [ | ||
| ...new Set(filters.flatMap((filter) => filter["#h"] ?? [])), | ||
| ]; | ||
| const kinds = [...new Set(filters.flatMap((filter) => filter.kinds ?? []))]; | ||
| return { | ||
| filters, | ||
| channelIds: channelIds.length ? channelIds : ["*"], | ||
| kinds: kinds.length ? kinds : null, | ||
| ownerPubkeys: [...new Set(filters.flatMap((filter) => filter["#p"] ?? []))], | ||
| }; | ||
| } | ||
|
|
||
| /** Test readiness must distinguish a channel consumer from unrelated global REQs. */ | ||
| export function hasMockSubscription( | ||
| subscriptions: Iterable<ReturnType<typeof createMockSubscription>>, | ||
| channelId: string, | ||
| kind?: number, | ||
| exactChannel = false, | ||
| ): boolean { | ||
| for (const subscription of subscriptions) { | ||
| if (exactChannel) { | ||
| if ( | ||
| subscription.filters.some( | ||
| (filter) => | ||
| filter["#h"]?.includes(channelId) && | ||
| (filter.kinds === undefined || | ||
| (filter.kinds.length > 0 && | ||
| (kind === undefined || filter.kinds.includes(kind)))), | ||
| ) | ||
| ) | ||
| return true; | ||
| } else if ( | ||
| (subscription.channelIds.includes(channelId) || | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Require the channel and kind to match within one original REQ filter. The bridge currently unions every
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in dac0e8c. The live-REQ storage constructor now retains the original filters, and exact readiness requires channel and kind in the same filter. The regression passes both global-kind and other-channel counterexamples through that actual constructor. Legacy nonexact/wildcard readiness and event-delivery projections remain unchanged. Validation: all 6,592 desktop unit tests, formatting/static checks and TypeScript passed via the commit/push hooks. A fresh E2E build and all 31 affected smoke tests passed with zero retries before the formatting-only hook changes. Please re-review the corrected boundary. Carl, an automated reviewer, commenting via Wes’s GitHub account. |
||
| subscription.channelIds.includes("*")) && | ||
| (kind === undefined || | ||
| !subscription.kinds || | ||
| subscription.kinds.includes(kind)) | ||
| ) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Bind the correlation regression to this REQ/socket boundary. The new tests call
createMockSubscription(filters)directly, so they verify the helper but not that parsed REQ filters actually reach it here. Mutation evidence shows replacing only this invocation with the prior flattened projection leaves all three new subscription tests green, including the correlation test. Add a regression that sends the two-filter counterexample through the actual mock socket/REQ path and observes exact readiness false, plus a same-filter positive control; reverting this call site to flattening must make that test fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 50b7da2. The new registered smoke spec
mock-subscription-readiness.spec.tsinvokesplugin:websocket|connectandplugin:websocket|sendwith serialized REQs, requires EOSE, then reads exposed readiness. Locked boot prevents app-owned subscriptions from satisfying the assertion. Both split-filter counterexamples are false; the same-filter positive control is true; CLOSE removes readiness.Mutation proof: changed only
createMockSubscription(filters)at the realsendToMockSocketcall site to pass flattened channel/kind unions. The socket test fails because bothsplitGlobalandsplitOtherChannelbecome true. The mutation was restored before committing.Validation: rebuilt after each mutation; restored build and all 32 affected smoke tests passed with zero retries before formatting-only commit-hook changes. Exact committed head passed all 6,592 desktop unit tests and required pre-push checks. Hosted CI is separate and pending.
Carl, an automated reviewer, commenting via Wes’s GitHub account.