Files
cnb/test/issue-comment.ts
xiongxiao 38ee73e48f feat: update package version to 0.0.42 and add CNB version fetching functionality
- Updated package version in package.json from 0.0.40 to 0.0.42.
- Added getCNBVersion function to fetch CNB version information from the API.
- Enhanced Issue class with methods for managing comments (list, create, get, update).
- Introduced new NPC and comment environment hooks for better context management.
- Implemented Docker image synchronization route for CNB.
- Added tests for version fetching and issue comment functionalities.
2026-03-10 03:45:02 +08:00

43 lines
1.3 KiB
TypeScript

import { Issue } from "../src/issue/index.ts";
import { token, showMore, cookie } from "./common.ts";
const issue = new Issue({
token: token,
cookie: cookie
});
const repo = "kevisual/dev-env";
const issueNumber = 5;
// 1. 查询评论列表
console.log("=== 1. 查询评论列表 ===");
const commentListRes = await issue.getCommentList(repo, issueNumber, {
page: 1,
page_size: 30
});
console.log(showMore(commentListRes));
// 2. 创建评论
console.log("\n=== 2. 创建评论 ===");
const createRes = await issue.createComment(repo, issueNumber, "测试评论内容 " + new Date().toISOString());
console.log(showMore(createRes));
// 如果创建成功,获取评论 ID
let commentId = null;
if (createRes.code === 200 && createRes.data?.id) {
commentId = createRes.data.id;
console.log("创建的评论 ID:", commentId);
// 3. 获取单个评论
console.log("\n=== 3. 获取单个评论 ===");
const getRes = await issue.getComment(repo, issueNumber, commentId);
console.log(showMore(getRes));
// 4. 修改评论
console.log("\n=== 4. 修改评论 ===");
const updateRes = await issue.updateComment(repo, issueNumber, commentId, "这是修改后的评论内容 " + new Date().toISOString());
console.log(showMore(updateRes));
}
const env = issue.useCommentEnv();
process.exit(0);