fix: accept rectifying low-confidence terminal results
This commit is contained in:
@@ -23,10 +23,15 @@ export function candidateWorkingTime(
|
||||
const terminal = actionKind === "present_low_result"
|
||||
|| actionKind === "present_medium_result"
|
||||
|| actionKind === "candidate_saved";
|
||||
const terminalStatusMatches = actionKind === "present_low_result"
|
||||
? assessment?.status === "rectifying"
|
||||
: (actionKind === "present_medium_result" || actionKind === "candidate_saved")
|
||||
&& assessment?.status === "candidate";
|
||||
|
||||
return assessment?.id === request.caseId
|
||||
&& assessment.user_id
|
||||
&& assessment.status === "candidate"
|
||||
&& typeof assessment?.user_id === "string"
|
||||
&& assessment.user_id.length > 0
|
||||
&& terminalStatusMatches
|
||||
&& assessment.candidate_result_id === request.resultId
|
||||
&& action?.resultId === request.resultId
|
||||
&& terminal
|
||||
|
||||
@@ -19,6 +19,22 @@ const terminalCase = {
|
||||
},
|
||||
};
|
||||
|
||||
const lowTerminalCase = {
|
||||
...terminalCase,
|
||||
status: "rectifying",
|
||||
candidate_result: {
|
||||
...terminalCase.candidate_result,
|
||||
confidence: "low",
|
||||
},
|
||||
turn_state: {
|
||||
...terminalCase.turn_state,
|
||||
nextAction: {
|
||||
kind: "present_low_result",
|
||||
resultId: terminalCase.candidate_result_id,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test("candidate completion only accepts the persisted terminal representative time", () => {
|
||||
assert.equal(candidateWorkingTime(terminalCase, {
|
||||
caseId: terminalCase.id,
|
||||
@@ -33,6 +49,31 @@ test("candidate completion only accepts the persisted terminal representative ti
|
||||
}), null);
|
||||
});
|
||||
|
||||
test("accepts a matching low-confidence result from the rectifying state", () => {
|
||||
assert.equal(candidateWorkingTime(lowTerminalCase, {
|
||||
caseId: terminalCase.id,
|
||||
resultId: terminalCase.candidate_result_id,
|
||||
time: "04:53",
|
||||
}), "04:53");
|
||||
});
|
||||
|
||||
test("does not accept a medium terminal action from the rectifying state", () => {
|
||||
assert.equal(candidateWorkingTime({
|
||||
...lowTerminalCase,
|
||||
turn_state: {
|
||||
...lowTerminalCase.turn_state,
|
||||
nextAction: {
|
||||
kind: "present_medium_result",
|
||||
resultId: terminalCase.candidate_result_id,
|
||||
},
|
||||
},
|
||||
}, {
|
||||
caseId: terminalCase.id,
|
||||
resultId: terminalCase.candidate_result_id,
|
||||
time: "04:53",
|
||||
}), null);
|
||||
});
|
||||
|
||||
test("non-terminal cases cannot be adopted for consultation", () => {
|
||||
assert.equal(candidateWorkingTime({
|
||||
...terminalCase,
|
||||
|
||||
Reference in New Issue
Block a user