chore(editor): rev 5 review nits
Deterministic scroll-settle wait for the bubble e2e, useDismissal split, precondition for the add-button focus test, CSS comment wrap.
This commit is contained in:
1 parent
a9252375e1
commit
b5dcb766b1
4 files changed
+65
-26
No files matched your search
@@ -67,6 +67,27 @@ interface Box {
|
||||
height: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves once the page's scroll position has held for three animation frames: a scroll
|
||||
* event of the move before is then past, which a bubble (closed by any scroll) must not meet.
|
||||
*/
|
||||
async function settleScroll(page: Page) {
|
||||
await page.evaluate(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
let last = window.scrollY
|
||||
let still = 0
|
||||
const frame = () => {
|
||||
still = window.scrollY === last ? still + 1 : 0
|
||||
last = window.scrollY
|
||||
if (still >= 3) resolve()
|
||||
else requestAnimationFrame(frame)
|
||||
}
|
||||
requestAnimationFrame(frame)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -311,7 +332,7 @@ test.describe('editor annotations (A3)', () => {
|
||||
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)
|
||||
await settleScroll(page)
|
||||
const widthBefore = await scrollWidth(page)
|
||||
await expectNoShift(page, async () => {
|
||||
await pressAtBox(page, redo)
|
||||
@@ -325,14 +346,14 @@ test.describe('editor annotations (A3)', () => {
|
||||
// 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 settleScroll(page)
|
||||
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 settleScroll(page)
|
||||
}
|
||||
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