// Releases from git: reading the repo address and WHATS-NEW.md. jest.mock('../src/config/db', () => ({})); const { parseRepoUrl, parseNotes } = require('../src/utils/releaseSync'); test('the repository address becomes the Gitea API', () => { expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua/hope-events')).toEqual({ api: 'https://c-git.crosscode.co.za/api/v1/repos/joshua/hope-events', owner: 'joshua', repo: 'hope-events' }); expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua/hope-events.git/').api).toBe('https://c-git.crosscode.co.za/api/v1/repos/joshua/hope-events'); expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua')).toBeNull(); expect(parseRepoUrl('ftp://x/y/z')).toBeNull(); expect(parseRepoUrl('')).toBeNull(); }); describe('WHATS-NEW.md', () => { const md = `# What's new in Cross Events Intro text that isn't a release. ## 1.46.2 — urgent - **See what's new** before you update, on the Licence page. - Uses \`code\` and [a link](https://example.com). ## [1.46.1] - 2026-10-28 Behind-the-scenes maintenance. Nothing changes for you. ## v1.46.0 (security fix) ### Volunteers - Rosters - Swaps `; const notes = parseNotes(md); test('one section per version; comments and the title are skipped', () => { expect(Object.keys(notes).sort()).toEqual(['1.46.0', '1.46.1', '1.46.2']); }); test('"urgent" or "security" in the heading marks it urgent', () => { expect(notes['1.46.2'].urgent).toBe(true); expect(notes['1.46.1'].urgent).toBe(false); expect(notes['1.46.0'].urgent).toBe(true); }); test('markup is removed, wrapped lines joined, list items kept', () => { expect(notes['1.46.2'].notes).toBe("- See what's new before you update, on the Licence page.\n- Uses code and a link."); expect(notes['1.46.1'].notes).toBe('Behind-the-scenes maintenance. Nothing changes for you.'); expect(notes['1.46.0'].notes).toBe('Volunteers\n- Rosters\n- Swaps'); }); test('no file means no notes', () => { expect(parseNotes('')).toEqual({}); expect(parseNotes(null)).toEqual({}); }); });