import { expect } from '@open-wc/testing' import { OxFiltersForm } from '../src/filters/filters-form.js' /* * A filter wider than the line - a date range on a phone: its label and two dates - ran past the screen's edge, the * form taking its content's width (2026-11-10, 감사 기록 at 375px). The form is no wider than the room it is given, and * a filter's inputs shrink into it. */ const text = (styles: unknown) => (Array.isArray(styles) ? styles : [styles]).map(s => String((s as { cssText?: string }).cssText ?? s)).join('\n') describe('a date range filter on a phone', () => { it('ends inside the room the form is given', async () => { const frame = document.createElement('iframe') frame.style.cssText = 'width:375px;height:300px;border:0' document.body.appendChild(frame) const doc = frame.contentDocument! const css = text(OxFiltersForm.styles).replace(/:host/g, '.host') doc.open() doc.write(`
`) doc.close() await new Promise(resolve => setTimeout(resolve, 0)) try { const right = (selector: string) => Math.round(doc.querySelector(selector)!.getBoundingClientRect().right) expect(right('form'), 'the form is wider than its room').to.be.at.most(351) expect(right('#to'), 'the last date runs past the room').to.be.at.most(351) } finally { frame.remove() } }) })