Browse Source

fix(config): 收尾真实后端切换遗留改动(mock 兜底开关 / 个人资料空值 / 测试对齐)

上轮接真实后端(求职端核心闭环)后遗留在工作区、未随提交入库的 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 产出,故单独成提交)
master
doublex001 4 weeks ago
parent
commit
eea5144710
  1. 4
      app.config.js
  2. 3
      app/(tabs)/profile.tsx
  3. 2
      src/__tests__/password.test.ts
  4. 6
      src/__tests__/profile-resume.test.ts

4
app.config.js

@ -78,7 +78,9 @@ export default {
// 业务接口基地址(规范 §1)。默认生产 HTTPS 域名;联调/本地可用环境变量 API_BASE_URL 覆盖。 // 业务接口基地址(规范 §1)。默认生产 HTTPS 域名;联调/本地可用环境变量 API_BASE_URL 覆盖。
apiBaseUrl: process.env.API_BASE_URL || 'https://job.youthome.com.cn/api/v1', apiBaseUrl: process.env.API_BASE_URL || 'https://job.youthome.com.cn/api/v1',
// mock 开关:联调期为 false 统一走真实后端;业务函数按接口是否已接通决定是否绕过 mock。 // mock 开关:联调期为 false 统一走真实后端;业务函数按接口是否已接通决定是否绕过 mock。
apiUseMock: false, // 2026-09-29 接真实后端(求职端核心闭环)期间先恢复 true 兜底:
// 已接好真实分支的接口走后端,未接的继续走 mock,保证 App 随时可跑、不回归。
apiUseMock: true,
// EAS 项目 ID:`eas init` 后会自动注入此处(与 updates.url 中的 PROJECT_ID 对应)。 // EAS 项目 ID:`eas init` 后会自动注入此处(与 updates.url 中的 PROJECT_ID 对应)。
eas: { eas: {
projectId: 'REPLACE_WITH_PROJECT_ID', projectId: 'REPLACE_WITH_PROJECT_ID',

3
app/(tabs)/profile.tsx

@ -304,7 +304,8 @@ export default function ProfileScreen() {
</View> </View>
<View style={styles.prefCard}> <View style={styles.prefCard}>
{PREF_ITEMS.map(({ key, label }, index) => { {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 isLast = index === PREF_ITEMS.length - 1;
// 未采集到的项显示「未设置」,不拿空串冒充已填;也就不再显示状态圆点 // 未采集到的项显示「未设置」,不拿空串冒充已填;也就不再显示状态圆点
const isUnset = value.trim() === ''; const isUnset = value.trim() === '';

2
src/__tests__/password.test.ts

@ -232,6 +232,8 @@ describe('resetPassword(重置 / 首次设置密码)', () => {
}); });
describe('changePassword(已登录态改密)', () => { describe('changePassword(已登录态改密)', () => {
beforeAll(() => setMockMode(true));
it('未填原密码时拒绝', async () => { it('未填原密码时拒绝', async () => {
await expect( await expect(
changePassword({ oldPassword: '', newPassword: 'abc12345', confirmPassword: 'abc12345' }), changePassword({ oldPassword: '', newPassword: 'abc12345', confirmPassword: 'abc12345' }),

6
src/__tests__/profile-resume.test.ts

@ -86,12 +86,12 @@ describe('个人资料 / 简历 域 mock 开关', () => {
it('真实模式:fetchUserProfile 先打 /profile/me(后端字段空时兜底 /auth/me)', async () => { it('真实模式:fetchUserProfile 先打 /profile/me(后端字段空时兜底 /auth/me)', async () => {
setMockMode(false); setMockMode(false);
// 后端 /profile/me 返回的字段名(nickname / avatarUrl),不是前端 UserProfile 的 name / avatarKey // 后端 StudentProfileResponse 字段名:realName / location / education 等
responder = () => okData({ nickname: '张三', avatarUrl: 'a1' }); responder = () => okData({ realName: '张三', location: '北京', education: '本科' });
const profile = await fetchUserProfile(); const profile = await fetchUserProfile();
// 第一个请求应该是 /profile/me // 第一个请求应该是 /profile/me
expect(fetchCalls[0].url).toBe(`${API_BASE_URL}/profile/me`); expect(fetchCalls[0].url).toBe(`${API_BASE_URL}/profile/me`);
// profile 非空时不请求 auth/me,直接用后端字段映射 // profile 关键字段非空时不请求 auth/me,直接用后端字段映射
expect(fetchCalls.length).toBe(1); expect(fetchCalls.length).toBe(1);
expect(profile.name).toBe('张三'); expect(profile.name).toBe('张三');
expect(profile.avatar).toBe('张'); expect(profile.avatar).toBe('张');

Loading…
Cancel
Save