38 lines
1.9 KiB
JavaScript
38 lines
1.9 KiB
JavaScript
// The pinned dock's divider is a keyboard separator: the arrow toward the
|
|
// page widens the dock, the arrow away narrows it, both stop at the allowed
|
|
// range, and the width is saved.
|
|
const assert = require('node:assert/strict');
|
|
const h = require('./helpers/chat-dock.cjs');
|
|
|
|
const width = (page) => h.dockOf(page).boundingBox().then((b) => Math.round(b.width));
|
|
const value = (page) => h.dividerOf(page).getAttribute('aria-valuenow').then(Number);
|
|
|
|
module.exports = async ({ page, go }) => {
|
|
const divider = h.dividerOf(page);
|
|
for (const [side, grow, shrink] of [['right', 'ArrowLeft', 'ArrowRight'], ['left', 'ArrowRight', 'ArrowLeft']]) {
|
|
await h.load(page, go, JSON.stringify({ side, width: 420 }));
|
|
await h.expand(page);
|
|
await divider.focus();
|
|
assert.equal(await value(page), 420);
|
|
assert.equal(await divider.getAttribute('aria-valuemin'), '320');
|
|
|
|
await page.keyboard.press(grow);
|
|
await h.until(async () => (await value(page)) === 436 && (await width(page)) === 436, `${side}: ${grow} did not widen by 16`);
|
|
await page.keyboard.press(shrink);
|
|
await page.keyboard.press(shrink);
|
|
await h.until(async () => (await value(page)) === 404 && (await width(page)) === 404, `${side}: ${shrink} did not narrow by 16`);
|
|
assert.equal((await h.saved(page)).width, 404, `${side}: the width was not saved`);
|
|
|
|
await page.keyboard.press('ArrowUp');
|
|
assert.equal(await value(page), 404, `${side}: a vertical arrow resized the dock`);
|
|
|
|
for (let i = 0; i < 12; i++) await page.keyboard.press(shrink);
|
|
await h.until(async () => (await width(page)) === 320, `${side}: the dock narrowed past its minimum`);
|
|
assert.equal(await value(page), 320);
|
|
|
|
for (let i = 0; i < 30; i++) await page.keyboard.press(grow);
|
|
await h.until(async () => (await width(page)) === 720, `${side}: the dock widened past its maximum`);
|
|
assert.equal(await value(page), 720);
|
|
}
|
|
};
|