From eea51447106599280403af887561f620a64cb775 Mon Sep 17 00:00:00 2001 From: doublex001 <16157008+doublex001@user.noreply.gitee.com> Date: Tue, 29 Sep 2026 17:10:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E6=94=B6=E5=B0=BE=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=90=8E=E7=AB=AF=E5=88=87=E6=8D=A2=E9=81=97=E7=95=99?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=EF=BC=88mock=20=E5=85=9C=E5=BA=95=E5=BC=80?= =?UTF-8?q?=E5=85=B3=20/=20=E4=B8=AA=E4=BA=BA=E8=B5=84=E6=96=99=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=20/=20=E6=B5=8B=E8=AF=95=E5=AF=B9=E9=BD=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上轮接真实后端(求职端核心闭环)后遗留在工作区、未随提交入库的 4 处改动: - app.config.js: apiUseMock 恢复 true —— 已接真实分支的接口走后端、未接的继续走 mock, 保证 App 随时可跑;联调只接哪些就切哪些,不做一刀切 false 导致整体白屏 - app/(tabs)/profile.tsx: 求职偏好取值加 ?? '' 兜底,存储缺字段 / 后端 partial 响应 不再让 value.trim() 抛 undefined - 测试: job-api fetchJobDetail 断言对齐 /jobs/public/{id};password 的改密用例补 setMockMode(true); profile-resume 对齐 /profile/me 的 realName/location/education 字段名 (此批为上一轮遗留,非本次 P0-6 产出,故单独成提交) --- app.config.js | 4 +++- app/(tabs)/profile.tsx | 3 ++- src/__tests__/password.test.ts | 2 ++ src/__tests__/profile-resume.test.ts | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app.config.js b/app.config.js index ef4c47a..218aedd 100644 --- a/app.config.js +++ b/app.config.js @@ -78,7 +78,9 @@ export default { // 业务接口基地址(规范 §1)。默认生产 HTTPS 域名;联调/本地可用环境变量 API_BASE_URL 覆盖。 apiBaseUrl: process.env.API_BASE_URL || 'https://job.youthome.com.cn/api/v1', // mock 开关:联调期为 false 统一走真实后端;业务函数按接口是否已接通决定是否绕过 mock。 - apiUseMock: false, + // 2026-09-29 接真实后端(求职端核心闭环)期间先恢复 true 兜底: + // 已接好真实分支的接口走后端,未接的继续走 mock,保证 App 随时可跑、不回归。 + apiUseMock: true, // EAS 项目 ID:`eas init` 后会自动注入此处(与 updates.url 中的 PROJECT_ID 对应)。 eas: { projectId: 'REPLACE_WITH_PROJECT_ID', diff --git a/app/(tabs)/profile.tsx b/app/(tabs)/profile.tsx index 7a43310..768d0d3 100644 --- a/app/(tabs)/profile.tsx +++ b/app/(tabs)/profile.tsx @@ -304,7 +304,8 @@ export default function ProfileScreen() { {PREF_ITEMS.map(({ key, label }, index) => { - const value = preference[key]; + // 兜底:preference[key] 运行时可能为 undefined(存储数据缺字段 / 后端 partial 响应) + const value = preference[key] ?? ''; const isLast = index === PREF_ITEMS.length - 1; // 未采集到的项显示「未设置」,不拿空串冒充已填;也就不再显示状态圆点 const isUnset = value.trim() === ''; diff --git a/src/__tests__/password.test.ts b/src/__tests__/password.test.ts index b4ec253..070d822 100644 --- a/src/__tests__/password.test.ts +++ b/src/__tests__/password.test.ts @@ -232,6 +232,8 @@ describe('resetPassword(重置 / 首次设置密码)', () => { }); describe('changePassword(已登录态改密)', () => { + beforeAll(() => setMockMode(true)); + it('未填原密码时拒绝', async () => { await expect( changePassword({ oldPassword: '', newPassword: 'abc12345', confirmPassword: 'abc12345' }), diff --git a/src/__tests__/profile-resume.test.ts b/src/__tests__/profile-resume.test.ts index 452bdbf..7511981 100644 --- a/src/__tests__/profile-resume.test.ts +++ b/src/__tests__/profile-resume.test.ts @@ -86,12 +86,12 @@ describe('个人资料 / 简历 域 mock 开关', () => { it('真实模式:fetchUserProfile 先打 /profile/me(后端字段空时兜底 /auth/me)', async () => { setMockMode(false); - // 后端 /profile/me 返回的字段名(nickname / avatarUrl),不是前端 UserProfile 的 name / avatarKey - responder = () => okData({ nickname: '张三', avatarUrl: 'a1' }); + // 后端 StudentProfileResponse 字段名:realName / location / education 等 + responder = () => okData({ realName: '张三', location: '北京', education: '本科' }); const profile = await fetchUserProfile(); // 第一个请求应该是 /profile/me expect(fetchCalls[0].url).toBe(`${API_BASE_URL}/profile/me`); - // profile 非空时不请求 auth/me,直接用后端字段映射 + // profile 关键字段非空时不请求 auth/me,直接用后端字段映射 expect(fetchCalls.length).toBe(1); expect(profile.name).toBe('张三'); expect(profile.avatar).toBe('张');