feat(editor): header history, save line and Abandonner les modifications
Header Annuler/Retablir on every tab (aria-disabled, commit on pointerdown, refused blur commit skips the undo). Save line: unsaved count selector (savedDistance), saveLineState forms, server save time via readSaveTime (lastSave in the store, never the browser clock). Discard relabelled and names the stored copy. Tool column pair removed, glyphs in EditorGlyph. Rewritten or removed assertions (R-24): - editor-route.test: Revision 3 / unsaved text / Annuler les modifications -> save-line testid, Abandonner label, copy sentence in the dialog - editor-route-conflict, editor-route-recovery: Revision n and copy_cap/ copy_quota text queries -> save-line testid - editor-no-loss: discard button label - editor-annotations-tab: tool column undo/redo test -> no pair left (behaviour moved to editor-history-buttons.test) - e2e journey/annotations/recovery/structures/support saveDraft/lan: undo/redo and revision/unsaved text -> historyButton, saveLine helpers; structures toHaveCount(0) on old text -> exact Revision n line - editor-shell clickability: header Annuler/Retablir added
This commit is contained in:
1 parent
ab51ea764d
commit
99b669bf8f
29 files changed
+1397
-248
No files matched your search
@@ -51,8 +51,7 @@ describe('edit mode', () => {
|
||||
await ready()
|
||||
expect(screen.getByText('Brouillon')).toBeInTheDocument()
|
||||
expect(screen.getByText('Copie de travail')).toBeInTheDocument()
|
||||
expect(screen.getByRole('status', { name: '' })).toBeDefined()
|
||||
expect(screen.getByText('Révision 3')).toBeInTheDocument()
|
||||
expect(screen.getByTestId('save-line')).toHaveTextContent(/^Révision 3$/)
|
||||
const tabs = within(screen.getByRole('tablist')).getAllByRole('tab')
|
||||
expect(tabs.map((tab) => tab.textContent)).toEqual(TABS)
|
||||
expect(screen.getByRole('tab', { name: 'Annotations' })).toHaveAttribute(
|
||||
@@ -81,11 +80,13 @@ describe('edit mode', () => {
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
expect(
|
||||
await screen.findByText('Révision 3 · modifications non enregistrées'),
|
||||
).toBeInTheDocument()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('save-line')).toHaveTextContent(/^1 modification non enregistrée$/),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Enregistrer' }))
|
||||
expect(await screen.findByText('Révision 4')).toBeInTheDocument()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('save-line')).toHaveTextContent(/^Enregistré · révision 4$/),
|
||||
)
|
||||
expect(sb.saveSheetDraft).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.objectContaining({ version_id: VERSION, expected_revision: 3 }),
|
||||
@@ -93,21 +94,25 @@ describe('edit mode', () => {
|
||||
expect(storedCopy()).toBeNull()
|
||||
})
|
||||
|
||||
it('« Annuler les modifications » asks first, then reloads the server draft', async () => {
|
||||
it('« Abandonner les modifications » asks first, then reloads the server draft', async () => {
|
||||
const user = userEvent.setup()
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
await user.click(
|
||||
await screen.findByRole('button', { name: 'Annuler les modifications' }),
|
||||
await screen.findByRole('button', { name: 'Abandonner les modifications' }),
|
||||
)
|
||||
const dialog = within(await screen.findByRole('dialog'))
|
||||
expect(dialog.getByText(fr['editor.draft.discard_ask'])).toBeInTheDocument()
|
||||
const asked = await screen.findByRole('dialog')
|
||||
expect(asked).toHaveTextContent(fr['editor.draft.discard_ask'])
|
||||
expect(asked).toHaveTextContent(fr['editor.draft.discard_copy'])
|
||||
const dialog = within(asked)
|
||||
await user.click(
|
||||
dialog.getByRole('button', { name: 'Abandonner les modifications' }),
|
||||
)
|
||||
await waitFor(() => expect(store.getState().unsaved).toBe(false))
|
||||
expect(await screen.findByText('Révision 3')).toBeInTheDocument()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('save-line')).toHaveTextContent(/^Révision 3$/),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -418,9 +423,9 @@ describe('permission lost during the session', () => {
|
||||
mountDraft()
|
||||
await ready()
|
||||
act(() => void commitMove(40))
|
||||
expect(
|
||||
await screen.findByText(fr['editor.draft.status.copy_quota']),
|
||||
).toBeInTheDocument()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('save-line')).toHaveTextContent(fr['editor.draft.status.copy_quota']),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: 'Enregistrer' }))
|
||||
const notice = await screen.findByText(/Votre session a expiré/)
|
||||
expect(notice).toHaveTextContent(fr['editor.draft.copy_not_kept'])
|
||||
|
||||
Reference in new issue
Block a user