test(ai-review comment): 補齊留言更新與 TLS 設定覆蓋

This commit is contained in:
2026-06-22 09:05:31 +00:00
parent 8e4ea97dac
commit f0544bb758
4 changed files with 52 additions and 1 deletions
+17 -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, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome } from './gitea.js';
import { getPRDiff, filterDiff, postComment, updateComment, postPullReviewComment, getCommitMessageBySha, getBranchHeadCommitMessage, shouldSkipBotCommit, getBotReviewOutcome } from './gitea.js';
afterEach(() => mock.restoreAll());
@@ -57,6 +57,22 @@ describe('gitea', () => {
await assert.rejects(() => postComment('test'), /api error/);
});
it('updateComment patches an existing issue comment with body', async () => {
let capturedUrl, capturedBody, capturedOpts;
mock.method(axios, 'patch', async (url, body, opts) => {
capturedUrl = url;
capturedBody = body;
capturedOpts = opts;
return { data: { id: 123, body: body.body } };
});
const result = await updateComment(123, 'updated body');
assert.deepEqual(result, { id: 123, body: 'updated body' });
assert.ok(capturedUrl.includes('/api/v1/repos/'));
assert.ok(capturedUrl.endsWith('/issues/comments/123'));
assert.equal(capturedBody.body, 'updated body');
assert.ok(capturedOpts.headers['Authorization'].startsWith('token '));
});
it('postPullReviewComment posts an inline review comment to the pulls reviews API', async () => {
let capturedUrl, capturedBody, capturedOpts;
mock.method(axios, 'post', async (url, body, opts) => {