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
@@ -3,10 +3,12 @@ import type { Page, TestInfo } from '@playwright/test'
|
||||
import { expect, expectAccessible, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
clientOf,
|
||||
clickDrawing,
|
||||
clientOf,
|
||||
editorActor,
|
||||
geometryField,
|
||||
historyButton,
|
||||
pressAtBox,
|
||||
openEditor,
|
||||
pickAnnotation,
|
||||
saveDraft,
|
||||
@@ -128,12 +130,7 @@ test.describe('editor annotations (A3)', () => {
|
||||
await fillCreation(page, { fr: 'Accès un', en: 'Access one' }, 'detail-a')
|
||||
await createFromPanel(page)
|
||||
await expect(selectionTag(page)).toContainText('Accès un')
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: dict['editor.annotations.undo'],
|
||||
exact: true,
|
||||
}),
|
||||
).toBeEnabled()
|
||||
await expect(historyButton(page, dict, 'undo')).toBeEnabled()
|
||||
|
||||
// A numeric edit of the point, then undo and redo.
|
||||
await pickAnnotation(page, dict, /Point un/)
|
||||
@@ -141,19 +138,12 @@ test.describe('editor annotations (A3)', () => {
|
||||
await cx.fill('420')
|
||||
await cx.press('Enter')
|
||||
await expect(cx).toHaveValue('420')
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: dict['editor.annotations.undo'],
|
||||
exact: true,
|
||||
})
|
||||
.click()
|
||||
await historyButton(page, dict, 'undo').click()
|
||||
await expect(geometryField(page, dict, 'cx')).toHaveValue(placed)
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: dict['editor.annotations.redo'],
|
||||
exact: true,
|
||||
})
|
||||
.click()
|
||||
await historyButton(page, dict, 'redo').click()
|
||||
await expect(geometryField(page, dict, 'cx')).toHaveValue('420')
|
||||
// Nothing left to redo: the button is aria-disabled and a press changes nothing.
|
||||
await pressAtBox(page, historyButton(page, dict, 'redo'))
|
||||
await expect(geometryField(page, dict, 'cx')).toHaveValue('420')
|
||||
|
||||
await saveDraft(page, dict, seed.revision + 1)
|
||||
|
||||
@@ -5,24 +5,29 @@ import { stepUpAdmin } from '../support/admin'
|
||||
import { expect, expectAccessible, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
pickAnnotation,
|
||||
selectionTag,
|
||||
clickDrawing,
|
||||
createFromPanel,
|
||||
creationPanel,
|
||||
editorActor,
|
||||
fillCreation,
|
||||
geometryField,
|
||||
historyButton,
|
||||
INKSCAPE_EXPORT,
|
||||
openDraft,
|
||||
openSection,
|
||||
pickAnnotation,
|
||||
place,
|
||||
revisionText,
|
||||
savedLine,
|
||||
saveDraft,
|
||||
saveLine,
|
||||
secondSession,
|
||||
selectionTag,
|
||||
selectTab,
|
||||
serverDocument,
|
||||
showDrawing,
|
||||
toolButton,
|
||||
UNSAVED_LINE,
|
||||
} from '../support/editor'
|
||||
import { signIn } from '../support/shell'
|
||||
|
||||
@@ -236,9 +241,7 @@ async function reloadAndRestore(page: Page, sheetId: string) {
|
||||
).toBeVisible()
|
||||
expect(page.url()).toContain(sheetId)
|
||||
await clickButton(page, dict['editor.draft.recovery.restore'])
|
||||
await expect(
|
||||
page.getByText(dict['editor.draft.status.unsaved'], { exact: false }),
|
||||
).toBeVisible()
|
||||
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
||||
}
|
||||
|
||||
test.describe('editor journey (owner trial steps)', () => {
|
||||
@@ -272,18 +275,8 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
await createAnnotations(page)
|
||||
await repairGeometry(page)
|
||||
// Undo and redo the numeric repair path's last creation.
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: dict['editor.annotations.undo'],
|
||||
exact: true,
|
||||
})
|
||||
.click()
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: dict['editor.annotations.redo'],
|
||||
exact: true,
|
||||
})
|
||||
.click()
|
||||
await historyButton(page, dict, 'undo').click()
|
||||
await historyButton(page, dict, 'redo').click()
|
||||
const modified = await modifyAnnotations(page)
|
||||
await expectAccessible(page, 'the editor with annotations')
|
||||
await saveDraft(page, dict, 1)
|
||||
@@ -342,14 +335,7 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
await expect(conflict).toContainText('révision 3')
|
||||
await clickDialog(conflict, dict['editor.draft.conflict.reload'])
|
||||
await expect(conflict).toBeHidden()
|
||||
await expect(
|
||||
page.getByText(
|
||||
dict['editor.draft.status.revision'].replace('{revision}', '3'),
|
||||
{
|
||||
exact: true,
|
||||
},
|
||||
),
|
||||
).toBeVisible()
|
||||
await expect(saveLine(page)).toHaveText(revisionText(dict, 3))
|
||||
|
||||
// The conflict again, resolved by keeping this version after the confirmation.
|
||||
await commitText(
|
||||
@@ -369,14 +355,7 @@ test.describe('editor journey (owner trial steps)', () => {
|
||||
await expect(again).toContainText('Remplacer la révision 4')
|
||||
await clickDialog(again, dict['editor.draft.conflict.keep'])
|
||||
await expect(again).toBeHidden()
|
||||
await expect(
|
||||
page.getByText(
|
||||
dict['editor.draft.status.revision'].replace('{revision}', '5'),
|
||||
{
|
||||
exact: true,
|
||||
},
|
||||
),
|
||||
).toBeVisible()
|
||||
await expect(saveLine(page)).toHaveText(savedLine(dict, 5))
|
||||
await second.context.close()
|
||||
|
||||
await selectTab(page, dict, 'verification')
|
||||
|
||||
@@ -4,7 +4,7 @@ import { rpc } from '../../../../packages/supabase/tests/sandbox/stack'
|
||||
import { expect, expectAccessible, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
place,
|
||||
type Actor,
|
||||
copyKeyOf,
|
||||
editorActor,
|
||||
expiringEditor,
|
||||
@@ -12,15 +12,18 @@ import {
|
||||
openDraft,
|
||||
openEditor,
|
||||
ownerActor,
|
||||
place,
|
||||
reloadAccepting,
|
||||
savedLine,
|
||||
saveDraft,
|
||||
saveLine,
|
||||
seedDraft,
|
||||
selectTab,
|
||||
serverDocument,
|
||||
serverRevision,
|
||||
standardShape,
|
||||
storedCopy,
|
||||
type Actor,
|
||||
UNSAVED_LINE,
|
||||
} from '../support/editor'
|
||||
import { stepUpAdmin } from '../support/admin'
|
||||
import { secondSession } from '../support/editor'
|
||||
@@ -143,9 +146,7 @@ test.describe('editor recovery and concurrency', () => {
|
||||
const seed = await seedDraft(actor, { shape: standardShape })
|
||||
await openGeneral(page, actor, seed.sheetId)
|
||||
await commitText(nameFr(page), 'Mon travail local')
|
||||
await expect(
|
||||
page.getByText(dict['editor.draft.status.unsaved'], { exact: false }),
|
||||
).toBeVisible()
|
||||
await expect(saveLine(page)).toHaveText(UNSAVED_LINE)
|
||||
await advanceServer(actor, seed.draftId, 1)
|
||||
|
||||
expect(await reloadAccepting(page)).toContain('beforeunload')
|
||||
@@ -168,14 +169,7 @@ test.describe('editor recovery and concurrency', () => {
|
||||
await expect(conflict).toContainText('Remplacer la révision 2')
|
||||
await button(conflict, dict['editor.draft.conflict.keep']).click()
|
||||
await expect(conflict).toBeHidden()
|
||||
await expect(
|
||||
page.getByText(
|
||||
dict['editor.draft.status.revision'].replace('{revision}', '3'),
|
||||
{
|
||||
exact: true,
|
||||
},
|
||||
),
|
||||
).toBeVisible()
|
||||
await expect(saveLine(page)).toHaveText(savedLine(dict, 3))
|
||||
const saved = await serverDocument<{ name: { fr: string } }>(seed.draftId)
|
||||
expect(saved.name.fr).toBe('Mon travail local')
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { fr } from '@/i18n/fr'
|
||||
import type { Page, TestInfo } from '@playwright/test'
|
||||
import type { Locator, Page, TestInfo } from '@playwright/test'
|
||||
import { expect, test } from '../support/browser'
|
||||
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
|
||||
import {
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
selectTab,
|
||||
shapeWith,
|
||||
showDrawing,
|
||||
historyButton,
|
||||
} from '../support/editor'
|
||||
|
||||
// V1-2.6 U1 B2a: tabs, Annotations sections and the references panel stay mounted. What
|
||||
@@ -39,6 +40,17 @@ async function open(page: Page) {
|
||||
return { ...seed, actor }
|
||||
}
|
||||
|
||||
/** The button's centre hits the button itself: no panel or scrim covers it (any state). */
|
||||
const hitsItself = (button: Locator) =>
|
||||
button.evaluate((element) => {
|
||||
const box = element.getBoundingClientRect()
|
||||
const hit = document.elementFromPoint(
|
||||
box.x + box.width / 2,
|
||||
box.y + box.height / 2,
|
||||
)
|
||||
return hit !== null && element.contains(hit)
|
||||
})
|
||||
|
||||
const active = (page: Page) => page.locator(':focus')
|
||||
const layerTransform = (page: Page) =>
|
||||
page
|
||||
@@ -133,6 +145,12 @@ test.describe('editor shell, kept places (B2a)', () => {
|
||||
for (const scrolled of [false, true]) {
|
||||
await page.evaluate((y) => window.scrollTo(0, y), scrolled ? 400 : 0)
|
||||
for (const target of targets) await target.click({ trial: true })
|
||||
// « Annuler » / « Rétablir » may be aria-disabled (a trial click would wait).
|
||||
for (const kind of ['undo', 'redo'] as const) {
|
||||
const button = historyButton(page, dict, kind)
|
||||
await button.scrollIntoViewIfNeeded()
|
||||
expect(await hitsItself(button)).toBe(true)
|
||||
}
|
||||
const box = await panel.boundingBox()
|
||||
for (const above of [header, tabs]) {
|
||||
const other = await above.boundingBox()
|
||||
|
||||
@@ -8,11 +8,13 @@ import {
|
||||
editorActor,
|
||||
openEditor,
|
||||
openReferences,
|
||||
place,
|
||||
openSection,
|
||||
pickAnnotation,
|
||||
place,
|
||||
pointOf,
|
||||
revisionText,
|
||||
saveDraft,
|
||||
saveLine,
|
||||
seedDraft,
|
||||
selectTab,
|
||||
serverDocument,
|
||||
@@ -202,6 +204,9 @@ test.describe('editor structures (A4)', () => {
|
||||
await expect(
|
||||
node.getByText(dict['editor.findings.status.reviewed']),
|
||||
).toBeVisible()
|
||||
// The tab row (history buttons included) scrolled under the sticky top bar is not a
|
||||
// target-size finding of its own: audit it from the top.
|
||||
await page.evaluate(() => window.scrollTo(0, 0))
|
||||
await expectAccessible(page, 'the findings tree')
|
||||
|
||||
// Reorder: the new zone moves above the seeded one.
|
||||
@@ -244,9 +249,9 @@ test.describe('editor structures (A4)', () => {
|
||||
await page.reload()
|
||||
await selectTab(page, dict, 'findings')
|
||||
await expect(items.filter({ hasText: 'Catégorie renommée' })).toBeVisible()
|
||||
await expect(
|
||||
page.getByText(dict['editor.draft.status.unsaved'], { exact: false }),
|
||||
).toHaveCount(0)
|
||||
await expect(saveLine(page)).toHaveText(
|
||||
revisionText(dict, seed.revision + 1),
|
||||
)
|
||||
await expect(
|
||||
button(page, dict['editor.draft.recovery.restore']),
|
||||
).toHaveCount(0)
|
||||
|
||||
Reference in new issue
Block a user