Skip to content
Merged
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
Prev Previous commit
Next Next commit
update page size test case
  • Loading branch information
Assem-Uber committed Nov 21, 2025
commit d9da99f53712f1ef6b255c903c69043d4819232d
Original file line number Diff line number Diff line change
Expand Up @@ -283,24 +283,22 @@ describe(WorkflowHistoryFetcher.name, () => {
});

const pageSizes = getCapturedPageSizes();
expect(pageSizes).toHaveLength(1);
expect(pageSizes[0]).toBe('200');
Comment on lines +285 to +286
Copy link
Member

Choose a reason for hiding this comment

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

This seems to assert behavior of setup and mockEndpoints rather than the "unit under test".

Is this intended?

Copy link
Contributor Author

@Assem-Uber Assem-Uber Nov 21, 2025

Choose a reason for hiding this comment

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

Which part exactly is testing the setup method?

What the test does here is capturing what request msw received and make sure that the first request had a query param of 200. The query for rest APIs are sent from the fetcher but received and captured by the setup method.

Copy link
Member

@macrotim macrotim Nov 21, 2025

Choose a reason for hiding this comment

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

It sounds like your intent is to introspect the inner workings of the fetcher?

To suggest an alternative approach:

  • Let's generalize it beyond pageSize.
  • Unit tests need to assert correct internal behavior.
  • And asserting the outcome falls short.
  • One solution: The fetcher returns an introspection object.
  • Example: Return debugInfo which provides detailed insights.

I suggest this because the purpose of CapturedPageSizes wasn't immediately clear.

});

it('should use WORKFLOW_HISTORY_PAGE_SIZE_CONFIG for subsequent pages', async () => {
const { fetcher, getCapturedPageSizes } = setup(queryClient);

fetcher.start((state) => (state.data?.pages.length || 0) < 2);
fetcher.start((state) => (state.data?.pages.length || 0) < 3);

await waitFor(() => {
const state = fetcher.getCurrentState();
expect(state.data?.pages).toHaveLength(2);
expect(state.data?.pages).toHaveLength(3);
});

const pageSizes = getCapturedPageSizes();
expect(pageSizes.length).toBeGreaterThanOrEqual(2);
expect(pageSizes[0]).toBe('200');
expect(pageSizes[1]).toBe('1000');
expect(pageSizes[2]).toBe('1000');
});
});

Expand Down