// Global schedule start date (results header) auto-fills each clip's post modal // date/time from that clip's VIRALITY RANK (rank 1 = most viral = top card). // // The mocked session clips are: // clip index 0 "First viral clip" score 91 -> rank 1 // clip index 1 "Second viral clip" score 77 -> rank 2 // Per the agreed cadence (odd rank on the picked date, even rank the next day, // shared time cycles 18:00 -> 21:00 -> 13:00): // rank 1 -> start date @ 18:00 // rank 2 -> start date + 1 day @ 18:00 import { test, expect } from '@playwright/test'; import { openApp, completedSession } from '../fixtures/app.js'; const START = '2030-01-02'; const seed = { session: completedSession(), postizUrl: 'http://postiz.e2e.local', postizKey: 'postiz-e2e-key', }; test.describe('global schedule auto-fill', () => { test('prefills each clip post time from its virality rank', async ({ page }) => { await openApp(page, { seed }); await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible(); // Pick the global start date in the results header. await page.getByTestId('schedule-start-date').fill(START); // Rank 1 (top card): start date @ 18:00, scheduling auto-enabled so the // prefilled time is visible. await page.getByRole('button', { name: 'post', exact: true }).nth(0).click(); let dialog = page.getByRole('dialog'); await expect(dialog.getByLabel('date', { exact: true })).toHaveValue(START); await expect(dialog.getByLabel('time (HH:MM)', { exact: true })).toHaveValue('18:00'); await expect(dialog.getByRole('checkbox', { name: /schedule post/i })).toBeChecked(); await dialog.getByRole('button', { name: 'close' }).click(); // Rank 2: next day, same first time slot. await page.getByRole('button', { name: 'post', exact: true }).nth(1).click(); dialog = page.getByRole('dialog'); await expect(dialog.getByLabel('date', { exact: true })).toHaveValue('2030-01-03'); await expect(dialog.getByLabel('time (HH:MM)', { exact: true })).toHaveValue('18:00'); }); test('with no start date the schedule stays off', async ({ page }) => { await openApp(page, { seed }); await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible(); await page.getByRole('button', { name: 'post', exact: true }).nth(0).click(); const dialog = page.getByRole('dialog'); await expect(dialog.getByRole('checkbox', { name: /schedule post/i })).not.toBeChecked(); }); });