Skip to content

Commit 6964f91

Browse files
test(desktop): e2e coverage for add-search channel_add_policy gating
Review follow-up on #3864: the predicate matrix is unit-tested, but the mock bridge seeds carried no channel_add_policy at all — every mock directory agent resolved to null policy and was hidden from add search, which made the e2e layer blind to this feature (the same fixture-gap class that let the mentions-surface regression hide until #3676's e2e update). Carry channel_add_policy through the bridge seed types with an "anyone" default (matching the relay's stored default), and add paired smoke specs modeled on identity-archive-hide.spec.ts: an agent declaring "nobody" never reaches the picker, and an "anyone" control proves the deny comes from the policy gate rather than a broken search. Swept existing specs for assertions the seed default could disturb: alice is already a member of general (excluded from add search there regardless of policy), charlie stays offered via the managed path with an unchanged testid, the no-directory-entry agents in channels.spec.ts remain hidden under the new gate, and the pagination count query cannot match either default agent's name. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Bryce Del Rio <[email protected]>
1 parent 27b8595 commit 6964f91

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default defineConfig({
6969
"**/workflows.spec.ts",
7070
"**/identity-archive.spec.ts",
7171
"**/identity-archive-hide.spec.ts",
72+
"**/add-search-eligibility.spec.ts",
7273
"**/relay-connectivity.spec.ts",
7374
"**/unread-pill.spec.ts",
7475
"**/sidebar-more-unread-overlap.spec.ts",

‎desktop/src/testing/e2eBridge.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type MockRelayAgentSeed = {
103103
capabilities?: string[];
104104
respondTo?: RawRelayAgent["respond_to"];
105105
respondToAllowlist?: string[];
106+
channelAddPolicy?: RawRelayAgent["channel_add_policy"];
106107
channelNames?: string[];
107108
channelIds?: string[];
108109
status?: PresenceStatus;
@@ -726,6 +727,7 @@ type RawRelayAgent = {
726727
status: PresenceStatus;
727728
respond_to?: "owner-only" | "allowlist" | "anyone";
728729
respond_to_allowlist?: string[];
730+
channel_add_policy?: "anyone" | "owner_only" | "nobody";
729731
};
730732

731733
type RawManagedAgent = {
@@ -2091,6 +2093,7 @@ function resetMockRelayAgents(config?: E2eConfig) {
20912093
status: seed.status ?? "online",
20922094
respond_to: seed.respondTo ?? "owner-only",
20932095
respond_to_allowlist: seed.respondToAllowlist ?? [],
2096+
channel_add_policy: seed.channelAddPolicy ?? "anyone",
20942097
});
20952098
}
20962099
}
@@ -2926,6 +2929,7 @@ const defaultMockRelayAgents: RawRelayAgent[] = [
29262929
status: "online",
29272930
respond_to: "anyone",
29282931
respond_to_allowlist: [],
2932+
channel_add_policy: "anyone",
29292933
},
29302934
{
29312935
pubkey: CHARLIE_PUBKEY,
@@ -2937,6 +2941,7 @@ const defaultMockRelayAgents: RawRelayAgent[] = [
29372941
status: "away",
29382942
respond_to: "anyone",
29392943
respond_to_allowlist: [],
2944+
channel_add_policy: "anyone",
29402945
},
29412946
];
29422947
let mockRelayAgents: RawRelayAgent[] = defaultMockRelayAgents.map((agent) => ({
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
import { installMockBridge } from "../helpers/bridge";
4+
5+
// External (non-managed) relay agents in the add-member search are gated on
6+
// their kind:10100 `channel_add_policy` — the declaration the relay enforces
7+
// on third-party adds. Paired specs: the deny case proves an opted-out agent
8+
// never reaches the picker; the allow control proves the deny result comes
9+
// from the policy gate, not from a broken search or member-exclusion.
10+
11+
const NOBODY_AGENT_PUBKEY = "77".repeat(32);
12+
const ANYONE_AGENT_PUBKEY = "99".repeat(32);
13+
14+
async function openAddMemberSearch(page: import("@playwright/test").Page) {
15+
await page.goto("/");
16+
await page.getByTestId("channel-agents").click();
17+
await page.getByTestId("channel-members-trigger").click();
18+
await expect(page.getByTestId("members-sidebar")).toBeVisible();
19+
}
20+
21+
test("add search: agent declaring channel_add_policy nobody is never offered", async ({
22+
page,
23+
}) => {
24+
await installMockBridge(page, {
25+
relayAgents: [
26+
{
27+
pubkey: NOBODY_AGENT_PUBKEY,
28+
name: "vega",
29+
channelAddPolicy: "nobody",
30+
channelNames: ["general"],
31+
respondTo: "anyone",
32+
},
33+
],
34+
});
35+
await openAddMemberSearch(page);
36+
await page.getByTestId("channel-management-search-users").fill("vega");
37+
await expect(
38+
page.getByTestId(`channel-user-search-result-${NOBODY_AGENT_PUBKEY}`),
39+
).toHaveCount(0);
40+
});
41+
42+
test("add search: control — agent declaring channel_add_policy anyone IS offered", async ({
43+
page,
44+
}) => {
45+
await installMockBridge(page, {
46+
relayAgents: [
47+
{
48+
pubkey: ANYONE_AGENT_PUBKEY,
49+
name: "lyra",
50+
channelAddPolicy: "anyone",
51+
channelNames: ["general"],
52+
respondTo: "anyone",
53+
},
54+
],
55+
});
56+
await openAddMemberSearch(page);
57+
await page.getByTestId("channel-management-search-users").fill("lyra");
58+
await expect(
59+
page.getByTestId(`channel-user-search-result-${ANYONE_AGENT_PUBKEY}`),
60+
).toBeVisible();
61+
});

‎desktop/tests/helpers/bridge.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type MockRelayAgentSeed = {
7878
capabilities?: string[];
7979
respondTo?: "owner-only" | "allowlist" | "anyone";
8080
respondToAllowlist?: string[];
81+
channelAddPolicy?: "anyone" | "owner_only" | "nobody";
8182
channelNames?: string[];
8283
channelIds?: string[];
8384
status?: "online" | "away" | "offline";

0 commit comments

Comments
 (0)