The PR still had a few targeted review threads around contributor pagination, route-layer passthroughs, dead header fallbacks, and synthetic response ids. These are small enough to settle directly on the release branch without broadening the merge scope, and they tighten the repo back toward the service-owned boundaries this refactor is aiming for. Constraint: Keep the changes narrow and regression-covered so the release PR stays green while review threads are closed out Rejected: Leave the minor threads for follow-up after merge | they were isolated enough to fix now and would keep noise on the PR Confidence: high Scope-risk: narrow Directive: When a route shim stops serving any route-local behavior, point callers at the owning service instead of keeping a passthrough around Tested: Focused vitest for contributor updater, openai responses response bridge, upstream request builder, stats proxy logs, architecture boundaries; typecheck; repo drift check; git diff --check Not-tested: Full npm test; unresolved review threads that still require larger product decisions
120 lines
3.7 KiB
TypeScript
120 lines
3.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
parsePaginatedJson,
|
|
normalizeContributors,
|
|
replaceContributorsSection,
|
|
renderContributorsBlock,
|
|
} from './update-readme-contributors.js';
|
|
|
|
describe('README contributors updater', () => {
|
|
it('filters anonymous and bot contributors before rendering', () => {
|
|
const contributors = normalizeContributors([
|
|
{
|
|
login: 'cita-777',
|
|
html_url: 'https://github.com/cita-777',
|
|
avatar_url: 'https://avatars.githubusercontent.com/u/177306803?v=4',
|
|
contributions: 483,
|
|
},
|
|
{
|
|
login: 'dependabot[bot]',
|
|
html_url: 'https://github.com/apps/dependabot',
|
|
avatar_url: 'https://avatars.githubusercontent.com/in/29110?v=4',
|
|
contributions: 12,
|
|
},
|
|
{
|
|
login: null,
|
|
html_url: null,
|
|
avatar_url: null,
|
|
contributions: 22,
|
|
},
|
|
{
|
|
login: 'Babylonehy',
|
|
html_url: 'https://github.com/Babylonehy',
|
|
avatar_url: 'https://avatars.githubusercontent.com/u/30937892?v=4',
|
|
contributions: 3,
|
|
},
|
|
]);
|
|
|
|
expect(contributors).toEqual([
|
|
{
|
|
login: 'cita-777',
|
|
htmlUrl: 'https://github.com/cita-777',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/177306803?v=4&s=48',
|
|
},
|
|
{
|
|
login: 'Babylonehy',
|
|
htmlUrl: 'https://github.com/Babylonehy',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/30937892?v=4&s=48',
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('replaces the marked README section with an avatar wall', () => {
|
|
const readme = [
|
|
'# Metapi',
|
|
'',
|
|
'<!-- metapi-contributors:start -->',
|
|
'old block',
|
|
'<!-- metapi-contributors:end -->',
|
|
'',
|
|
'tail',
|
|
].join('\n');
|
|
|
|
const next = replaceContributorsSection(readme, [
|
|
{
|
|
login: 'cita-777',
|
|
htmlUrl: 'https://github.com/cita-777',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/177306803?v=4&s=48',
|
|
},
|
|
{
|
|
login: 'Hureru',
|
|
htmlUrl: 'https://github.com/Hureru',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/121702350?v=4&s=48',
|
|
},
|
|
{
|
|
login: 'Babylonehy',
|
|
htmlUrl: 'https://github.com/Babylonehy',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/30937892?v=4&s=48',
|
|
},
|
|
], 2);
|
|
|
|
expect(next).toContain('<p align="left">');
|
|
expect(next).toContain('https://github.com/cita-777');
|
|
expect(next).toContain('https://github.com/Hureru');
|
|
expect(next).toContain('https://github.com/Babylonehy');
|
|
expect(next).not.toContain('old block');
|
|
expect(next).toContain('tail');
|
|
});
|
|
|
|
it('renders contributors across multiple rows', () => {
|
|
const html = renderContributorsBlock([
|
|
{
|
|
login: 'cita-777',
|
|
htmlUrl: 'https://github.com/cita-777',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/177306803?v=4&s=48',
|
|
},
|
|
{
|
|
login: 'Hureru',
|
|
htmlUrl: 'https://github.com/Hureru',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/121702350?v=4&s=48',
|
|
},
|
|
{
|
|
login: 'Babylonehy',
|
|
htmlUrl: 'https://github.com/Babylonehy',
|
|
avatarUrl: 'https://avatars.githubusercontent.com/u/30937892?v=4&s=48',
|
|
},
|
|
], 2);
|
|
|
|
expect(html).toContain('\n <a href="https://github.com/cita-777"');
|
|
expect(html).toContain('\n <a href="https://github.com/Babylonehy"');
|
|
expect((html.match(/\n <a href=/g) || []).length).toBe(2);
|
|
});
|
|
|
|
it('parses concatenated paginated gh api arrays without requiring newlines between pages', () => {
|
|
expect(parsePaginatedJson('[{"login":"a"}][{"login":"b"}]')).toEqual([
|
|
{ login: 'a' },
|
|
{ login: 'b' },
|
|
]);
|
|
});
|
|
});
|