From 303104bb20fb6bf0b378f99163f80f726c21d274 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 26 Jun 2026 14:15:55 +0800 Subject: [PATCH] =?UTF-8?q?test(test=20=E7=9B=AE=E9=8C=84):=20=E5=B0=87=20?= =?UTF-8?q?12=20=E5=80=8B=E5=96=AE=E5=85=83=E6=B8=AC=E8=A9=A6=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=20app/test=20=E4=B8=A6=E6=9B=B4=E6=96=B0=20npm=20test?= =?UTF-8?q?=20=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- app/package.json | 2 +- app/{ => test}/comments.test.js | 4 ++-- app/{ => test}/config.test.js | 2 +- app/{ => test}/findings.test.js | 4 ++-- app/{ => test}/git.test.js | 2 +- app/{ => test}/gitea.test.js | 2 +- app/{ => test}/json.test.js | 2 +- app/{ => test}/llm.test.js | 4 ++-- app/{ => test}/log.test.js | 2 +- app/{ => test}/preflight.test.js | 2 +- app/{ => test}/resolve.test.js | 2 +- app/{ => test}/roles.test.js | 2 +- app/{ => test}/usage.test.js | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) rename app/{ => test}/comments.test.js (99%) rename app/{ => test}/config.test.js (95%) rename app/{ => test}/findings.test.js (99%) rename app/{ => test}/git.test.js (99%) rename app/{ => test}/gitea.test.js (99%) rename app/{ => test}/json.test.js (99%) rename app/{ => test}/llm.test.js (98%) rename app/{ => test}/log.test.js (98%) rename app/{ => test}/preflight.test.js (99%) rename app/{ => test}/resolve.test.js (99%) rename app/{ => test}/roles.test.js (98%) rename app/{ => test}/usage.test.js (99%) diff --git a/app/package.json b/app/package.json index 08c6c22..5dd15ad 100644 --- a/app/package.json +++ b/app/package.json @@ -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", diff --git a/app/comments.test.js b/app/test/comments.test.js similarity index 99% rename from app/comments.test.js rename to app/test/comments.test.js index 7d26416..d39c32c 100644 --- a/app/comments.test.js +++ b/app/test/comments.test.js @@ -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 = []; diff --git a/app/config.test.js b/app/test/config.test.js similarity index 95% rename from app/config.test.js rename to app/test/config.test.js index 13d6f67..c6aa636 100644 --- a/app/config.test.js +++ b/app/test/config.test.js @@ -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', diff --git a/app/findings.test.js b/app/test/findings.test.js similarity index 99% rename from app/findings.test.js rename to app/test/findings.test.js index 8897733..5dc1dc2 100644 --- a/app/findings.test.js +++ b/app/test/findings.test.js @@ -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; diff --git a/app/git.test.js b/app/test/git.test.js similarity index 99% rename from app/git.test.js rename to app/test/git.test.js index 4503465..b011f0a 100644 --- a/app/git.test.js +++ b/app/test/git.test.js @@ -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() { diff --git a/app/gitea.test.js b/app/test/gitea.test.js similarity index 99% rename from app/gitea.test.js rename to app/test/gitea.test.js index 5a2d263..4d819fd 100644 --- a/app/gitea.test.js +++ b/app/test/gitea.test.js @@ -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()); diff --git a/app/json.test.js b/app/test/json.test.js similarity index 99% rename from app/json.test.js rename to app/test/json.test.js index 29aa858..636301a 100644 --- a/app/json.test.js +++ b/app/test/json.test.js @@ -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; diff --git a/app/llm.test.js b/app/test/llm.test.js similarity index 98% rename from app/llm.test.js rename to app/test/llm.test.js index 6fa0d82..5d34206 100644 --- a/app/llm.test.js +++ b/app/test/llm.test.js @@ -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'; diff --git a/app/log.test.js b/app/test/log.test.js similarity index 98% rename from app/log.test.js rename to app/test/log.test.js index 719a6d2..b7f6fac 100644 --- a/app/log.test.js +++ b/app/test/log.test.js @@ -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()); diff --git a/app/preflight.test.js b/app/test/preflight.test.js similarity index 99% rename from app/preflight.test.js rename to app/test/preflight.test.js index ba2e1c5..8d02e5e 100644 --- a/app/preflight.test.js +++ b/app/test/preflight.test.js @@ -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', diff --git a/app/resolve.test.js b/app/test/resolve.test.js similarity index 99% rename from app/resolve.test.js rename to app/test/resolve.test.js index 1ce4c8d..1969e0c 100644 --- a/app/resolve.test.js +++ b/app/test/resolve.test.js @@ -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}`; diff --git a/app/roles.test.js b/app/test/roles.test.js similarity index 98% rename from app/roles.test.js rename to app/test/roles.test.js index 80d7335..c985d8c 100644 --- a/app/roles.test.js +++ b/app/test/roles.test.js @@ -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 diff --git a/app/usage.test.js b/app/test/usage.test.js similarity index 99% rename from app/usage.test.js rename to app/test/usage.test.js index 783c9c7..9c42bf0 100644 --- a/app/usage.test.js +++ b/app/test/usage.test.js @@ -12,7 +12,7 @@ import { fetchAccountQuota, formatUsageStats, formatUsageStatsLine, -} from './usage.js'; +} from '../usage.js'; describe('extractUsage', () => { it('parses OpenAI-compatible usage', () => {