fix(admin): 生产环境隐藏并禁用自动化测试
侧栏与路由按服务端 NODE_ENV 控制;可通过 ALLOW_SMOKE_TESTS=true 临时开启。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2299,9 +2299,16 @@ export class AdminController {
|
||||
return jsonResponse(messages);
|
||||
}
|
||||
|
||||
@Get('system/smoke-tests')
|
||||
@RequirePermissions(P.settings)
|
||||
getSmokeTestsStatus() {
|
||||
return jsonResponse({ allowed: this.smokeTests.isAllowed() });
|
||||
}
|
||||
|
||||
@Get('smoke-tests/suites')
|
||||
@RequirePermissions(P.settings)
|
||||
async smokeTestSuites() {
|
||||
this.smokeTests.assertAllowed();
|
||||
return jsonResponse({
|
||||
suites: this.smokeTests.listSuites(),
|
||||
cases: this.smokeTests.listCases(),
|
||||
@@ -2312,6 +2319,7 @@ export class AdminController {
|
||||
@Get('smoke-tests/last-run')
|
||||
@RequirePermissions(P.settings)
|
||||
async smokeTestLastRun() {
|
||||
this.smokeTests.assertAllowed();
|
||||
return jsonResponse(this.smokeTests.getLastRun());
|
||||
}
|
||||
|
||||
@@ -2321,6 +2329,7 @@ export class AdminController {
|
||||
@CurrentUser('id') operatorId: bigint,
|
||||
@Body() body: { suites?: string[] },
|
||||
) {
|
||||
this.smokeTests.assertAllowed();
|
||||
const summary = await this.smokeTests.run(body?.suites, operatorId);
|
||||
await this.audit.log({
|
||||
operatorId,
|
||||
|
||||
Reference in New Issue
Block a user