mirror of
https://github.com/firstsun-dev/git-files-sync.git
synced 2026-07-22 17:20:30 +00:00
Adds a "what's new" modal shown once after the plugin updates to a new version, so users don't miss what changed: - New src/changelog.ts: a hand-curated CHANGELOG array (distinct from the auto-generated CHANGELOG.md, which lists every commit) where entries can be marked `notable` so they're called out separately from minor fixes, per the issue's clarification comment. - New src/utils/version.ts: compareVersions() does numeric per-segment comparison (so "1.10.0" sorts after "1.9.0", unlike a plain string compare). - getUnseenReleases() filters+sorts the changelog to what's newer than a given "last seen" version, extracted as a pure/testable function rather than inlined in main.ts (which isn't unit-tested in this repo). - New settings field lastSeenVersion, persisted the same way as other settings. On a fresh install (empty lastSeenVersion) it's just recorded silently — no modal, since there's nothing to compare against. On an actual version bump, WhatsNewModal shows the unseen releases' highlights, with a "View full changelog" link out to CHANGELOG.md and a "Got it" dismiss; the version is recorded either way so the tip only ever shows once per upgrade. - The whole check is wrapped in try/catch so a malformed version string can never break plugin startup. Closes #39
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { getUnseenReleases, type ChangelogRelease } from '../src/changelog';
|
|
|
|
describe('getUnseenReleases', () => {
|
|
const changelog: ChangelogRelease[] = [
|
|
{ version: '1.0.0', entries: [{ text: 'Initial release' }] },
|
|
{ version: '1.1.0', entries: [{ text: 'Feature A' }] },
|
|
{ version: '1.2.0', entries: [{ text: 'Feature B', notable: true }] },
|
|
{ version: '1.10.0', entries: [{ text: 'Feature C' }] },
|
|
];
|
|
|
|
it('returns only releases newer than lastSeenVersion', () => {
|
|
const result = getUnseenReleases(changelog, '1.1.0');
|
|
expect(result.map(r => r.version)).toEqual(['1.10.0', '1.2.0']);
|
|
});
|
|
|
|
it('returns releases newest-first', () => {
|
|
const result = getUnseenReleases(changelog, '1.0.0');
|
|
expect(result.map(r => r.version)).toEqual(['1.10.0', '1.2.0', '1.1.0']);
|
|
});
|
|
|
|
it('compares versions numerically, not lexically (1.10.0 > 1.2.0)', () => {
|
|
const result = getUnseenReleases(changelog, '1.9.0');
|
|
expect(result.map(r => r.version)).toEqual(['1.10.0']);
|
|
});
|
|
|
|
it('returns an empty array when already on the latest version', () => {
|
|
expect(getUnseenReleases(changelog, '1.10.0')).toEqual([]);
|
|
});
|
|
|
|
it('returns everything when lastSeenVersion is empty', () => {
|
|
expect(getUnseenReleases(changelog, '').length).toBe(4);
|
|
});
|
|
});
|