Files
gstack/test/shared-libs-pr-coverage-budget.test.ts
T
garrytan e0f30196a7 test: shared-libs PR coverage checks the stated page budget, not per-PR ceilings from one run (W7d shared-libs per-endpoint page caps)
prCoverageRequestViolations keeps the skill's stated older-open-PR budget
(five metadata pages, fifty file-list pages plus recent PR 7) and the coverage
outcome (PR 42's file list read from page 1 through page 2). It drops the PR 42
three/four-page and single-first-page ceilings, which were tuned to one
observed capture with a truncated first view. The judge criteria are
unchanged. Stored endpoint lists: three known-good (including a re-read first
page the old ceilings rejected) pass; four known-bad plus an over-budget
file-list run fail. incompleteFirstFileView is no longer used by the paid case.
2026-10-03 00:44:12 +00:00

22 lines
1.2 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
import { prCoverageRequestViolations } from './helpers/shared-libs-eval-fixture';
const stored = JSON.parse(fs.readFileSync(path.join(import.meta.dir, 'fixtures/shared-libs/pr-coverage-endpoints.json'), 'utf8')) as
{ known_good: Record<string, string[]>; known_bad: Record<string, string[]> };
describe('shared-libs PR coverage request budget', () => {
test.each(Object.entries(stored.known_good))('passes %s', (_name, endpoints) => {
expect(prCoverageRequestViolations(endpoints)).toEqual([]);
});
test.each(Object.entries(stored.known_bad))('fails %s', (_name, endpoints) => {
expect(prCoverageRequestViolations(endpoints).length).toBeGreaterThan(0);
});
test('file-list pages beyond the stated budget fail', () => {
const pages = Array.from({ length: 52 }, (_, i) => `/repos/fixture/shared-libs/pulls/${i < 2 ? 42 : 100 + i}/files?per_page=100&page=${i < 2 ? i + 1 : 1}`);
expect(prCoverageRequestViolations(pages)).toEqual(['52 file-list pages exceed the budget of 50 plus PR 7']);
expect(prCoverageRequestViolations(pages.slice(0, 51))).toEqual([]);
});
});