Repository navigation
Fix configuration, browsing and report decision regressions #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7b86818
Merge commit '19af55eb9d4a44713df2702d6246701029cd3202' into fix/rele…
Producdevity 508a4e1
Merge commit '2e5223c8d9721fe68b909e94482fc186d204510e' into fix/rele…
Producdevity a2407cb
fix: preserve custom field ordering and stored configuration errors
Producdevity 2697063
fix: retain bookmark and profile browsing state
Producdevity 41329c6
fix: align report decision effects and notification links
Producdevity 4d7af0b
fix: bound TGDB duplicate lookup batches
Producdevity 9c92ca7
refactor: centralize committed moderation trust effects
Producdevity 03beaa7
fix: name form controls and preserve preference feedback
Producdevity b7d8235
fix: address profile and bookmark review findings
Producdevity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { render, screen } from '@testing-library/react' | ||
| import { type ComponentProps } from 'react' | ||
| import { beforeEach, expect, it, vi } from 'vitest' | ||
| import { type api } from '@/lib/api' | ||
| import { type RouterOutput } from '@/types/trpc' | ||
| import DevicesPage from './DevicesPage' | ||
| import type DeviceViewModal from './components/DeviceViewModal' | ||
| import type * as UI from '@/components/ui' | ||
|
|
||
| type Device = RouterOutput['devices']['get']['devices'][number] | ||
| const selected: Device = { | ||
| id: 'device-1', | ||
| modelName: 'Selected device', | ||
| brandId: 'brand-1', | ||
| socId: null, | ||
| brand: { id: 'brand-1', name: 'Brand', createdAt: new Date('2026-11-01') }, | ||
| soc: null, | ||
| _count: { listings: 1 }, | ||
| } | ||
| let devices: Device[] = [] | ||
| let params = new URLSearchParams() | ||
| let byId: { data: RouterOutput['devices']['byId'] | undefined; isError: boolean } | ||
| const byIdQuery = vi.hoisted(() => | ||
| vi.fn<(...args: Parameters<typeof api.devices.byId.useQuery>) => typeof byId>(), | ||
| ) | ||
|
|
||
| vi.mock('next/navigation', () => ({ | ||
| useRouter: () => ({ replace: vi.fn() }), | ||
| useSearchParams: () => params, | ||
| })) | ||
| vi.mock('@/hooks', () => ({ useColumnVisibility: () => ({ isColumnVisible: () => false }) })) | ||
| vi.mock('@/lib/api', () => ({ | ||
| api: { | ||
| devices: { | ||
| get: { useQuery: () => ({ data: { devices }, isPending: false }) }, | ||
| byId: { useQuery: byIdQuery }, | ||
| }, | ||
| }, | ||
| })) | ||
| vi.mock('@/components/ui', async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof UI>()), | ||
| ColumnVisibilityControl: () => null, | ||
| })) | ||
| vi.mock('./components/DeviceViewModal', () => ({ | ||
| default: (props: ComponentProps<typeof DeviceViewModal>) => | ||
| props.isOpen && props.deviceData ? <div role="dialog">{props.deviceData.modelName}</div> : null, | ||
| })) | ||
|
|
||
| beforeEach(() => { | ||
| devices = [selected] | ||
| params = new URLSearchParams('deviceId=device-1') | ||
| byId = { data: undefined, isError: false } | ||
| byIdQuery.mockReset().mockImplementation(() => byId) | ||
| }) | ||
|
|
||
| it('keeps the latest resolved device open while it leaves the current results', () => { | ||
| const view = render(<DevicesPage />) | ||
| expect(screen.getByRole('dialog')).toHaveTextContent('Selected device') | ||
| expect(byIdQuery).toHaveBeenLastCalledWith({ id: 'device-1' }, { enabled: false }) | ||
|
|
||
| devices = [] | ||
| view.rerender(<DevicesPage />) | ||
| expect(byIdQuery).toHaveBeenLastCalledWith({ id: 'device-1' }, { enabled: true }) | ||
| expect(screen.getByRole('dialog')).toHaveTextContent('Selected device') | ||
|
|
||
| byId.data = { ...selected, modelName: 'Fetched device' } | ||
| view.rerender(<DevicesPage />) | ||
| expect(screen.getByRole('dialog')).toHaveTextContent('Fetched device') | ||
|
|
||
| byId.data = undefined | ||
| view.rerender(<DevicesPage />) | ||
| expect(screen.getByRole('dialog')).toHaveTextContent('Fetched device') | ||
| }) | ||
|
|
||
| it('does not show an old device after changing or removing its URL id, or a failed lookup', () => { | ||
| const view = render(<DevicesPage />) | ||
| params = new URLSearchParams('deviceId=another-device') | ||
| view.rerender(<DevicesPage />) | ||
| expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
|
|
||
| params = new URLSearchParams('deviceId=device-1') | ||
| devices = [] | ||
| byId.isError = true | ||
| view.rerender(<DevicesPage />) | ||
| expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
|
|
||
| params = new URLSearchParams() | ||
| view.rerender(<DevicesPage />) | ||
| expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.