Files
archie/e2e/checks/chat-dock-phone.cjs
T
sam 3f092c0704
ci/woodpecker/pr/quality Pipeline was successful
Quality / check (pull_request) Canceled after 0s
test(e2e): chat dock browser checks (#1886)
2026-11-12 23:08:02 +11:00

42 lines
2.2 KiB
JavaScript

// The chat dock at phone width: the bar and the open conversation fit the
// screen on a few pages, a stored desktop pin is ignored, the composer stays
// reachable, and the dock adds no sideways scroll. The page's own overflow is
// phone-overflow's to report, so the dock is measured against the page
// without it.
const assert = require('node:assert/strict');
const h = require('./helpers/chat-dock.cjs');
module.exports = async ({ page, go, shot, tolerate }) => {
tolerate(/extensions\/catalogue/);
await page.setViewportSize({ width: 390, height: 844 });
const fits = async (label) => {
const { scroll, bare, inner } = await page.evaluate(() => {
const root = document.querySelector('aside[aria-label="Chat with Archie"]').parentElement;
const scroll = document.documentElement.scrollWidth;
root.style.display = 'none';
const bare = document.documentElement.scrollWidth;
root.style.display = '';
return { scroll, bare, inner: window.innerWidth };
});
assert.ok(scroll <= Math.max(bare, inner), `${label}: the dock widens the page (${scroll} > ${Math.max(bare, inner)})`);
const box = await h.dockOf(page).boundingBox();
assert.ok(box.x >= 0 && box.x + box.width <= inner, `${label}: dock leaves the screen (${box.x}..${box.x + box.width})`);
assert.ok(box.y >= 0 && box.y + box.height <= 844, `${label}: dock leaves the screen vertically`);
};
for (const path of ['/events', '/account', '/org/agents']) {
await h.load(page, go, JSON.stringify({ side: 'right', width: 420 }));
await go(path);
await fits(`${path} collapsed`);
await h.expand(page);
await fits(`${path} open`);
assert.equal(await page.evaluate(() => document.documentElement.style.getPropertyValue('--chat-pin-r')), '0px', `${path}: the page reserved room for a pin on a phone`);
const composer = await h.composerOf(page).boundingBox();
assert.ok(composer.y + composer.height <= 844 && composer.x >= 0 && composer.x + composer.width <= 390, `${path}: composer is off screen`);
assert.equal(await h.dividerOf(page).count(), 0, `${path}: a phone shows the pin divider`);
await h.composerOf(page).fill('A long unbroken line '.repeat(20));
await fits(`${path} long draft`);
await shot(path);
}
};