Files
jiapu/tests/pc-scope.test.js
T
fizzleaf ce4f05b60f test(api): 更新API客户端契约测试以符合YAML规范
- 更新登录响应模拟数据以匹配真实的AppLoginVo结构
- 添加认证客户端租户和授权字段验证
- 增加操作码枚举验证测试用例
- 移除对旧token别名的兼容性测试
- 修复测试用例中的短信验证码长度一致性问题
- 更新区域接口路径为PC专用路径
- 调整分片上传接口参数以符合新契约定义

refactor(api): 重构API客户端实现以严格遵循YAML契约

- 添加认证操作码和短信操作码枚举验证
- 实现严格的token响应解析只接受access_token字段
- 使用pickDefined函数过滤请求体中未定义的字段
- 重构认证接口参数映射以符合契约定义
- 更新区域接口路径为PC专用路径/genealogy/pc/region/*
- 优化分片上传接口参数结构与契约保持一致
- 添加操作码枚举验证函数toRequiredOperationCode
- 实现请求体字段选择性提取功能

feat(auth): 优化认证页面的验证码处理流程

- 添加takeCaptchaToken函数用于一次性获取验证码票据
- 更新短信验证码长度验证从4-6位改为精确4位
- 在登录和密码重置流程中集成验证码票据处理
- 修复验证码发送后票据清理逻辑
- 更新HTML模板中的验证码输入字段属性

chore(config): 提取常量配置并扩展配置对象结构

- 将客户端ID、租户ID和令牌键提取为常量
- 扩展配置对象返回客户端配置信息
- 更新配置测试用例以验证新增配置项

docs(planning): 更新PC接口对接规划文档

- 更新契约源说明以反映YAML冻结契约
- 添加YAML与在线Apifox复核对比内容
- 更新阻断项状态表格
- 修订登录响应token字段处理规范
- 更新文件上传和行政区划接口规范说明

style(profile): 优化相册管理页面的文件上传交互

- 将封面和照片OSS ID输入改为隐藏字段
- 添加文件选择标签以改善用户体验
- 移除手动输入OSS ID的选项保持界面简洁
2026-07-28 15:06:34 +08:00

61 lines
2.8 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const root = path.resolve(__dirname, '..');
function read(relativePath) {
return fs.readFileSync(path.join(root, relativePath), 'utf8');
}
test('配置始终使用后端提供的 PC 接口地址', () => {
const createConfig = require('../config.js');
const development = createConfig({ location: { hostname: 'localhost', port: '5500' } });
const production = createConfig({ location: { hostname: 'genealogy.example.test', port: '' } });
assert.equal(development.getEnvironment(), 'development');
assert.equal(production.getEnvironment(), 'production');
assert.equal(development.getApiBaseUrl(), 'https://backend-api.ddxcjp.cn/');
assert.equal(production.getApiBaseUrl(), 'https://backend-api.ddxcjp.cn/');
assert.deepEqual(production.getConfig(), {
environment: 'production',
apiBaseUrl: 'https://backend-api.ddxcjp.cn/',
clientId: 'ced7e5f0498645c6ec642dcf450b036f',
tenantId: '000000',
tokenKey: 'genealogy_auth_token'
});
});
test('PC 对接规划记录本轮由用户指定的 YAML 冻结契约', () => {
const plan = read('docs/PC接口对接规划.md');
assert.match(plan, /genealogy-pc-openapi\.yaml` 对接,因此该 YAML 是本轮冻结契约/);
assert.match(plan, /旧 OpenAPI 文件不再作为新增功能依据/);
});
test('pages do not load scripts for unavailable business APIs', () => {
const removedScripts = [
'album-pages.js', 'article-pages.js', 'ceremony-pages.js',
'feedback-pages.js', 'genealogy-pages.js',
'help-pages.js', 'join-apply-pages.js', 'member-admin-pages.js',
'promotion-pages.js', 'vip-pages.js'
];
const retainedPages = fs.readdirSync(root).filter((entry) => entry.endsWith('.html'));
retainedPages.forEach((page) => {
const source = read(page);
removedScripts.forEach((script) => {
assert.equal(source.includes('src="public/js/' + script + '"'), false, `${page} still loads ${script}`);
});
});
['profile-feed.html', 'profile-feed-edit.html'].forEach((page) => {
assert.equal(read(page).includes('src="public/js/feed-pages.js"'), true, `${page} must load feed-pages.js`);
});
assert.equal(read('profile-generation.html').includes('src="public/js/generation-pages.js"'), true, 'profile-generation.html must load generation-pages.js');
assert.equal(read('profile-tree.html').includes('src="public/js/lineage-pages.js"'), true, 'profile-tree.html must load lineage-pages.js');
assert.equal(read('profile-relative.html').includes('src="public/js/relative-pages.js"'), true, 'profile-relative.html must load relative-pages.js');
assert.equal(read('profile-memo.html').includes('src="public/js/memo-pages.js"'), true, 'profile-memo.html must load memo-pages.js');
});