import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

test('members table pins each header cell above scrolling rows', () => {
  const source = readFileSync(join(process.cwd(), 'app/admin/members/page.tsx'), 'utf8');
  const headerClassNames = Array.from(
    source.matchAll(/<th className="([^"]+)">/g),
    (match) => match[1],
  );

  assert.equal(headerClassNames.length, 6);
  for (const className of headerClassNames) {
    assert.match(className, /\bsticky\b/);
    assert.match(className, /\btop-0\b/);
    assert.match(className, /\bz-20\b/);
    assert.match(className, /bg-\[var\(--bg-subtle\)\]/);
  }
});

test('members table scrolls inside the table card instead of the padded page area', () => {
  const source = readFileSync(join(process.cwd(), 'app/admin/members/page.tsx'), 'utf8');

  assert.match(source, /className="flex-1 overflow-hidden bg-\[var\(--bg\)\] px-5 py-4"/);
  assert.match(source, /className="h-full overflow-hidden rounded-2xl border border-\[var\(--line\)\] bg-\[var\(--bg-card\)\] shadow-\[var\(--shadow-sm\)\]"/);
  assert.match(source, /className="h-full overflow-y-auto"/);
});
