import {test,expect} from '@playwright/test'; import {bootCalendar,printCalendar} from './calendar-fixture.mjs'; test('busy calendar days show nine single-line orders and retain access to the rest',async({page,context})=>{ const dates=await bootCalendar(page,context); const day=i=>page.locator(`.cal-day[data-date="${dates[i]}"]`); await expect(day(0)).not.toHaveClass(/cal-day--compact/); await expect(day(0).locator('.cal-event:visible')).toHaveCount(3); await expect(day(1)).toHaveClass(/cal-day--compact/); await expect(day(1).locator('.cal-event:visible')).toHaveCount(4); await expect(day(2).locator('.cal-event:visible')).toHaveCount(9); await expect(day(2).locator('.cal-more')).toHaveCount(0); expect(await day(2).locator('.cal-event').evaluateAll(rows=>rows.every(row=>row.getBoundingClientRect().height<26))).toBe(true); await expect(day(3).locator('.cal-event:visible')).toHaveCount(9); await expect(day(3).locator('.cal-more')).toHaveText('+ ещё 2'); await day(3).locator('.cal-more').click(); await expect(page.locator('[data-cal-open-v1762]')).toHaveCount(11); await page.locator('[data-cal-open-v1762="1310"]').click(); expect(await page.evaluate(()=>draft.id)).toBe(1310); }); test('calendar print fits nine orders inside the day and includes overflow on a continuation sheet',async({page,context})=>{ const dates=await bootCalendar(page,context),popup=await printCalendar(page,context); await popup.emulateMedia({media:'print'}); await expect(popup.locator(`.cal-day[data-date="${dates[2]}"] .cal-event`)).toHaveCount(9); const fit=await popup.locator('.cal-day').evaluateAll(days=>{ return days.every(day=>{const cell=day.getBoundingClientRect();return [...day.querySelectorAll('.cal-event')].every(row=>{const box=row.getBoundingClientRect();return box.top>=cell.top&&box.bottom<=cell.bottom-1})}); }); expect(fit).toBe(true); await expect(popup.locator('.cal-print-overflow .cal-event')).toHaveCount(2); await expect(popup.locator('.cal-print-overflow [data-order-id="1310"]')).toBeVisible(); const ids=await popup.locator('.cal-event').evaluateAll(rows=>rows.map(r=>r.dataset.orderId)); expect(ids).toHaveLength(27);expect(new Set(ids).size).toBe(27); expect(await popup.locator('.cal-print-overflow').evaluate(el=>getComputedStyle(el).breakBefore)).toBe('page'); expect(await popup.locator('body').innerText()).not.toContain('₽'); await popup.close(); });