mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
fix(walkthrough): return to the top of the overview on regeneration
This commit is contained in:
1 parent
50e249d5d2
commit
b9345e53b6
2 files changed
+23
No files matched your search
@@ -73,6 +73,7 @@ describe('ChangesWalkthroughSheet', () => {
|
||||
Element.prototype.setPointerCapture ??= () => {}
|
||||
Element.prototype.releasePointerCapture ??= () => {}
|
||||
Element.prototype.scrollIntoView ??= () => {}
|
||||
Element.prototype.scrollTo ??= () => {}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -198,6 +199,27 @@ describe('ChangesWalkthroughSheet', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('scrolls back to the top of the overview when a walkthrough is regenerated', async () => {
|
||||
const user = userEvent.setup()
|
||||
const scrollTo = vi.spyOn(Element.prototype, 'scrollTo')
|
||||
let createdAt = 1
|
||||
mocks.getChangeWalkthrough.mockImplementation(async () => state({ walkthrough: { ...walkthrough, createdAt } }))
|
||||
mocks.generateChangeWalkthrough.mockImplementation(async () => {
|
||||
createdAt = 2
|
||||
return state({ walkthrough: { ...walkthrough, createdAt } })
|
||||
})
|
||||
renderSheet()
|
||||
|
||||
await user.click(await screen.findByRole('button', { name: '1. Add the greeting' }))
|
||||
expect(await screen.findByText('1 of 2')).toBeInTheDocument()
|
||||
|
||||
scrollTo.mockClear()
|
||||
await user.click(screen.getByRole('button', { name: 'Regenerate walkthrough' }))
|
||||
|
||||
await waitFor(() => expect(scrollTo).toHaveBeenCalledWith({ top: 0 }))
|
||||
expect(await screen.findByText('Overview')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows progress while the server is generating instead of the generate button', async () => {
|
||||
mocks.getChangeWalkthrough.mockResolvedValue(state({ walkthrough: null, generating: true }))
|
||||
renderSheet()
|
||||
|
||||
@@ -129,6 +129,7 @@ export function ChangesWalkthroughProvider({ sessionId, active, children }: Chan
|
||||
|
||||
useEffect(() => {
|
||||
setStopIndex(null)
|
||||
scrollRef.current?.scrollTo?.({ top: 0 })
|
||||
}, [active, sessionId, walkthrough?.createdAt])
|
||||
|
||||
const hunksById = new Map(walkthrough?.hunks.map((hunk) => [hunk.id, hunk]) ?? [])
|
||||
|
||||
Reference in new issue
Block a user