- commit
- 8fe3dd69b67734cb2b465ea248c1cf01e3c28f55
- parent
- 6ec67ec381914e39b14d9cc87ea1c847183888d7
- author
- Dami <dami.etoile@gmail.com>
| M | tests/ | 57 | ++++++++++++++++++++++++++++++ |
@@ -281,6 +281,40 @@ async function assertCanvasRound3Typography(page, { ledger = false, win = false
281281 assert.ok(progress[0] - headline[1] >= 10, 'Win card progress line should have visible spacing below headline');282282 }283283 284+async function assertGiftActionsBelowPreview(page, label) {285+ const box = await page.evaluate(() => {286+ const canvas = document.querySelector('.stage-canvas');287+ const ctx = canvas?.getContext('2d');288+ if (!canvas || !ctx) return null;289+ const pixels = ctx.getImageData(0, 0, canvas.width, canvas.height).data;290+ const orange = (x, y) => {291+ const i = (y * canvas.width + x) * 4;292+ return pixels[i] > 180 && pixels[i + 1] > 90 && pixels[i + 1] < 210 && pixels[i + 2] < 100;293+ };294+ const actionRows = [];295+ for (let y = Math.floor(canvas.height * 0.4); y < canvas.height; y += 1) {296+ let count = 0;297+ for (let x = 0; x < canvas.width; x += 1) if (orange(x, y)) count += 1;298+ if (count > 100) actionRows.push(y);299+ }300+ let minX = canvas.width;301+ let maxX = -1;302+ let minY = actionRows.length ? Math.min(...actionRows) : canvas.height;303+ let maxY = actionRows.length ? Math.max(...actionRows) : -1;304+ for (const y of actionRows) for (let x = 0; x < canvas.width; x += 1) if (orange(x, y)) {305+ minX = Math.min(minX, x);306+ maxX = Math.max(maxX, x);307+ }308+ return { width: canvas.width, height: canvas.height, minX, maxX, minY, maxY };309+ });310+ assert.ok(box && box.maxY >= 0, `${label} should render a selected Gift action`);311+ if (box.width <= 760) {312+ assert.ok(box.minY >= box.height * 0.62, `${label} Gift actions should sit below the preview board`);313+ } else {314+ assert.ok(box.minX >= box.width * 0.40, `${label} Gift actions should sit to the right of the preview board`);315+ }316+}317+284318 async function openDevProof(page) {285319 await page.keyboard.press('Enter');286320 await page.waitForFunction(() => document.querySelector('.stage-shell')?.dataset.scene === 'index');@@ -644,6 +678,29 @@ try {
644678 await navigationPage.waitForFunction(first => document.querySelector('#level-list .level-choice.active')?.dataset.levelId === first, firstWordLabLevel);645679 assert.equal(await currentPackId(navigationPage), 'word-lab', 'previous arrow should preserve the active pack');646680 report('level arrows navigate within the selected pack');681+ await triggerShare(navigationPage);682+ const wordLabShareUrl = await readShareUrl(navigationPage);683+ const wordLabGiftContext = await browser.newContext();684+ const wordLabGiftPage = await wordLabGiftContext.newPage();685+ wordLabGiftPage.setDefaultTimeout(timeout);686+ await wordLabGiftPage.setViewportSize({ width: 1280, height: 800 });687+ await wordLabGiftPage.goto(wordLabShareUrl, { waitUntil: 'networkidle' });688+ await wordLabGiftPage.waitForFunction(() => document.querySelector('.stage-shell')?.dataset.scene === 'gift');689+ await wordLabGiftPage.waitForTimeout(700);690+ await wordLabGiftPage.screenshot({ path: `${stageScreenshotDir}/gift-word-lab-desktop.png` });691+ await assertGiftActionsBelowPreview(wordLabGiftPage, 'desktop Word Lab Gift');692+ const wordLabGiftMobile = await wordLabGiftContext.newPage();693+ wordLabGiftMobile.setDefaultTimeout(timeout);694+ await wordLabGiftMobile.setViewportSize({ width: 390, height: 844 });695+ await wordLabGiftMobile.goto(wordLabShareUrl, { waitUntil: 'networkidle' });696+ await wordLabGiftMobile.waitForFunction(() => document.querySelector('.stage-shell')?.dataset.scene === 'gift');697+ await wordLabGiftMobile.waitForTimeout(700);698+ await wordLabGiftMobile.screenshot({ path: `${stageScreenshotDir}/gift-word-lab-mobile.png` });699+ await assertGiftActionsBelowPreview(wordLabGiftMobile, 'mobile Word Lab Gift');700+ report('Word Lab shared Gift captured at desktop and mobile sizes');701+ await wordLabGiftPage.close();702+ await wordLabGiftMobile.close();703+ await wordLabGiftContext.close();647704 await navigationPage.close();648705 649706 const singlePackContext = await browser.newContext();