Skip to content

Commit

Permalink
fix: [AXIMST-728] check complete unit on prev and next click (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-romaniuk authored and monteri committed Apr 1, 2024
1 parent c5a24d7 commit d315c9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/courseware/course/sequence/Sequence.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ const Sequence = ({

const handleNext = () => {
const nextIndex = sequence.unitIds.indexOf(unitId) + 1;
if (nextIndex < sequence.unitIds.length) {
const newUnitId = sequence.unitIds[nextIndex];
handleNavigate(newUnitId);
} else {
const newUnitId = sequence.unitIds[nextIndex];
handleNavigate(newUnitId);

if (nextIndex >= sequence.unitIds.length) {
nextSequenceHandler();
}
};

const handlePrevious = () => {
const previousIndex = sequence.unitIds.indexOf(unitId) - 1;
if (previousIndex >= 0) {
const newUnitId = sequence.unitIds[previousIndex];
handleNavigate(newUnitId);
} else {
const newUnitId = sequence.unitIds[previousIndex];
handleNavigate(newUnitId);

if (previousIndex < 0) {
previousSequenceHandler();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/courseware/course/sequence/Sequence.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ describe('Sequence', () => {

screen.getAllByRole('link', { name: /previous/i }).forEach(button => fireEvent.click(button));
expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(2);
expect(testData.unitNavigationHandler).not.toHaveBeenCalled();
expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(2);

screen.getAllByRole('link', { name: /next/i }).forEach(button => fireEvent.click(button));
expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(2);
expect(testData.unitNavigationHandler).not.toHaveBeenCalled();
expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(4);

expect(sendTrackEvent).toHaveBeenNthCalledWith(1, 'edx.ui.lms.sequence.previous_selected', {
current_tab: 1,
Expand Down

0 comments on commit d315c9c

Please sign in to comment.