Skip to content

Commit

Permalink
fix(rga): state reset keep configid (#4286)
Browse files Browse the repository at this point in the history
Fixing a regression when resetting the answer in the new answerAPI flow.

## Problem

When we need to reset a RGA answer
e.g. right after a new query has been submitted
The `answerConfigurationId` must be kept in the state whenever the
answer API flow is used.

## The Fix
We pass the actual state answerConfigurationID to the new state created
by the reset action.

Co-authored-by: Danny Gauthier <[email protected]>
  • Loading branch information
dmgauthier and Danny Gauthier authored Aug 19, 2024
1 parent c4fa7b6 commit a822cea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ describe('generated answer slice', () => {
expect(finalState.responseFormat).toEqual(responseFormat);
});
});
it('should not reset the configuration id', () => {
const state = {
...baseState,
answerConfigurationId: 'some-id',
};

const finalState = generatedAnswerReducer(state, resetAnswer());
expect(finalState.answerConfigurationId).toBe('some-id');
});

test.each(generatedContentFormat)(
'#setAnswerContentFormat should set the "%i" content format in the state',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export const generatedAnswerReducer = createReducer(
.addCase(resetAnswer, (state) => {
return {
...getGeneratedAnswerInitialState(),
...(state.answerConfigurationId
? {answerConfigurationId: state.answerConfigurationId}
: {}),
responseFormat: state.responseFormat,
fieldsToIncludeInCitations: state.fieldsToIncludeInCitations,
isVisible: state.isVisible,
Expand Down

0 comments on commit a822cea

Please sign in to comment.