fix(editor): bubble clears the strip's commands, announces through a steady region
This commit is contained in:
1 parent
49f0144729
commit
a9252375e1
7 files changed
+313
-56
No files matched your search
@@ -54,27 +54,49 @@ const tool = (page: Page, id: string) =>
|
||||
const scrollWidth = (page: Page) =>
|
||||
page.evaluate(() => document.documentElement.scrollWidth)
|
||||
|
||||
/** The bubble sits in the window, under the top bar, under its button and clear of the other. */
|
||||
const intersects = (a: Box, b: Box) =>
|
||||
a.x < b.x + b.width &&
|
||||
b.x < a.x + a.width &&
|
||||
a.y < b.y + b.height &&
|
||||
b.y < a.y + a.height
|
||||
|
||||
interface Box {
|
||||
x: number
|
||||
y: number
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
/**
|
||||
* The bubble sits in the window, under the top bar, right under its button (within 8 px
|
||||
* unless the bar pushes it down), and over neither « Défaire » nor the strip's commands.
|
||||
*/
|
||||
async function expectBubbleBeside(
|
||||
page: Page,
|
||||
bubble: Locator,
|
||||
button: Locator,
|
||||
other: Locator,
|
||||
) {
|
||||
const box = await bubble.boundingBox()
|
||||
const own = await button.boundingBox()
|
||||
const next = await other.boundingBox()
|
||||
const bar = await page.locator('header').first().boundingBox()
|
||||
const boxes = await Promise.all([
|
||||
bubble.boundingBox(),
|
||||
button.boundingBox(),
|
||||
other.boundingBox(),
|
||||
page.locator('header').first().boundingBox(),
|
||||
page.locator('[data-testid="edit-strip"] > :last-child').boundingBox(),
|
||||
])
|
||||
const view = page.viewportSize()
|
||||
if (!box || !own || !next || !bar || !view)
|
||||
const [box, own, next, bar, commands] = boxes
|
||||
if (!box || !own || !next || !bar || !commands || !view)
|
||||
throw new Error('a box is missing')
|
||||
expect(box.x).toBeGreaterThanOrEqual(0)
|
||||
expect(box.x + box.width).toBeLessThanOrEqual(view.width)
|
||||
expect(box.y + box.height).toBeLessThanOrEqual(view.height)
|
||||
expect(box.y).toBeGreaterThanOrEqual(bar.y + bar.height)
|
||||
expect(box.y).toBeGreaterThanOrEqual(own.y + own.height)
|
||||
const apart = box.y >= next.y + next.height || box.x >= next.x + next.width
|
||||
expect(apart).toBe(true)
|
||||
expect(box.y - (own.y + own.height)).toBeLessThanOrEqual(8)
|
||||
expect(box.width).toBeLessThanOrEqual(288)
|
||||
expect(intersects(box, next)).toBe(false)
|
||||
expect(intersects(box, commands)).toBe(false)
|
||||
}
|
||||
|
||||
interface Names {
|
||||
@@ -288,6 +310,8 @@ test.describe('editor annotations (A3)', () => {
|
||||
// The resize's own reflow (a breakpoint) settles before the press is measured.
|
||||
await page.waitForTimeout(300)
|
||||
await redo.evaluate((el) => el.scrollIntoView({ block: 'center' }))
|
||||
// Its scroll event lands before the press, which a scroll would close.
|
||||
await page.waitForTimeout(150)
|
||||
const widthBefore = await scrollWidth(page)
|
||||
await expectNoShift(page, async () => {
|
||||
await pressAtBox(page, redo)
|
||||
@@ -298,6 +322,17 @@ test.describe('editor annotations (A3)', () => {
|
||||
await expectAccessible(page, `the bubble open at ${width}`)
|
||||
await expectNoShift(page, () => page.keyboard.press('Escape'))
|
||||
await expect(bubble).toHaveCount(0)
|
||||
// Scrolled, the strip stuck under the bar: the keyboard press keeps the same rules.
|
||||
await page.evaluate(() => window.scrollTo(0, 150))
|
||||
await redo.focus()
|
||||
await page.waitForTimeout(150)
|
||||
await page.keyboard.press('Enter')
|
||||
await expect(bubble).toHaveText(reason)
|
||||
await expectBubbleBeside(page, bubble, redo, undo)
|
||||
await page.keyboard.press('Escape')
|
||||
await expect(bubble).toHaveCount(0)
|
||||
await page.evaluate(() => window.scrollTo(0, 0))
|
||||
await page.waitForTimeout(150)
|
||||
}
|
||||
await expect(page.getByTestId('gesture-message')).toHaveCount(0)
|
||||
// Escape order: the bubble first, alone; the next Escape asks about the creation.
|
||||
|
||||
Reference in new issue
Block a user