Files
musicshare/packages/shared/src/qr.test.ts
T
chrisandClaude Opus 5.5 586acdbeab API: follower lists, blocking, reports, admin; drop Spotify sign-in
- Followers/following lists (paginated), 'follows you', remove a follower
- Blocking severs follows both ways and hides each user from the other
  (profile 404s, search, follows); the blocker sees activity hidden
- Reports for moderation (App Store guideline 1.2)
- First account on a server becomes admin; admins see the report queue,
  resolve reports, and suspend accounts (signs out, blocks login, hides
  the profile, stops sharing). set-role script to promote/demote
- users.onboardedAt drives first-run onboarding; existing accounts are
  backfilled as already onboarded. Empty PATCH /me no longer 500s
- Remove Spotify account sign-in and polling: Spotify caps new apps at 5
  accounts, so Spotify arrives via its Last.fm/ListenBrainz link or the
  Android reader. App-level catalog search stays for exact links
- Shared: QR code generation and profile-link parsing (verified with jsQR)
- Integration test timeout raised; password hashing is slow by design

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
2026-10-05 19:16:40 -04:00

36 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { qrMatrix, qrShape } from './qr';
describe('qr', () => {
const url = 'https://musicshare.app/u/alice';
it('produces a square grid with the three finder patterns', () => {
const m = qrMatrix(url);
const n = m.length;
expect(n).toBeGreaterThanOrEqual(21);
expect(m.every((row) => row.length === n)).toBe(true);
// Finder pattern corners: dark outer ring, light inner ring, dark 3x3 centre.
for (const [r, c] of [
[0, 0],
[0, n - 7],
[n - 7, 0],
] as const) {
expect(m[r]![c]).toBe(true);
expect(m[r + 1]![c + 1]).toBe(false);
expect(m[r + 3]![c + 3]).toBe(true);
}
});
it('is deterministic and draws every dark module', () => {
const a = qrShape(url);
expect(qrShape(url)).toEqual(a);
const darkCount = qrMatrix(url).flat().filter(Boolean).length;
const drawn = [...a.path.matchAll(/h(\d+)v1/g)].reduce((sum, m) => sum + Number(m[1]), 0);
expect(drawn).toBe(darkCount);
});
it('grows for longer text', () => {
expect(qrShape(`${url}?${'x'.repeat(200)}`).size).toBeGreaterThan(qrShape(url).size);
});
});