Inspected targets:
/home/mark/sandbox/personal/pr-review-chatbot/src/store/slices/prsSlice.test.ts
/home/mark/sandbox/personal/pr-review-chatbot/src/components/Sidebar.test.tsx
Minimal test changes I’d propose for a new single thunk (example name: fetchFullPRContext) are:
1) Update slice success-path async test to dispatch only the new thunk
File: /home/mark/sandbox/personal/pr-review-chatbot/src/store/slices/prsSlice.test.ts
Update existing test: loads metadata, files, comments, and commits
Use one dispatch:
await store.dispatch(fetchFullPRContext({ owner: 'org', repo: 'repo', prNumber: 42 }));
Exact assertions:
expect(store.getState().prs.selectedPR?.number).toBe(42);
expect(store.getState().prs.files).toHaveLength(1);
expect(store.getState().prs.comments).toHaveLength(1);
expect(store.getState().prs.reviewComments).toHaveLength(1);
expect(store.getState().prs.reviews).toHaveLength(1);
expect(store.getState().prs.commits).toHaveLength(1);
expect(store.getState().prs.error).toBeNull();
2) Update race-condition test to race two full-context thunk calls
File: /home/mark/sandbox/personal/pr-review-chatbot/src/store/slices/prsSlice.test.ts
Update existing test: keeps latest PR resource data when older requests resolve later
Instead of dispatching 6 resource thunks per PR, dispatch two full-context requests (A then B), resolve B first then A.
Exact assertions (same expected behavior):
const state = store.getState().prs;
expect(state.selectedPR?.number).toBe(202);
expect(state.files[0]?.filename).toBe('src/b.ts');
expect(state.comments[0]?.body).toBe('comment-b');
expect(state.reviewComments[0]?.body).toBe('review-comment-b');
expect(state.reviews[0]?.body).toBe('review-b');
expect(state.commits[0]?.sha).toBe('commit-b');
3) Update sidebar “select from list” test to assert single-thunk entrypoint
File: /home/mark/sandbox/personal/pr-review-chatbot/src/components/Sidebar.test.tsx
Update existing test: selects PR from list and loads details in right pane state
Replace “assert low-level metadata call” with “assert unified thunk called once with parsed repo+PR”.
Exact assertions:
await waitFor(() => {
expect(fetchFullPRContextSpy).toHaveBeenCalledTimes(1);
expect(fetchFullPRContextSpy).toHaveBeenCalledWith({
owner: 'org',
repo: 'repo',
prNumber: 12,
});
});
4) Add one sidebar test for direct PR-number load path using the same thunk
File: /home/mark/sandbox/personal/pr-review-chatbot/src/components/Sidebar.test.tsx
New test: e.g. loads single PR by number using full-context thunk
User enters org/repo + 42 and clicks Load PR.
Exact assertions:
expect(screen.getByText('Load PR')).toBeInTheDocument();
await waitFor(() => {
expect(fetchFullPRContextSpy).toHaveBeenCalledTimes(1);
expect(fetchFullPRContextSpy).toHaveBeenCalledWith({
owner: 'org',
repo: 'repo',
prNumber: 42,
});
});
That’s the smallest set that still verifies:
- new thunk is the single loading path,
- state hydration for all PR resources,
- stale response protection still works,
- sidebar integration actually switched to the thunk.