Conversation
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
0d7ce62 to
e7aabaa
Compare
There was a problem hiding this comment.
Pull request overview
Adds initial Bun-based unit/component tests for the TypeScript webapp and wires them into the repository’s CI workflow, with a small refactor to make URL-related helpers independently testable.
Changes:
- Introduces Bun test suites for URL utilities, GitHub API ref fetching, and
IfUrlLinkrendering. - Extracts URL parsing/sanitization helpers into a dedicated module and updates the app to use it.
- Adds test-oriented TypeScript config and updates CI/scripts to run
bun test.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.test.json | New TS config intended for type-checking test files with Bun types. |
| tsconfig.json | Excludes *.test.ts/tsx from the main TS compilation. |
| src/repo-review-app/utils/url.ts | New shared helpers for packageDir sanitization + refType parsing. |
| src/repo-review-app/utils/url.test.ts | Unit tests for the new URL helpers. |
| src/repo-review-app/utils/github.ts | Adds explicit JSON typing for GitHub refs responses. |
| src/repo-review-app/utils/github.test.ts | Unit tests for fetchRepoRefs using a mocked fetch. |
| src/repo-review-app/repo-review-app.tsx | Uses extracted URL helpers instead of inline functions. |
| src/repo-review-app/components/IfUrlLink.test.tsx | Component-level rendering tests via renderToStaticMarkup. |
| package.json | Adds test and type:test scripts; adds @types/bun. |
| bun.lock | Lockfile updates for Bun/Node typing dependencies. |
| .github/workflows/ci.yml | Runs Bun tests in CI. |
Comments suppressed due to low confidence (1)
src/repo-review-app/utils/github.ts:25
branches/tagsare already parsed asArray<{ name: string }>but the subsequentmapstill uses(branch: any)/(tag: any). This defeats the purpose of the cast and can hide JSON-shape regressions. Use the inferred element type (or define aRefJsontype) and drop theanyannotations in themapcallbacks.
const branches = (await branchesResponse.json()) as Array<{
name: string;
}>;
const tags = (await tagsResponse.json()) as Array<{ name: string }>;
return {
branches: branches.map((branch: any) => ({
name: branch.name,
type: "branch",
})),
tags: tags.map((tag: any) => ({ name: tag.name, type: "tag" })),
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| beforeEach(() => { | ||
| savedFetch = globalThis.fetch; | ||
| spyOn(console, "error").mockImplementation(() => {}); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| globalThis.fetch = savedFetch; |
There was a problem hiding this comment.
console.error is spied on in beforeEach but never restored in afterEach. This can leak the mocked implementation into other test files (and can also accumulate spies across tests). Capture the spy returned by spyOn(...) and restore it in afterEach (or call the appropriate restore method supported by bun:test).
| beforeEach(() => { | |
| savedFetch = globalThis.fetch; | |
| spyOn(console, "error").mockImplementation(() => {}); | |
| }); | |
| afterEach(() => { | |
| globalThis.fetch = savedFetch; | |
| let consoleErrorSpy: ReturnType<typeof spyOn>; | |
| beforeEach(() => { | |
| savedFetch = globalThis.fetch; | |
| consoleErrorSpy = spyOn(console, "error"); | |
| consoleErrorSpy.mockImplementation(() => {}); | |
| }); | |
| afterEach(() => { | |
| globalThis.fetch = savedFetch; | |
| consoleErrorSpy.mockRestore(); |
| @@ -42,6 +42,8 @@ jobs: | |||
| run: bun run lint | |||
| - name: Run type checker | |||
| run: bun run type | |||
There was a problem hiding this comment.
CI runs bun run type, but tsconfig.json now excludes *.test.ts/tsx and the new type:test script isn’t executed. This means TypeScript errors in tests won’t be caught by CI. Add a CI step to run bun run type:test (or adjust the existing typecheck to cover both app code and tests).
| run: bun run type | |
| run: bun run type | |
| - name: Run test type checker | |
| run: bun run type:test |
Adding some tests, vscode + copilot.