import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import test from 'node:test'; const read = name => readFileSync(new URL('../' + name, import.meta.url), 'utf8'); const source = JSON.parse(read('tools/career-titles.json')); const {careers, families} = JSON.parse(read('assets/career-directory.json')); const expectedTrades = new Set([...read('volunteer/index.html').matchAll(/glimmer:\/\/community\/atom-([a-z0-9-]+)/g)].map(match => match[1])); test('directory preserves every BLS civilian title across all 22 families, without duplication', () => { assert.equal(source.length, 848); assert.equal(new Set(source.map(([code]) => code)).size, 848); assert.equal(families.length, 22); assert.deepEqual(careers.map(row => row.slice(0, 2)), source); assert.ok(careers.every(([code]) => /^\d{2}-\d{4}$/.test(code) && !code.startsWith('55-'))); assert.deepEqual(new Set(careers.map(([code]) => code.slice(0, 2))), new Set(families.map(([code]) => code))); assert.ok(careers.some(([code, title, trade, aliases]) => title === 'Software Developers' && aliases.includes('coder'))); }); test('every family and career resolves to the existing Glimmer trade communities', () => { assert.equal(expectedTrades.size, 50); assert.ok(families.every(([, , trade]) => expectedTrades.has(trade))); assert.ok(careers.every(([, , trade]) => !trade || expectedTrades.has(trade))); const hrefs = [...read('careers/index.html').matchAll(/glimmer:\/\/community\/atom-([a-z0-9-]+)/g)]; assert.equal(hrefs.length, 23); assert.ok(hrefs.every(([, trade]) => expectedTrades.has(trade))); }); test('career directory is volunteer-only, discoverable and distinct from the existing roster', () => { const page = read('careers/index.html'); assert.match(page, /unpaid volunteer ideas, not openings, shifts, or commitments/); assert.match(page, /No forms or résumé are needed/); assert.match(page, /independently qualified and authorized/); assert.doesNotMatch(page, /JobPosting|baseSalary|