fix(aihr): clear stale candidate records on fetch failure
This commit is contained in:
@@ -168,6 +168,7 @@ const loadPage = async () => {
|
||||
materials.value = nextMaterials;
|
||||
records.value = nextRecords;
|
||||
} catch (error) {
|
||||
clearData();
|
||||
refreshAuthState();
|
||||
if (!loggedIn.value) {
|
||||
clearData();
|
||||
|
||||
@@ -108,6 +108,7 @@ const loadMaterials = async () => {
|
||||
try {
|
||||
materials.value = await getCandidateMaterials();
|
||||
} catch (error) {
|
||||
clearData();
|
||||
handleRequestError(error, '资料列表加载失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
|
||||
@@ -83,6 +83,11 @@ const reviewStatusDescription = computed(() => latestMaterial.value?.status ===
|
||||
? 'HR 已完成 AI 评分与补充资料复核,后续通知会同步更新。'
|
||||
: 'HR 正在复核 AI 评分与补充资料,预计 1-2 个工作日更新。');
|
||||
|
||||
const clearData = () => {
|
||||
records.value = [];
|
||||
materials.value = [];
|
||||
};
|
||||
|
||||
const loadPage = async () => {
|
||||
loggedIn.value = isLoggedIn();
|
||||
if (!loggedIn.value) {
|
||||
@@ -97,6 +102,7 @@ const loadPage = async () => {
|
||||
]);
|
||||
message.value = '';
|
||||
} catch (error) {
|
||||
clearData();
|
||||
loggedIn.value = isLoggedIn();
|
||||
message.value = loggedIn.value ? (error instanceof Error ? error.message : '面试记录加载失败') : '登录已过期,请重新登录';
|
||||
}
|
||||
|
||||
@@ -85,6 +85,18 @@ test('候选首页只做状态总览和独立页面分流', async () => {
|
||||
assert.doesNotMatch(source, /interviewQuestions/);
|
||||
});
|
||||
|
||||
test('候选端刷新失败不保留上一轮真实记录', async () => {
|
||||
const [home, materials, progress] = await Promise.all([
|
||||
pageSource('../src/pages/candidate/index/index.vue'),
|
||||
pageSource('../src/pages/candidate/materials/index.vue'),
|
||||
pageSource('../src/pages/candidate/progress/index.vue')
|
||||
]);
|
||||
|
||||
assert.match(home, /catch \(error\) \{\n\s*clearData\(\);/);
|
||||
assert.match(materials, /catch \(error\) \{\n\s*clearData\(\);/);
|
||||
assert.match(progress, /catch \(error\) \{\n\s*clearData\(\);/);
|
||||
});
|
||||
|
||||
test('面试、资料、进度和预习页各自只承载一类真实任务', async () => {
|
||||
const [interview, materials, progress, study] = await Promise.all([
|
||||
pageSource('../src/pages/candidate/interview/index.vue'),
|
||||
|
||||
Reference in New Issue
Block a user