Files
buzz/desktop/tests/e2e/pubkey-display-screenshots.spec.ts
T
cls 9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
feat: import Chinese-localized Buzz source snapshot
Signed-off-by: cls_宁波本机 <908705107@qq.com>
2026-08-13 18:34:25 +08:00

247 lines
8.4 KiB
TypeScript

import { expect, test } from "@playwright/test";
import {
installMockBridge,
openNewMessagePage,
TEST_IDENTITIES,
} from "../helpers/bridge";
import { waitForAnimations } from "../helpers/animations";
const SHOTS = "test-results/pubkey-display";
const AGENT_PUBKEY = "cafef00d".repeat(8);
// Screenshot evidence for the pubkey-display work: the canonical profile
// surfaces, plus the new-DM recipient identity-hover states retained by it.
test("profile panel Public key row opens the PubKey popover on hover", async ({
page,
}) => {
await installMockBridge(page);
await page.goto("/");
await page.getByTestId("channel-general").click();
await expect(page.getByTestId("chat-title")).toHaveText("general");
const messageRow = page.getByTestId("message-row").first();
await expect(messageRow).toBeVisible();
await messageRow.locator("button").first().click();
await expect(page.getByTestId("user-profile-panel")).toBeVisible();
const pubkeyTrigger = page.getByTestId("user-profile-copy-pubkey");
await expect(pubkeyTrigger).toBeVisible();
await pubkeyTrigger.hover();
// Hover-open fires after a 500ms intent delay.
await expect(page.getByText("hex", { exact: true })).toBeVisible({
timeout: 3_000,
});
await expect(page.getByText("npub", { exact: true })).toBeVisible();
await waitForAnimations(page);
await page.screenshot({
path: `${SHOTS}/profile-panel-pubkey-hover-popover.png`,
});
});
test("new-DM agent name swaps to its public key on name hover", async ({
page,
}) => {
// Agent rows only surface when the agent is mentionable, so seed a managed
// agent alongside its search profile.
await installMockBridge(page, {
managedAgents: [
{
name: "Pinky",
pubkey: AGENT_PUBKEY,
status: "running",
},
],
searchProfiles: [
{
displayName: "Pinky",
isAgent: true,
ownerPubkey: "deadbeef".repeat(8),
pubkey: AGENT_PUBKEY,
},
],
});
await page.goto("/");
await openNewMessagePage(page);
await expect(page.getByTestId("new-message-page")).toBeVisible();
const agentResult = page.getByTestId(`new-dm-result-${AGENT_PUBKEY}`);
await expect(agentResult).toBeVisible();
await expect(page.getByTestId("new-dm-loading")).toBeHidden();
await expect
.poll(async () => {
const marker = crypto.randomUUID();
await agentResult.evaluate((element, value) => {
element.dataset.e2eSettleMarker = value;
}, marker);
await page.waitForTimeout(250);
return agentResult
.evaluate(
(element, value) => element.dataset.e2eSettleMarker === value,
marker,
)
.catch(() => false);
})
.toBe(true);
const agentName = agentResult.getByTestId(`new-dm-name-${AGENT_PUBKEY}`);
const agentNpub = agentResult.getByTestId(`new-dm-npub-${AGENT_PUBKEY}`);
await expect(agentResult).toContainText("managed by you");
await expect(agentName).toContainText("Pinky");
await expect(agentNpub).toHaveCSS("opacity", "0");
const agentNameBox = await agentName.boundingBox();
const agentResultBox = await agentResult.boundingBox();
expect(agentNameBox).not.toBeNull();
expect(agentResultBox).not.toBeNull();
if (!agentNameBox || !agentResultBox) return;
expect(agentNameBox.width).toBeLessThan(agentResultBox.width / 2);
await page.mouse.move(
agentResultBox.x + agentResultBox.width - 12,
agentNameBox.y + agentNameBox.height / 2,
);
await expect(agentNpub).toHaveCSS("opacity", "0");
// Acquire fresh locators after the directory queries settle: the result row
// can be replaced while the initial loading skeleton is transitioning out.
const settledAgentResult = page.getByTestId(`new-dm-result-${AGENT_PUBKEY}`);
const settledAgentName = settledAgentResult.getByTestId(
`new-dm-name-${AGENT_PUBKEY}`,
);
const settledAgentNpub = settledAgentResult.getByTestId(
`new-dm-npub-${AGENT_PUBKEY}`,
);
await settledAgentName.hover();
await expect
.poll(async () =>
settledAgentName.evaluate((element) => element.matches(":hover")),
)
.toBe(true);
await expect(settledAgentNpub).not.toHaveCSS("opacity", "0");
await expect(settledAgentNpub).toHaveText("cafef00d…f00d");
await expect(
settledAgentName.getByText("Pinky", { exact: true }),
).not.toHaveCSS("opacity", "1");
await expect(settledAgentResult).toContainText("managed by you");
await waitForAnimations(page);
await page.getByTestId("new-message-page").screenshot({
path: `${SHOTS}/new-dm-agent-name-hover.png`,
});
});
test("selected new-DM recipient can be verified again through search", async ({
page,
}) => {
await installMockBridge(page);
await page.goto("/");
await openNewMessagePage(page);
await expect(page.getByTestId("new-message-page")).toBeVisible();
const search = page.getByTestId("new-dm-search");
const charlieResult = page.getByTestId(
`new-dm-result-${TEST_IDENTITIES.charlie.pubkey}`,
);
const charlieName = page.getByTestId(
`new-dm-name-${TEST_IDENTITIES.charlie.pubkey}`,
);
const charlieNpub = page.getByTestId(
`new-dm-npub-${TEST_IDENTITIES.charlie.pubkey}`,
);
// The same name-to-key swap is available in the unfiltered directory,
// before the user has typed anything.
await expect(charlieResult).toBeVisible();
await expect(charlieNpub).toHaveCSS("opacity", "0");
await charlieName.hover();
await expect(charlieNpub).toHaveCSS("opacity", "1");
await expect(charlieNpub).toHaveText(
`${TEST_IDENTITIES.charlie.pubkey.slice(0, 8)}${TEST_IDENTITIES.charlie.pubkey.slice(-4)}`,
);
await page.mouse.move(1_100, 500);
await expect(charlieNpub).toHaveCSS("opacity", "0");
await search.fill("charlie");
await expect(charlieResult).toBeVisible();
await page.keyboard.press("Enter");
const charlieChip = page.getByTestId(
`new-dm-selected-${TEST_IDENTITIES.charlie.pubkey}`,
);
const charlieNameTrigger = page.getByTestId(
`new-dm-recipient-name-${TEST_IDENTITIES.charlie.pubkey}`,
);
const charlieKeyPopover = page.getByTestId(
`new-dm-selected-key-popover-${TEST_IDENTITIES.charlie.pubkey}`,
);
const charliePubkey = page.getByTestId(
`new-dm-selected-pubkey-${TEST_IDENTITIES.charlie.pubkey}`,
);
await expect(charlieChip).toBeVisible();
await expect(page.getByTestId("new-message-recipient-popover")).toBeVisible();
await expect(search).toHaveValue("");
await expect(charlieResult).toHaveCount(0);
await expect(charlieKeyPopover).toHaveCount(0);
await charlieChip.hover();
await expect(charlieKeyPopover).toHaveCount(0);
await charlieNameTrigger.click();
await expect(charlieKeyPopover).toBeVisible();
await expect(charliePubkey).toContainText("npub1");
await expect(charlieKeyPopover).toContainText(TEST_IDENTITIES.charlie.pubkey);
await waitForAnimations(page);
await page.getByTestId("new-message-page").screenshot({
path: `${SHOTS}/new-dm-selected-recipient-key.png`,
});
await page.keyboard.press("Escape");
await expect(charlieKeyPopover).toHaveCount(0);
await search.fill("charlie");
await expect(charlieResult).toBeVisible();
await expect(charlieResult).toHaveAttribute(
"aria-label",
"Already added charlie",
);
await charlieName.hover();
await expect(charlieNpub).toHaveCSS("opacity", "1");
await expect(charlieNpub).toHaveText(
`${TEST_IDENTITIES.charlie.pubkey.slice(0, 8)}${TEST_IDENTITIES.charlie.pubkey.slice(-4)}`,
);
await expect(charlieName.getByText("charlie", { exact: true })).toHaveCSS(
"opacity",
"0",
);
await page.keyboard.press("Enter");
await expect(search).toHaveValue("");
await expect(
page.locator("button[data-testid^='new-dm-selected-']"),
).toHaveCount(1);
await page.mouse.move(1_100, 500);
await expect(charlieNpub).toHaveCount(0);
await expect(charlieKeyPopover).toHaveCount(0);
await waitForAnimations(page);
await page.getByTestId("new-message-page").screenshot({
path: `${SHOTS}/new-dm-selected-recipient.png`,
});
});
test("member removal confirm shows the full npub inline", async ({ page }) => {
await installMockBridge(page);
await page.goto("/");
await page.getByTestId("channel-general").click();
await expect(page.getByTestId("chat-title")).toHaveText("general");
await page.getByTestId("channel-members-trigger").click();
await expect(page.getByTestId("members-sidebar")).toBeVisible();
await waitForAnimations(page);
await page.getByTestId("members-sidebar").screenshot({
path: `${SHOTS}/members-sidebar.png`,
});
});