Skip to content

Commit

Permalink
🐛(lib-classroom) fix description update from another user
Browse files Browse the repository at this point in the history
The description textarea didn't seem to be updated when a update
occured from another user (websocket).
  • Loading branch information
AntoLC committed Nov 10, 2023
1 parent b8c7c3d commit d35bbaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ describe('<Description />', () => {

deferredPatch.resolve({ message: 'Classroom scheduled.' });

await waitFor(() => expect(fetchMock.calls()).toHaveLength(1));
await waitFor(() => expect(fetchMock.calls()).toHaveLength(1), {
timeout: 2000,
});

expect(fetchMock.calls()[0]![0]).toEqual('/api/classrooms/1/');
expect(fetchMock.calls()[0]![1]).toEqual({
Expand All @@ -92,9 +94,7 @@ describe('<Description />', () => {
'Accept-Language': 'en',
},
method: 'PATCH',
body: JSON.stringify({
welcome_text: 'updated welcome text',
}),
body: expect.stringContaining(`"welcome_text":"updated welcome text"`),
});

// simulate classroom update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ export const Description = () => {
setUpdatedClassroomState(classroom);
},
});
const [updatedClassroomState, setUpdatedClassroomState] = useState<
Partial<Classroom>
>({});
const [updatedClassroomState, setUpdatedClassroomState] =
useState<Partial<Classroom>>(classroom);

const timeoutId = useRef<Maybe<number>>();

Expand All @@ -81,7 +80,7 @@ export const Description = () => {
};

useEffect(() => {
setUpdatedClassroomState({});
setUpdatedClassroomState(classroom);
}, [classroom]);

return (
Expand Down

0 comments on commit d35bbaf

Please sign in to comment.