import { expect, test } from '@playwright/test' import { chooseObjective, learnerFor, signIn, EDUCATOR } from './helpers.js' test('a cross-reference previews before it is followed', async ({ page, isMobile }, testInfo) => { test.skip(isMobile, 'hover is a pointer thing; the phone opens the card on tap') await signIn(page, learnerFor(testInfo)) await page.goto('/articles/1') await chooseObjective(page) const link = page.locator('.al-link').first() await expect(link).toBeVisible() await link.hover() const card = page.getByRole('tooltip') await expect(card).toBeVisible() await expect(card).toContainText(/Bronchiolitis/i) // The two ways out of the card, and neither of them is "you have left the // article you were reading". await expect(card.getByRole('link', { name: /new tab/i })).toBeVisible() }) test('an educator sees the tools a learner does not', async ({ page }) => { await signIn(page, EDUCATOR) await page.goto('/articles/1') await chooseObjective(page) await expect(page.getByRole('button', { name: /^Edit$/ })).toBeVisible() // Drafting belongs in the editor, not on the page a learner is reading. await expect(page.getByRole('button', { name: /AI refine/i })).toHaveCount(0) }) test('a learner sees no editing tools at all', async ({ page }, testInfo) => { await signIn(page, learnerFor(testInfo)) await page.goto('/articles/1') await chooseObjective(page) // The article's own title, not the entry for it in the contents drawer. await expect(page.locator('.article-title, h1').first()).toContainText(/Croup/i) await expect(page.getByRole('button', { name: /^Edit$/ })).toHaveCount(0) await expect(page.getByRole('button', { name: /Generate cards/i })).toHaveCount(0) })