feat(app): Aller à selects the element in its tab, reload after submit
This commit is contained in:
1 parent
2a54fa4c78
commit
4f223e04cd
24 files changed
+473
-66
No files matched your search
@@ -29,7 +29,8 @@ vi.mock('@faunosteo/supabase', async (orig) => ({
|
||||
|
||||
const onSelectTab = vi.fn()
|
||||
const reloadSheet = vi.fn()
|
||||
const props = { readOnly: false, onSelectTab, reloadSheet }
|
||||
const onGoTo = vi.fn()
|
||||
const props = { readOnly: false, onSelectTab, onGoTo, reloadSheet }
|
||||
const SUBMIT = 'Soumettre à la revue'
|
||||
|
||||
/** An annotation without geometry: a blocking error of the core. */
|
||||
@@ -48,6 +49,7 @@ afterEach(() => {
|
||||
cleanup()
|
||||
resetStore()
|
||||
onSelectTab.mockReset()
|
||||
onGoTo.mockReset()
|
||||
reloadSheet.mockReset()
|
||||
})
|
||||
|
||||
@@ -77,9 +79,12 @@ describe('Vérification panel', () => {
|
||||
expect(screen.getAllByText('Sans tracé')).toHaveLength(2)
|
||||
expect(screen.getByText(/n'a pas de géométrie/)).toBeTruthy()
|
||||
await user.click(
|
||||
screen.getAllByRole('button', { name: 'Aller à Annotations' })[0],
|
||||
screen.getAllByRole('button', { name: 'Aller à Sans tracé' })[0],
|
||||
)
|
||||
expect(onSelectTab).toHaveBeenCalledWith('annotations')
|
||||
expect(onGoTo).toHaveBeenCalledWith('annotations', {
|
||||
kind: 'annotation',
|
||||
id: 'anno-bare',
|
||||
})
|
||||
expect(screen.queryByText('Aucun problème détecté')).toBeNull()
|
||||
})
|
||||
|
||||
@@ -101,9 +106,9 @@ describe('Vérification panel', () => {
|
||||
render(<VerificationTab {...props} />)
|
||||
expect(screen.getByText('1 blocking errors')).toBeTruthy()
|
||||
expect(screen.getByText(/This annotation has no geometry/)).toBeTruthy()
|
||||
expect(
|
||||
screen.getAllByRole('button', { name: 'Go to Annotations' }),
|
||||
).toHaveLength(3)
|
||||
expect(screen.getAllByRole('button', { name: 'Go to Bare' })).toHaveLength(
|
||||
2,
|
||||
)
|
||||
})
|
||||
|
||||
it('hides the submission when read-only', async () => {
|
||||
@@ -214,3 +219,21 @@ describe('Issue messages', () => {
|
||||
expect(getDict('fr')[key]).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Submission after the tab is gone', () => {
|
||||
it('still reloads the sheet when the tab unmounted during the await', async () => {
|
||||
await openReady()
|
||||
let resolve: (id: never) => void = () => undefined
|
||||
sb.submitSheetReview.mockReturnValue(new Promise((r) => (resolve = r)))
|
||||
const user = userEvent.setup()
|
||||
const view = render(<VerificationTab {...props} />)
|
||||
await user.type(
|
||||
screen.getByLabelText('Note de soumission (obligatoire)'),
|
||||
'Prête',
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: SUBMIT }))
|
||||
view.unmount()
|
||||
await act(async () => resolve('review-1' as never))
|
||||
await waitFor(() => expect(reloadSheet).toHaveBeenCalled())
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user