Files
buzz/desktop/src/shared/ui/styled-qr-code.test.mjs
klopez4212 e6c90bb7c4 Polish community rail and mobile pairing (#2972)
## Summary
- align the multi-community rail with the content surface and balance
its visible 10px side gutters
- center Mobile pairing, start sessions on demand, and keep retry states
inside the QR area
- reveal the QR code and copy action with 250ms motion and use the
standard loading spinner

The rail was centered within its own box, but the adjacent sidebar added
another 11px to the visible right gap. Mobile pairing also started
before user intent, which could leave an idle session waiting for EOSE.

## Validation
- `pnpm -C desktop build:e2e`
- `pnpm -C desktop test` — 3,516 passed
- `pnpm -C desktop exec playwright test tests/e2e/community-rail.spec.ts
--project=smoke` — 19 passed
- `pnpm -C desktop exec playwright test
tests/e2e/mobile-pairing-qr.spec.ts --project=smoke` — 1 passed

`pnpm -C desktop check` is currently blocked by the existing
`src-tauri/src/managed_agents/runtime.rs` file-size baseline (2,220
lines; limit 2,216).
2026-07-26 13:20:26 -07:00

55 lines
1.8 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { StyledQrCode } from "./styled-qr-code.tsx";
const TEST_PAIRING_URI =
"nostrpair://8f4b8db31967ce14fef970a1ff1e8eecf19a430aa1c83875e2f5be68dcac0f1a?relay=wss%3A%2F%2Frelay.example.com&secret=87d5a8cfd5807a0cb44f728b67d88d6dcb8daf99be137c158f21a50c1e913c0a&v=1";
test("renders the Wallet-style QR geometry locally", () => {
const html = renderToStaticMarkup(
React.createElement(StyledQrCode, {
centerImageSrc: "/app-icon@2x.png",
title: "Mobile pairing QR code",
value: TEST_PAIRING_URI,
}),
);
assert.match(html, /aria-label="Mobile pairing QR code"/);
assert.match(html, /data-qr-matrix-size="57"/);
assert.equal((html.match(/data-qr-finder-pattern=""/g) ?? []).length, 3);
assert.ok(
(html.match(/<circle /g) ?? []).length > 100,
"expected the QR payload to render as individual circular data cells",
);
assert.match(html, /href="\/app-icon@2x\.png"/);
});
test("uses a deterministic lower-density matrix for the same payload", () => {
const first = renderToStaticMarkup(
React.createElement(StyledQrCode, { value: TEST_PAIRING_URI }),
);
const second = renderToStaticMarkup(
React.createElement(StyledQrCode, { value: TEST_PAIRING_URI }),
);
assert.equal(first, second);
});
test("adds the row-based reveal motion when requested", () => {
const html = renderToStaticMarkup(
React.createElement(StyledQrCode, {
animate: true,
value: TEST_PAIRING_URI,
}),
);
assert.match(html, /class="buzz-qr-cell-reveal"/);
assert.match(html, /data-qr-cell-row="0"/);
assert.match(html, /--buzz-qr-reveal-delay:0ms/);
assert.match(html, /data-qr-cell-row="56"/);
assert.match(html, /--buzz-qr-reveal-delay:189ms/);
});