|
| 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 | +}); |
0 commit comments