From 91b8adca62705c3761f8be11810d3067bd0f8c5f Mon Sep 17 00:00:00 2001 From: Aaron shiel <57824522+aaronshiel@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:17:09 -0800 Subject: [PATCH] only add new answers to state (#316) * only add new answers to state * fix 1 test * fix --------- Co-authored-by: Aaron Shiel --- client/src/hooks/graphql/use-with-record-state.tsx | 10 +++++++--- cypress/cypress/e2e/home.cy.ts | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/src/hooks/graphql/use-with-record-state.tsx b/client/src/hooks/graphql/use-with-record-state.tsx index af34eed1..85067f9b 100644 --- a/client/src/hooks/graphql/use-with-record-state.tsx +++ b/client/src/hooks/graphql/use-with-record-state.tsx @@ -139,13 +139,16 @@ export function useWithRecordState( } } + // Insert answers that are not already in state const answerStates: AnswerState[] = []; for (const a of _answers) { const q = getValueIfKeyExists(a.question, mentorQuestions); // we don't want to remove questions that are already in the recording state - const answerAlreadyInState = Boolean( - answers.find((as) => as.answer.question === a.question) + const answerInState = answers.find( + (as) => as.answer.question === a.question ); + + const answerAlreadyInState = Boolean(answerInState); let checkStatus = !status || answerAlreadyInState; if (status === Status.COMPLETE) { checkStatus = @@ -167,10 +170,11 @@ export function useWithRecordState( answer: a, editedAnswer: a, editedQuestion: q.question, - recordedVideo: undefined, + recordedVideo: answerInState?.recordedVideo || undefined, minVideoLength: q.question.minVideoLength, attentionNeeded: doesAnswerNeedAttention(a), localTranscriptChanges: false, + ...(answerInState || {}), }); } } diff --git a/cypress/cypress/e2e/home.cy.ts b/cypress/cypress/e2e/home.cy.ts index 861325b4..4388d31b 100644 --- a/cypress/cypress/e2e/home.cy.ts +++ b/cypress/cypress/e2e/home.cy.ts @@ -1184,7 +1184,13 @@ describe("My Mentor Page", () => { it("users with locked subjects cannot see 'select subject' in hamburger menu", () => { cySetup(cy); cyMockDefault(cy, { - mentor: clintWithConfig, + mentor: { + ...clintWithConfig, + mentorConfig: { + ...clintWithConfig.mentorConfig, + lockedToSubjects: true, + }, + }, }); cy.visit("/"); cy.get("[data-cy=setup-no]").trigger("mouseover").click();