Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,14 @@ describe('documentQuerySlice', function () {

const result = reducer(pageTwoCursorState, documentsReceived(docs));

expect(result.startItem).to.equal(11);
expect(result.endItem).to.equal(11);
expect(result.startItem).to.equal(0);
expect(result.endItem).to.equal(0);
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The surrounding test case description (the it(...) label just above this block) no longer matches what is being asserted after the change to 0-0 for empty results. Please update the test name (or the setup) so the description reflects the empty-documents cursor-query scenario being tested.

Copilot uses AI. Check for mistakes.
});

it('shows 0-0 when cursor query returns no documents on page 1', function () {
const result = reducer(cursorState, documentsReceived([]));
expect(result.startItem).to.equal(0);
expect(result.endItem).to.equal(0);
});

Comment thread
tculig marked this conversation as resolved.
it('totalCountReceived(null) keeps totalPages null for cursor queries', function () {
Expand Down
21 changes: 13 additions & 8 deletions src/views/data-browsing-app/store/documentQuerySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ const recalculatePaginationValues = (
// next/previous page and amount per page
state.totalDocuments = null;
state.totalPages = null;
state.startItem = (state.currentPage - 1) * state.itemsPerPage + 1;
state.endItem = Math.max(
Math.min(
state.currentPage * state.itemsPerPage,
state.startItem + state.displayedDocuments.length - 1,
),
state.startItem,
);
if (state.displayedDocuments.length === 0) {
state.startItem = 0;
state.endItem = 0;
} else {
state.startItem = (state.currentPage - 1) * state.itemsPerPage + 1;
state.endItem = Math.max(
Math.min(
state.currentPage * state.itemsPerPage,
state.startItem + state.displayedDocuments.length - 1,
),
state.startItem,
);
}
Comment thread
tculig marked this conversation as resolved.
}
};

Expand Down
Loading