/** CI-only checks against the disposable stack, never against personal documents. */ import assert from 'node:assert/strict'; import { chromium } from 'playwright-core'; export async function verifyBrandUI(base: string) { for (const prefix of process.env.VERIFY_CANVAS_UI === '1' ? ['', '/studio'] : ['']) { const icon = await fetch(`${base}${prefix}/favicon.ico`); assert.equal(icon.status, 200); const bytes = new Uint8Array(await icon.arrayBuffer()); assert.deepEqual([...bytes.slice(0, 4)], [0, 0, 1, 0]); assert.equal(bytes[4], 7, 'favicon includes seven resolutions'); for (const file of ['logo-light.svg', 'logo-dark.svg', 'icon-dark.svg']) { const image = await fetch(`${base}${prefix}/brand/${file}`); assert.equal(image.status, 200, prefix + '/' + file); assert.match(await image.text(), / { await page.goto(base + path, { waitUntil: 'commit' }); await page.locator('button[data-theme-ready="true"]').first().waitFor(); await page.waitForFunction(expected => document.documentElement.dataset.theme === expected, theme); console.log('Brand UI route ready:', path, theme); }; const background = (selector: string) => page.locator(selector).first().evaluate(el => getComputedStyle(el).backgroundColor); await visit('/', 'home-light'); assert.equal(await background('body'), 'rgb(255, 246, 239)'); assert.ok((await page.title()).includes('啡跃')); assert.ok((await page.locator('link[rel="icon"]').all()).length >= 2); assert.equal(await page.locator('.endoleap-mark-light').first().isVisible(), true); await page.getByRole('button', { name: '切换明暗主题', exact: true }).first().click(); await page.waitForFunction(() => document.documentElement.dataset.theme === 'home-dark'); assert.equal(await background('body'), 'rgb(28, 24, 22)'); assert.equal(await page.locator('.endoleap-mark-dark').first().isVisible(), true); await visit('/account', 'home-dark'); if (process.env.VERIFY_CANVAS_UI === '1') { await visit('/graphic', 'canvas-dark'); assert.equal(await background('body'), 'rgb(20, 20, 20)'); assert.equal(await page.locator('[class*="boardWrap"] > div').first().evaluate(el => getComputedStyle(el).backgroundColor), 'rgb(255, 255, 255)', 'artwork stays white in dark chrome'); await page.getByRole('button', { name: '切换明暗主题', exact: true }).first().click(); await page.waitForFunction(() => document.documentElement.dataset.theme === 'canvas-light'); await visit('/infinite_canvas', 'canvas-light'); assert.equal(await background('[class*="viewport"]'), 'rgb(250, 250, 250)'); } else { await page.getByRole('button', { name: '切换明暗主题', exact: true }).first().click(); } await visit('/', 'home-light'); await page.setViewportSize({ width: 390, height: 844 }); assert.equal(await page.locator('.endoleap-mark-light').first().isVisible(), true); assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), 'mobile home has no horizontal overflow'); console.log('Endoleap logos, both favicon paths, persisted home/canvas themes and artwork color isolation passed.'); } finally { await browser.close(); } }