|
1 | 1 | import { expect, test } from "@playwright/test"; |
| 2 | +import { npubEncode } from "nostr-tools/nip19"; |
2 | 3 |
|
3 | 4 | import { |
4 | 5 | installMockBridge, |
@@ -198,8 +199,59 @@ test("selected new-DM recipient can be verified again through search", async ({ |
198 | 199 | await page.getByTestId("new-message-page").screenshot({ |
199 | 200 | path: `${SHOTS}/new-dm-selected-recipient-key.png`, |
200 | 201 | }); |
| 202 | + |
| 203 | + // Full-variant clipboard regression (D1a): the nested copy affordances |
| 204 | + // must write the recipient's complete canonical npub through the real |
| 205 | + // bridge — never the legacy raw hex the popover also shows, and never a |
| 206 | + // truncation. The evidence screenshot above is captured first, so this |
| 207 | + // interaction leaves it untouched. |
| 208 | + await page.context().grantPermissions(["clipboard-read", "clipboard-write"]); |
| 209 | + const copyPublicKeyTrigger = charliePubkey.getByRole("button", { |
| 210 | + name: "Copy public key", |
| 211 | + }); |
| 212 | + await copyPublicKeyTrigger.click(); |
| 213 | + const copyNpubButton = page.getByRole("button", { name: "Copy npub" }); |
| 214 | + await copyNpubButton.click(); |
| 215 | + await expect |
| 216 | + .poll(() => page.evaluate(() => navigator.clipboard.readText())) |
| 217 | + .toBe(npubEncode(TEST_IDENTITIES.charlie.pubkey)); |
| 218 | + await expect( |
| 219 | + page.locator("[data-sonner-toast]").filter({ hasText: "npub copied" }), |
| 220 | + ).toBeVisible(); |
| 221 | + // Copying is not a dismissal: the nested affordance and the inspection |
| 222 | + // popover it lives in both survive the copy. |
| 223 | + await expect(copyNpubButton).toBeVisible(); |
| 224 | + await expect(charlieKeyPopover).toBeVisible(); |
| 225 | + |
| 226 | + // The inner Escape closes only the nested key popover — the inspection |
| 227 | + // stays open. |
| 228 | + await page.keyboard.press("Escape"); |
| 229 | + await expect(copyNpubButton).toHaveCount(0); |
| 230 | + await expect(charlieKeyPopover).toBeVisible(); |
| 231 | + |
| 232 | + // Keyboard path: after the inner Escape focus returns naturally to the |
| 233 | + // full-key trigger; Space reopens the popover, whose auto-focus lands on |
| 234 | + // Copy npub, and Enter activates it. The sentinel proves this keyboard |
| 235 | + // copy rewrites the clipboard rather than inheriting the value above. |
| 236 | + await expect(copyPublicKeyTrigger).toBeFocused(); |
| 237 | + await page.evaluate(() => |
| 238 | + navigator.clipboard.writeText("keyboard-copy-sentinel"), |
| 239 | + ); |
| 240 | + await page.keyboard.press("Space"); |
| 241 | + await expect(copyNpubButton).toBeVisible(); |
| 242 | + await expect(copyNpubButton).toBeFocused(); |
| 243 | + await page.keyboard.press("Enter"); |
| 244 | + await expect |
| 245 | + .poll(() => page.evaluate(() => navigator.clipboard.readText())) |
| 246 | + .toBe(npubEncode(TEST_IDENTITIES.charlie.pubkey)); |
| 247 | + |
| 248 | + // Close the reopened nested popover so the inspection popover owns the |
| 249 | + // final Escape; the recipient itself survives both dismissals. |
| 250 | + await page.keyboard.press("Escape"); |
| 251 | + await expect(copyNpubButton).toHaveCount(0); |
201 | 252 | await page.keyboard.press("Escape"); |
202 | 253 | await expect(charlieKeyPopover).toHaveCount(0); |
| 254 | + await expect(charlieChip).toBeVisible(); |
203 | 255 |
|
204 | 256 | await search.fill("charlie"); |
205 | 257 | await expect(charlieResult).toBeVisible(); |
@@ -230,6 +282,16 @@ test("selected new-DM recipient can be verified again through search", async ({ |
230 | 282 | await page.getByTestId("new-message-page").screenshot({ |
231 | 283 | path: `${SHOTS}/new-dm-selected-recipient.png`, |
232 | 284 | }); |
| 285 | + |
| 286 | + // The To-field guard ignores popover clicks that bubble into the field; |
| 287 | + // a click on the label itself — a physical descendant of the field — must |
| 288 | + // still focus the input and open the recipient picker. |
| 289 | + await page |
| 290 | + .getByTestId("new-message-to-field") |
| 291 | + .getByText("To:", { exact: true }) |
| 292 | + .click(); |
| 293 | + await expect(search).toBeFocused(); |
| 294 | + await expect(page.getByTestId("new-message-recipient-popover")).toBeVisible(); |
233 | 295 | }); |
234 | 296 |
|
235 | 297 | test("member removal confirm shows the full npub inline", async ({ page }) => { |
|
0 commit comments