ce4f05b60f
- 更新登录响应模拟数据以匹配真实的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的选项保持界面简洁
101 lines
3.6 KiB
JavaScript
101 lines
3.6 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const ProfilePages = require('../public/js/profile-pages.js');
|
|
const RegionPages = require('../public/js/region-pages.js');
|
|
const UploadPages = require('../public/js/upload-pages.js');
|
|
|
|
test('profile view reads only the documented profile fields', () => {
|
|
assert.deepEqual(ProfilePages.buildProfileView({
|
|
nickName: '小林',
|
|
phone: '13800000000',
|
|
birthday: '1990-01-01',
|
|
provinceCode: '11',
|
|
userName: '不应读取',
|
|
mobile: '不应读取'
|
|
}), {
|
|
displayName: '小林',
|
|
avatarText: '小',
|
|
phone: '13800000000',
|
|
sex: '待填写',
|
|
birthday: '1990-01-01',
|
|
regionText: '加载中...'
|
|
});
|
|
|
|
assert.deepEqual(ProfilePages.buildProfileView({
|
|
userName: '不应读取',
|
|
phonenumber: '不应读取',
|
|
mobile: '不应读取'
|
|
}), {
|
|
displayName: '未设置昵称',
|
|
avatarText: '家',
|
|
phone: '未绑定',
|
|
sex: '待填写',
|
|
birthday: '待填写',
|
|
regionText: '待填写'
|
|
});
|
|
});
|
|
|
|
test('profile update emits only the six fields defined by ProfileUpdateBody', () => {
|
|
assert.deepEqual(ProfilePages.buildProfileUpdateBody({
|
|
nickName: '小林',
|
|
realName: '林某',
|
|
avatar: '',
|
|
sex: '0',
|
|
birthday: '1990-01-01',
|
|
email: 'lin@example.com',
|
|
avatarOssId: 'legacy-avatar',
|
|
provinceCode: '11'
|
|
}), {
|
|
nickName: '小林',
|
|
realName: '林某',
|
|
sex: '0',
|
|
birthday: '1990-01-01',
|
|
email: 'lin@example.com'
|
|
});
|
|
assert.deepEqual(ProfilePages.buildProfileUpdateBody({ avatar: '123' }), { avatar: '123' });
|
|
assert.deepEqual(
|
|
ProfilePages.buildProfileUpdateBody({ avatar: '2060000000000000001' }),
|
|
{ avatar: '2060000000000000001' }
|
|
);
|
|
assert.equal(UploadPages.normalizeUploadResult({ ossId: '2060000000000000000' }).ossId, '2060000000000000000');
|
|
});
|
|
|
|
test('region selector accepts only documented region fields and levels', () => {
|
|
assert.deepEqual(RegionPages.normalizeList({ data: [{ regionCode: '11' }] }), []);
|
|
assert.equal(RegionPages.getRegionCode({ value: '11' }), '');
|
|
assert.equal(RegionPages.getRegionName({ label: '北京市' }), '未命名地区');
|
|
assert.equal(RegionPages.getRegionLevel({ regionCode: '110101' }), 0);
|
|
|
|
assert.deepEqual(RegionPages.buildRegionSelection([
|
|
{ regionCode: '11', regionName: '北京市', regionLevel: 1 },
|
|
{ regionCode: '1101', regionName: '市辖区', regionLevel: 2 },
|
|
{ regionCode: '110101', regionName: '东城区', regionLevel: 3 }
|
|
]), {
|
|
provinceCode: '11',
|
|
cityCode: '1101',
|
|
districtCode: '110101'
|
|
});
|
|
});
|
|
|
|
test('profile data page exposes every editable ProfileUpdateBody field without a manual OSS ID input', () => {
|
|
const source = fs.readFileSync(path.join(__dirname, '..', 'profile-data.html'), 'utf8');
|
|
|
|
assert.match(source, /data-profile-form/);
|
|
assert.match(source, /name="nickName"/);
|
|
assert.match(source, /name="realName"/);
|
|
assert.match(source, /name="avatar"/);
|
|
assert.match(source, /name="sex"[\s\S]*<option value="2">未知<\/option>/);
|
|
assert.match(source, /name="birthday"/);
|
|
assert.match(source, /name="email"/);
|
|
assert.doesNotMatch(source, /name="avatarOssId"/);
|
|
assert.match(source, /name="avatar"[\s\S]*type="hidden"|type="hidden"[\s\S]*name="avatar"/);
|
|
assert.doesNotMatch(source, /data-region-profile-form/);
|
|
assert.doesNotMatch(source, /data-region-profile-status/);
|
|
assert.match(source, /data-region-search-form/);
|
|
assert.match(source, /src="public\/js\/upload-pages\.js"/);
|
|
assert.match(source, /src="public\/js\/region-pages\.js"/);
|
|
});
|