chore: sync project snapshot for gitea/github upload
Some checks failed
CI / build_test_package (push) Has been cancelled
CI / auto_merge (push) Has been cancelled

This commit is contained in:
Your Name
2026-03-26 15:59:53 +08:00
parent e5b0f65156
commit 5f5597ef0f
121 changed files with 5841 additions and 1357 deletions

View File

@@ -10,12 +10,21 @@ const path = require('path');
* 3. 准备测试数据
* 4. 验证服务可用性
*
* 凭证配置:
* - E2E_USER_TOKEN: 真实用户令牌(可选)
* * 如果设置:使用真实凭证创建测试数据,严格模式
* * 如果未设置使用假token降级模式smoke测试
* - E2E_STRICT=true: 严格模式,无真实凭证时测试会失败并明确提示
*
* 如果无法创建真实数据,将使用默认占位数据
*/
// 测试配置
const API_BASE_URL = process.env.API_BASE_URL || 'http://localhost:8080';
const TEST_USER_TOKEN = 'test-e2e-token-' + Date.now();
// E2E_USER_TOKEN 环境变量有真实凭证时直接使用无则生成假token用于服务就绪检测
const E2E_USER_TOKEN = process.env.E2E_USER_TOKEN;
const TEST_USER_TOKEN = E2E_USER_TOKEN || 'test-e2e-token-' + Date.now();
const USE_REAL_CREDENTIALS = Boolean(E2E_USER_TOKEN);
// 默认测试数据
const DEFAULT_TEST_DATA = {
@@ -152,7 +161,10 @@ async function createTestActivity() {
);
if (response.status === 401 || response.status === 403) {
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌`);
if (USE_REAL_CREDENTIALS) {
throw new Error(`认证失败: ${response.status} - 提供的 E2E_USER_TOKEN 无效,请检查凭证是否过期`);
}
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌(请设置 E2E_USER_TOKEN 环境变量)`);
}
if (response.status !== 201) {
@@ -186,7 +198,10 @@ async function generateApiKey(activityId) {
);
if (response.status === 401 || response.status === 403) {
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌`);
if (USE_REAL_CREDENTIALS) {
throw new Error(`认证失败: ${response.status} - 提供的 E2E_USER_TOKEN 无效,请检查凭证是否过期`);
}
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌(请设置 E2E_USER_TOKEN 环境变量)`);
}
if (response.status !== 201) {
@@ -220,7 +235,10 @@ async function createShortLink(activityId, apiKey) {
);
if (response.status === 401 || response.status === 403) {
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌`);
if (USE_REAL_CREDENTIALS) {
throw new Error(`认证失败: ${response.status} - 提供的 E2E_USER_TOKEN 无效,请检查凭证是否过期`);
}
throw new Error(`认证失败: ${response.status} - 需要有效的用户令牌(请设置 E2E_USER_TOKEN 环境变量)`);
}
if (response.status !== 201) {