test(test 目錄): 將 12 個單元測試移至 app/test 並更新 npm test 指令

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-26 14:15:55 +08:00
co-authored by Claude Opus 4.8
parent 51fd223b48
commit 303104bb20
13 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
"version": "1.0.0",
"type": "module",
"scripts": {
"test": "node --test *.test.js"
"test": "node --test test/*.test.js"
},
"dependencies": {
"axios": "^1.6.7",
@@ -3,8 +3,8 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { saveFindings, parseLocation, postNewCriticalComments, postFindingsReview, formatFindingsStats, formatFindingsStatsLine } from './comments.js';
import { FINDINGS_PATH } from './config.js';
import { saveFindings, parseLocation, postNewCriticalComments, postFindingsReview, formatFindingsStats, formatFindingsStatsLine } from '../comments.js';
import { FINDINGS_PATH } from '../config.js';
describe('saveFindings', () => {
const tempDirs = [];
@@ -1,6 +1,6 @@
import { describe, it, beforeEach, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import { getLLMConfig, getOpenCodeHttpsAgent } from './config.js';
import { getLLMConfig, getOpenCodeHttpsAgent } from '../config.js';
const ENV_KEYS = [
'OPENCODE_BASE_URL', 'OPENCODE_MODEL', 'OPENCODE_PROVIDER',
@@ -3,8 +3,8 @@ import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { loadOldFindings, loadExclusions, applyExclusions, filterFalsePositivesWithAI, appendExclusions, resolveMissingLineNumbers } from './findings.js';
import { EXCLUSIONS_PATH, FINDINGS_PATH } from './config.js';
import { loadOldFindings, loadExclusions, applyExclusions, filterFalsePositivesWithAI, appendExclusions, resolveMissingLineNumbers } from '../findings.js';
import { EXCLUSIONS_PATH, FINDINGS_PATH } from '../config.js';
describe('findings exclusions', () => {
let workspace;
+1 -1
View File
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { commitAndPush, cloneRepo, verifyRemoteAccess, BOT_COMMIT_MARKER, getHeadCommitMessage, isBotAutoCommit } from './git.js';
import { commitAndPush, cloneRepo, verifyRemoteAccess, BOT_COMMIT_MARKER, getHeadCommitMessage, isBotAutoCommit } from '../git.js';
// --- helpers ---
function makeTmpWorkspace() {
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, afterEach, mock } from 'node:test';
import assert from 'node:assert/strict';
import axios from 'axios';
import { getPRDiff, filterDiff, postComment, postPullReviewComment, postPullReview, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome, listPullReviews, getPullReviewComments, listAllReviewComments, resolvePullReviewComment, getFileContentAtRef } from './gitea.js';
import { getPRDiff, filterDiff, postComment, postPullReviewComment, postPullReview, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome, listPullReviews, getPullReviewComments, listAllReviewComments, resolvePullReviewComment, getFileContentAtRef } from '../gitea.js';
afterEach(() => mock.restoreAll());
+1 -1
View File
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { stripCodeFence, repairJSONArrayWithAI, validateJSONArrayFile, ensureJSONArrayFileExists } from './json.js';
import { stripCodeFence, repairJSONArrayWithAI, validateJSONArrayFile, ensureJSONArrayFileExists } from '../json.js';
describe('json helpers', () => {
const MAX_JSON_BYTES = 1024 * 1024;
+2 -2
View File
@@ -29,7 +29,7 @@ function mockOpenCodeResponse(content) {
}
describe('chat - OpenCode', async () => {
const { chat } = await import('./llm.js');
const { chat } = await import('../llm.js');
it('uses OpenCode server session API', async () => {
process.env.OPENCODE_BASE_URL = 'http://opencode.local:4096';
@@ -96,7 +96,7 @@ describe('chat - OpenCode', async () => {
});
describe('chatJSON', async () => {
const { chatJSON } = await import('./llm.js');
const { chatJSON } = await import('../llm.js');
it('parses plain JSON response', async () => {
process.env.OPENCODE_BASE_URL = 'http://opencode.local:4096';
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, it, afterEach, mock } from 'node:test';
import assert from 'node:assert/strict';
import { section, step, line, input, output, result, ok, warn, error } from './log.js';
import { section, step, line, input, output, result, ok, warn, error } from '../log.js';
afterEach(() => mock.restoreAll());
@@ -1,7 +1,7 @@
import { describe, it, afterEach, mock } from 'node:test';
import assert from 'node:assert/strict';
import axios from 'axios';
import { checkRequiredEnv, verifyGiteaToken, verifyCommentToken, verifyLLM, runPreflight } from './preflight.js';
import { checkRequiredEnv, verifyGiteaToken, verifyCommentToken, verifyLLM, runPreflight } from '../preflight.js';
const LLM_ENV_KEYS = [
'OPENCODE_BASE_URL', 'OPENCODE_MODEL', 'OPENCODE_PROVIDER',
@@ -8,7 +8,7 @@ import {
reconcileConversations,
dropResolvedFindings,
addCarriedFindings,
} from './resolve.js';
} from '../resolve.js';
const reviewBody = (level, role, problem, suggestion) =>
`**嚴重等級**${level}\n**審查員**${role}\n**問題**${problem}\n**建議**${suggestion}`;
+1 -1
View File
@@ -1,6 +1,6 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { parseRoleFile, loadRoles, loadRole, buildAnalysisPrompt, buildLocateLinePrompt, getRoleIntro } from './roles.js';
import { parseRoleFile, loadRoles, loadRole, buildAnalysisPrompt, buildLocateLinePrompt, getRoleIntro } from '../roles.js';
const SAMPLE = `---
name: Tester
+1 -1
View File
@@ -12,7 +12,7 @@ import {
fetchAccountQuota,
formatUsageStats,
formatUsageStatsLine,
} from './usage.js';
} from '../usage.js';
describe('extractUsage', () => {
it('parses OpenAI-compatible usage', () => {