- Each wish says whether it may change backend code. A frontend-only wish is told which paths it must leave alone; a change to them goes back before any check runs, the platform puts those files back before the repair round, and the control plane never integrates them. A wish that may change backend code integrates directly for people with backend permission and waits for a code review otherwise. - Owners and admins grant backend permission per person on the members page as well as per project in the project settings. - AI optimization has its own button for the wish and for the criteria. It writes a wish of at most three lines (goal, scope, limits), keeps the details in checkable criteria, and asks only what the person must decide, as choices whose answers join the wish; suggested criteria are taken one by one. - Lists, run titles, Feishu cards and pull request titles show a wish's first line; the run details show the rest. - Changed paths no longer follow renames, so moving backend code into a frontend directory counts at both places for code review and for the frontend-only scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
2.1 KiB
TypeScript
44 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { globPattern, invalidGlob, pathsNeedingReview } from '@wishforge/contracts/path-rules';
|
|
import { codeReviewPolicyInput } from '@wishforge/contracts';
|
|
|
|
describe('code review path rules', () => {
|
|
it('matches directories, one level and any depth', () => {
|
|
expect(globPattern('backend/').test('backend/api/server.go')).toBe(true);
|
|
expect(globPattern('backend/').test('backend-tools/x')).toBe(false);
|
|
expect(globPattern('*.go').test('main.go')).toBe(true);
|
|
expect(globPattern('*.go').test('cmd/main.go')).toBe(false);
|
|
expect(globPattern('**/*.go').test('main.go')).toBe(true);
|
|
expect(globPattern('**/*.go').test('internal/store/db.go')).toBe(true);
|
|
expect(globPattern('src/?.ts').test('src/a.ts')).toBe(true);
|
|
expect(globPattern('src/?.ts').test('src/ab.ts')).toBe(false);
|
|
expect(globPattern('./go.mod').test('go.mod')).toBe(true);
|
|
// Other regular expression characters are literal.
|
|
expect(globPattern('a+b.(c)').test('a+b.(c)')).toBe(true);
|
|
expect(globPattern('a+b.(c)').test('aab.c')).toBe(false);
|
|
});
|
|
it('holds what the policy names, minus its exceptions', () => {
|
|
const policy = { paths: ['**/*.go', 'api/'], exceptPaths: ['**/*_test.go', 'api/docs/'] };
|
|
expect(
|
|
pathsNeedingReview(
|
|
['web/app.js', 'cmd/main.go', 'cmd/main_test.go', 'api/routes.ts', 'api/docs/readme.md'],
|
|
policy,
|
|
),
|
|
).toEqual(['cmd/main.go', 'api/routes.ts']);
|
|
expect(pathsNeedingReview(['cmd/main.go'], undefined)).toEqual([]);
|
|
expect(pathsNeedingReview(['cmd/main.go'], { paths: [], exceptPaths: [] })).toEqual([]);
|
|
});
|
|
it('refuses patterns outside the repository', () => {
|
|
expect(invalidGlob('/etc/passwd')).toBeTruthy();
|
|
expect(invalidGlob('../other/')).toBeTruthy();
|
|
expect(invalidGlob('a\\b')).toBeTruthy();
|
|
expect(invalidGlob('backend/')).toBeUndefined();
|
|
expect(() => codeReviewPolicyInput.parse({ paths: ['../x'] })).toThrow();
|
|
expect(codeReviewPolicyInput.parse({ paths: ['backend/'] })).toEqual({
|
|
paths: ['backend/'],
|
|
exceptPaths: [],
|
|
trustedMembers: [],
|
|
});
|
|
});
|
|
});
|