From 98c962796fb0bd5f010e834108ac624e297f151b Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Mon, 27 Apr 2026 18:04:56 -0400 Subject: [PATCH] test(ext/sw): assert lastCommit URL structure + comment limit/per_page divergence Co-Authored-By: Claude Sonnet 4.6 --- .../service-worker/__tests__/git-host-extensions.test.ts | 6 ++++++ extension/src/service-worker/gitea.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/extension/src/service-worker/__tests__/git-host-extensions.test.ts b/extension/src/service-worker/__tests__/git-host-extensions.test.ts index 12267a1..afbebeb 100644 --- a/extension/src/service-worker/__tests__/git-host-extensions.test.ts +++ b/extension/src/service-worker/__tests__/git-host-extensions.test.ts @@ -16,6 +16,9 @@ describe('lastCommit (Gitea)', () => { const host = new GiteaHost('https://git.example.com', 'user/vault', 'tok'); const result = await host.lastCommit('manifest.enc'); expect(result).toEqual({ sha: 'abc1234', author: 'Alice', date: '2026-04-20T12:00:00Z' }); + expect(fetchSpy.mock.calls[0][0]).toContain('/repos/user/vault/commits'); + expect(fetchSpy.mock.calls[0][0]).toContain('path=manifest.enc'); + expect(fetchSpy.mock.calls[0][0]).toContain('limit=1'); }); it('returns null on 404', async () => { @@ -45,6 +48,9 @@ describe('lastCommit (GitHub)', () => { const host = new GitHubHost('user/vault', 'tok'); const result = await host.lastCommit('manifest.enc'); expect(result).toEqual({ sha: 'def4567', author: 'Bob', date: '2026-04-22T15:00:00Z' }); + expect(fetchSpy.mock.calls[0][0]).toContain('/repos/user/vault/commits'); + expect(fetchSpy.mock.calls[0][0]).toContain('path=manifest.enc'); + expect(fetchSpy.mock.calls[0][0]).toContain('per_page=1'); }); it('returns null when commits list is empty', async () => { diff --git a/extension/src/service-worker/gitea.ts b/extension/src/service-worker/gitea.ts index c4b7f77..c8368b0 100644 --- a/extension/src/service-worker/gitea.ts +++ b/extension/src/service-worker/gitea.ts @@ -120,6 +120,7 @@ export class GiteaHost implements GitHost { async lastCommit(path: string): Promise<{ sha: string; author: string; date: string } | null> { try { + // Gitea uses 'limit'; GitHub's equivalent endpoint uses 'per_page'. const url = `${this.commitsUrl}?path=${encodeURIComponent(path)}&limit=1`; const resp = await fetch(url, { headers: this.headers }); if (!resp.ok) return null;