| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| import { test, expect } from '@playwright/test'; |
| import { mkdirSync } from 'node:fs'; |
|
|
| const COMPARE_QUERY = 'Compare 80 Pioneer Street Brooklyn to 100 Gold Street Manhattan'; |
| const SCREENSHOT_DIR = 'test-results/demo-screenshots'; |
| mkdirSync(SCREENSHOT_DIR, { recursive: true }); |
|
|
| test.describe('@compare two-column layout', () => { |
| test.describe.configure({ mode: 'serial', timeout: 360_000 }); |
|
|
| test('compare renders two address headers and delta bar', async ({ page }) => { |
| await page.setViewportSize({ width: 1440, height: 900 }); |
|
|
| const consoleErrors: string[] = []; |
| page.on('console', (msg) => { |
| if (msg.type() === 'error') consoleErrors.push(msg.text()); |
| }); |
|
|
| await page.goto(`/q/${encodeURIComponent(COMPARE_QUERY)}`, { |
| waitUntil: 'domcontentloaded' |
| }); |
|
|
| |
| |
| await page.waitForFunction( |
| () => { |
| const errCard = document.querySelector('.error-card'); |
| const headers = document.querySelectorAll('.address-header'); |
| return Boolean(errCard) || headers.length >= 2; |
| }, |
| undefined, |
| { timeout: 360_000 } |
| ); |
|
|
| |
| await expect(page.locator('.error-card'), 'no ErrorCard for valid compare query') |
| .toHaveCount(0); |
|
|
| |
| const headers = page.locator('.address-header'); |
| await expect(headers, 'exactly two address-header elements').toHaveCount(2); |
|
|
| |
| const textA = (await headers.nth(0).textContent())?.trim(); |
| const textB = (await headers.nth(1).textContent())?.trim(); |
| expect(textA, 'PLACE A header has address text').toBeTruthy(); |
| expect(textB, 'PLACE B header has address text').toBeTruthy(); |
| expect(textA, 'PLACE A and PLACE B headers differ').not.toBe(textB); |
|
|
| |
| |
| const deltaBar = page.locator('.compare-delta-bar'); |
| const deltaCount = await deltaBar.count(); |
| |
| console.log(`[compare] delta bar present: ${deltaCount > 0}`); |
|
|
| |
| const sectionHeads = page.locator('.briefing-section-head'); |
| const headCount = await sectionHeads.count(); |
| expect(headCount, 'at least two section heads (one per column)').toBeGreaterThanOrEqual(2); |
|
|
| |
| const filteredErrors = consoleErrors.filter( |
| (e) => !e.includes('favicon') && !e.includes('maplibre-gl') |
| ); |
| expect(filteredErrors, `console errors: ${filteredErrors.join(' | ')}`).toEqual([]); |
|
|
| await page.screenshot({ |
| path: `${SCREENSHOT_DIR}/compare.png`, |
| fullPage: true |
| }); |
|
|
| console.log( |
| `[compare] headers="${textA}" / "${textB}" · sections=${headCount} · delta=${deltaCount > 0}` |
| ); |
| }); |
|
|
| test('compare two-column layout stacks on narrow viewport', async ({ page }) => { |
| |
| await page.setViewportSize({ width: 800, height: 900 }); |
|
|
| await page.goto(`/q/${encodeURIComponent(COMPARE_QUERY)}`, { |
| waitUntil: 'domcontentloaded' |
| }); |
|
|
| await page.waitForFunction( |
| () => document.querySelectorAll('.address-header').length >= 2 || |
| Boolean(document.querySelector('.error-card')), |
| undefined, |
| { timeout: 360_000 } |
| ); |
|
|
| |
| const headers = page.locator('.address-header'); |
| await expect(headers).toHaveCount(2); |
|
|
| |
| const cols = page.locator('.compare-cols'); |
| if (await cols.count() > 0) { |
| const gridCols = await cols.evaluate( |
| (el) => window.getComputedStyle(el).gridTemplateColumns |
| ); |
| |
| expect(gridCols, 'stacked: single grid column track').not.toContain('1px'); |
| } |
| }); |
| }); |
|
|