test(app): make chat outline transit timing deterministic
This commit is contained in:
@@ -77,6 +77,9 @@ export async function expectNoChatOutlinePreview(page: Page): Promise<void> {
|
|||||||
|
|
||||||
export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Page): Promise<void> {
|
export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Page): Promise<void> {
|
||||||
const railBox = await requireBoundingBox(chatOutlineRail(page));
|
const railBox = await requireBoundingBox(chatOutlineRail(page));
|
||||||
|
const clockStart = Date.now();
|
||||||
|
await page.clock.install({ time: clockStart });
|
||||||
|
await page.clock.pauseAt(clockStart + 60_000);
|
||||||
await page.mouse.move(railBox.x + railBox.width + 2, railBox.y + railBox.height / 2);
|
await page.mouse.move(railBox.x + railBox.width + 2, railBox.y + railBox.height / 2);
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
document.body.dataset.chatOutlinePreviewObserved = String(
|
document.body.dataset.chatOutlinePreviewObserved = String(
|
||||||
@@ -91,19 +94,19 @@ export async function expectNoChatOutlinePreviewWhileCrossingToSidebar(page: Pag
|
|||||||
Object.assign(window, { __chatOutlinePreviewObserver: observer });
|
Object.assign(window, { __chatOutlinePreviewObserver: observer });
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let step = 0; step <= 10; step += 1) {
|
// Keep the transit slower than the activation delay at every point while making the whole
|
||||||
|
// crossing longer than it. Horizontal motion must keep postponing activation until leave
|
||||||
|
// cancels the final pending timer.
|
||||||
|
const transitSteps = 6;
|
||||||
|
for (let step = 0; step < transitSteps; step += 1) {
|
||||||
await page.mouse.move(
|
await page.mouse.move(
|
||||||
railBox.x + railBox.width - 1 - (step * railBox.width) / 10,
|
railBox.x + railBox.width - 1 - (step * railBox.width) / transitSteps,
|
||||||
railBox.y + railBox.height / 2,
|
railBox.y + railBox.height / 2,
|
||||||
);
|
);
|
||||||
await page.evaluate(
|
await page.clock.runFor(100);
|
||||||
() =>
|
|
||||||
new Promise<void>((resolve) => {
|
|
||||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await page.mouse.move(railBox.x - 2, railBox.y + railBox.height / 2);
|
await page.mouse.move(railBox.x - 2, railBox.y + railBox.height / 2);
|
||||||
|
await page.clock.runFor(200);
|
||||||
|
|
||||||
const previewAppeared = await page.evaluate(() => {
|
const previewAppeared = await page.evaluate(() => {
|
||||||
const observer = Reflect.get(window, "__chatOutlinePreviewObserver") as
|
const observer = Reflect.get(window, "__chatOutlinePreviewObserver") as
|
||||||
|
|||||||
Reference in New Issue
Block a user