import { test, expect } from '@playwright/test'; import { NOTE_TEXT, pasteInto, resumeButton, seedStudy } from './helpers.js'; test('open a study, write notes, answer the paste check, and use the keyboard', async ({ page }) => { const { title } = await seedStudy(page); await expect(page.getByRole('heading', { name: title })).toBeVisible(); await expect(page.getByText(/needs a connection for john/i).first()).toBeVisible(); // the offline badge await resumeButton(page, title).click(); await expect(page.getByRole('heading', { name: 'John 3:16–18' })).toBeVisible(); // keyboard: 2 jumps into Interpret, Escape leaves it await page.keyboard.press('2'); await expect(page.getByRole('textbox', { name: 'Interpret' })).toBeFocused(); await page.keyboard.press('Escape'); await expect(page.getByRole('textbox', { name: 'Interpret' })).not.toBeFocused(); // a long paste asks whether it is from AI; "No, I wrote it" counts the words as yours await page.keyboard.press('1'); const observe = page.getByRole('textbox', { name: 'Observe' }); const pasted = Array.from({ length: 24 }, (_, i) => `pasted${i}`).join(' '); await pasteInto(observe, pasted); await observe.fill(`${NOTE_TEXT.observation} ${pasted}`); await expect(page.getByText(/is this from ai\?/i)).toBeVisible(); await expect(page.getByText(/24 words here were pasted/i)).toBeVisible(); await page.getByRole('button', { name: 'No, I wrote it' }).click(); await expect(page.getByText(/is this from ai\?/i)).toHaveCount(0); await expect(page.getByText(/were pasted/i)).toHaveCount(0); // either half of the right column can be folded const resources = page.getByRole('button', { name: /commentary & resources/i }); await resources.click(); await expect(resources).toHaveAttribute('aria-expanded', 'false'); await page.getByRole('button', { name: 'Your notes' }).click(); // folding the last open half opens the other await expect(resources).toHaveAttribute('aria-expanded', 'true'); // the reading list belongs to the study await page.getByRole('button', { name: 'Your notes' }).click(); // make room: fold notes, resources stay open await page.getByRole('tab', { name: /reading list/i }).click(); await page.getByRole('textbox', { name: /add to the reading list/i }).fill('Carson on John'); await page.keyboard.press('Enter'); await page.getByRole('checkbox', { name: /read: carson on john/i }).check(); await expect(page.getByRole('checkbox', { name: /read: carson on john/i })).toBeChecked(); });