- endpoints: is-starred (404→false), star/unstar, subscription watch/unwatch, fork, releases list/detail - hooks: useIsStarred/useToggleStar, useSubscription/useToggleWatch, useForkRepository, useReleases/useRelease - repo overview: star/watch/fork actions, Releases + Wiki entries (wiki via explicit browser fallback gated by capability probe) - screens: Releases list, Release detail with downloadable assets - core/capabilities: version parsing + per-capability minimum versions + tests - i18n (en/nl); README/ROADMAP/FEATURE_PARITY updated for phases 3-5
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
/** Instance capability detection (version parsing + feature gating). */
|
|
|
|
import { atLeast, parseGiteaVersion, supports } from './index';
|
|
|
|
describe('parseGiteaVersion', () => {
|
|
it('parses plain versions', () => {
|
|
expect(parseGiteaVersion('1.21.4')).toEqual({ major: 1, minor: 21, patch: 4, raw: '1.21.4' });
|
|
});
|
|
|
|
it('tolerates suffixes and a leading v', () => {
|
|
expect(parseGiteaVersion('v1.22.0+rc1')?.minor).toBe(22);
|
|
expect(parseGiteaVersion('1.19.3-rc2')?.patch).toBe(3);
|
|
});
|
|
|
|
it('defaults a missing patch to 0', () => {
|
|
expect(parseGiteaVersion('1.21')?.patch).toBe(0);
|
|
});
|
|
|
|
it('returns null for empty or invalid input', () => {
|
|
expect(parseGiteaVersion(undefined)).toBeNull();
|
|
expect(parseGiteaVersion('')).toBeNull();
|
|
expect(parseGiteaVersion('development')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('atLeast', () => {
|
|
const v = parseGiteaVersion('1.21.4');
|
|
|
|
it('compares major/minor/patch correctly', () => {
|
|
expect(atLeast(v, 1, 21, 4)).toBe(true);
|
|
expect(atLeast(v, 1, 21, 5)).toBe(false);
|
|
expect(atLeast(v, 1, 22, 0)).toBe(false);
|
|
expect(atLeast(v, 2, 0, 0)).toBe(false);
|
|
expect(atLeast(v, 1, 20, 0)).toBe(true);
|
|
});
|
|
|
|
it('treats an unknown version as too old', () => {
|
|
expect(atLeast(null, 1, 0, 0)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('supports', () => {
|
|
it('gates Actions on Gitea 1.19+', () => {
|
|
expect(supports('actions', parseGiteaVersion('1.18.5'))).toBe(false);
|
|
expect(supports('actions', parseGiteaVersion('1.19.0'))).toBe(true);
|
|
expect(supports('actions', parseGiteaVersion('1.24.1'))).toBe(true);
|
|
});
|
|
|
|
it('treats releases and wiki as widely available', () => {
|
|
expect(supports('releases', parseGiteaVersion('1.9.0'))).toBe(true);
|
|
expect(supports('wiki', parseGiteaVersion('1.0.0'))).toBe(true);
|
|
});
|
|
|
|
it('is conservative for unknown instances', () => {
|
|
expect(supports('packages', null)).toBe(false);
|
|
});
|
|
});
|