Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

14.2 KB
Raw Blame
import { _electron as electron, expect, test } from '@playwright/test'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'

for (const theme of ['light', 'dark'] as const) test(`split metadata popovers stay separate in a short note (${theme})`, async () => {
  const app = await electron.launch({ args: [join(import.meta.dirname, '../out/main/index.js')], env: {
    ...process.env, YOGURT_FAKE: '1', YOGURT_USER_DATA: mkdtempSync(join(tmpdir(), 'yogurt-e2e-')),
  } })
  try {
    const page = await app.firstWindow()
    await expect(page.getByTestId('home')).toBeVisible()
    await app.evaluate(() => (globalThis as unknown as { __fake__: { manyMeetings(o: unknown): void } }).__fake__.manyMeetings({ n: 1, clean: true }))
    const [meeting] = await page.evaluate(() => window.yogurt.meetings.cards({ limit: 1 }))
    await page.clock.setFixedTime(meeting.startedAt)
    const events = [{ id: 'linked-event', title: 'Launch planning', start: new Date(meeting.startedAt).toISOString(), end: new Date(meeting.startedAt + 1_800_000).toISOString(),
      attendees: [{ name: 'Jamie Quill', email: '[email protected]' }], url: 'https://meet.google.com/fak-eeve-ntx', calendarId: 'work', calendar: 'Work', calendarColor: '#438879', calendarSource: '[email protected]', me: '[email protected]' }]
    const next = new Date(meeting.startedAt); next.setDate(next.getDate() + 1)
    const nextTitle = 'Next day review of the international launch and the engineering handover'
    events.push({ ...events[0], id: 'next-day-event', title: nextTitle, calendarId: 'personal', calendar: 'Personal', calendarColor: '', start: next.toISOString(), end: new Date(+next + 1_800_000).toISOString() })
    events.push({ ...events[1], id: 'next-day-focus', title: 'Focus time' })
    await app.evaluate((_e, events) => (globalThis as unknown as { __fake__: { calendarEvents(events: unknown[]): void } }).__fake__.calendarEvents(events), events)
    await page.evaluate(theme => window.yogurt.settings.setTheme(theme), theme)
    await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().find(w => !w.webContents.getURL().includes('#'))!.setContentSize(720, 520))
    await page.reload()
    await page.getByTestId('past-note').click()
    await page.getByTestId('note-date').click()
    const date = page.getByTestId('note-date-card')
    await expect(date.getByTestId('note-date-event')).toHaveCount(1)
    // the view swap keeps a fading copy of the old view for a moment: measure the settled view only
    await expect(date.locator('.note-date-retiring')).toHaveCount(0)
    await date.evaluate(el => Promise.all(el.getAnimations({ subtree: true }).map(a => a.finished.catch(() => {}))))
    const lines = await date.locator(':is(h3, .note-date-event strong, .note-date-event small):not(.note-date-retiring *)').evaluateAll(els =>
      els.map(el => ({ text: (el.textContent ?? '').slice(0, 40), left: Math.round(el.getBoundingClientRect().left * 10) / 10 })))
    const textStarts = lines.map(l => l.left)
    expect(Math.max(...textStarts) - Math.min(...textStarts), JSON.stringify(lines)).toBeLessThan(1)
    await expect(date.getByTestId('note-date-events-toggle')).toHaveCount(0)
    await expect(date.getByTestId('people-list')).toHaveCount(0)
    await expect(date.getByRole('link')).toHaveCount(0)
    await page.keyboard.press('Escape')
    await expect(page.getByTestId('note-date')).toBeFocused()
    await page.getByTestId('note-attendees').click()
    await expect(page.getByTestId('people-add')).toBeFocused()
    await expect(page.getByTestId('people-card')).not.toContainText('Who was there')
    await page.keyboard.press('Escape')
    await page.getByTestId('note-date').click()
    await expect(date.getByTestId('note-date-event').first()).toBeVisible()
    await expect(date.getByTestId('note-date-heading')).toBeFocused()
    await page.keyboard.press('Tab')
    await expect(date.getByTestId('note-date-previous')).toBeFocused()
    await page.keyboard.press('Tab')
    await expect(date.getByTestId('note-date-next')).toBeFocused()
    await page.keyboard.press('Tab')
    await expect(page.getByTestId('note-date-event').first()).toBeFocused()
    const choice = date.getByTestId('note-date-event').first()
    await expect(choice).toContainText('Work')
    await expect(choice).not.toContainText('Jamie')
    const chip = page.getByTestId('note-date')
    const noteDate = await chip.innerText()
    // Access lost between listing and selection must be a retryable error.
    await app.evaluate(() => (globalThis as any).__fake__.calendarStatus('denied'))
    await page.getByTestId('note-date-event').filter({ hasText: 'Launch planning' }).press('Enter')
    await expect(date.getByRole('alert')).toContainText("Yogurt couldn't update the calendar link")
    expect((await page.evaluate(id => window.yogurt.meetings.get(id), meeting.id))?.eventId).toBeNull()
    await app.evaluate(() => (globalThis as any).__fake__.calendarStatus('granted'))
    await page.getByTestId('note-date-event').filter({ hasText: 'Launch planning' }).press('Enter')
    await expect(date).toContainText('Launch planning')
    await expect(chip.locator('.note-date-chip-dot')).toHaveCSS('background-color', 'rgb(67, 136, 121)')
    await expect(chip).toHaveAccessibleName(`${noteDate} Launch planning`)
    await expect(date.getByTestId('note-date-events-toggle')).not.toContainText('Jamie')
    await expect(date).toContainText('Work')
    await expect(date).not.toContainText('[email protected]')
    await expect(date.getByRole('button', { name: 'Open note', exact: true })).toHaveCount(0)
    await expect(date.getByRole('link', { name: 'Join meeting' })).toHaveAttribute('href', events[0].url)
    await expect(date.getByRole('link', { name: 'Join meeting' })).toHaveClass('workspace-button')
    await expect(date.getByRole('link', { name: 'Join meeting' })).toHaveCSS('height', '30px')
    await expect(date.locator('.agenda-inspector-actions')).toHaveCSS('justify-content', 'flex-end')
    await expect(date.getByTestId('people-list')).toHaveCount(0)
    await page.getByTestId('note-date-events-toggle').click()
    await expect(page.getByTestId('note-date-unlink')).not.toBeFocused()
    await expect(date.getByTestId('note-date-event')).toHaveCount(0)
    await expect(date).not.toContainText('Switch to')
    await expect(date.getByTestId('note-date-unlink')).toContainText('Keep the title, attendees and notes.')
    await expect(date.getByTestId('note-date-heading')).toHaveCount(0)
    await expect(date.getByTestId('note-date-next')).toHaveCount(0)
    await page.keyboard.press('Escape')
    await expect(date.getByTestId('note-date-events-toggle')).toBeFocused()
    await expect(date.getByTestId('note-date-unlink')).not.toBeVisible()
    await page.keyboard.press('Escape')
    await expect(date).toHaveCount(0)
    await expect(page.getByTestId('note-date')).toBeFocused()
    await page.getByTestId('note-date').press('Enter')
    await page.getByTestId('note-date-events-toggle').press('Enter')
    await expect(date.getByTestId('note-date-unlink')).toBeFocused()
    await date.getByTestId('note-date-unlink').press('Enter')
    await expect(date.getByTestId('note-date-events-toggle')).toHaveCount(0)
    await expect(date.getByTestId('note-date-event')).toHaveCount(1)
    await page.getByTestId('note-date-next').click()
    const choices = date.getByTestId('note-date-event')
    await expect(choices).toHaveCount(2)
    for (const row of await choices.all()) {
      await expect(row).toContainText('Personal')
      await expect(row).not.toContainText('Jamie')
    }
    await choices.filter({ hasText: 'Next day review' }).click()
    await expect(chip.locator('.note-date-chip-dot')).toHaveCount(0)
    await expect(chip).toContainText('·')
    await expect(chip).toHaveAccessibleName(`${noteDate} ${nextTitle}`)
    await expect(chip).toHaveAttribute('title', nextTitle)
    const name = chip.locator('.note-date-chip-name')
    await expect(name).toHaveText(nextTitle)
    expect(await name.evaluate(el => el.scrollWidth > el.clientWidth)).toBe(true)
    await expect(date.locator('.note-date-identity strong')).toHaveText(nextTitle)
    await expect(page.getByTestId('note-title')).toHaveText(meeting.title)
    await expect(date.getByRole('link', { name: 'Join meeting' })).toHaveCount(0)
    await expect(date.locator('.note-date-actions')).toHaveCount(0)
    await page.keyboard.press('Escape')
    await page.reload()
    await page.getByTestId('note-date').click()
    await expect(date).toContainText('Next day review')
    await expect(date).not.toContainText('Calendar event unavailable')
    await app.evaluate(() => (globalThis as any).__fake__.calendarStatus('denied'))
    await page.evaluate(() => window.dispatchEvent(new Event('focus')))
    await expect(date.getByRole('button', { name: 'Open System Settings' })).toBeVisible()
    await expect(date).toContainText('Next day review')
    await expect(date).toContainText('Personal')
    await expect(date).not.toContainText('[email protected]')
    await app.evaluate(() => (globalThis as any).__fake__.calendarStatus('granted'))
    await page.evaluate(() => window.dispatchEvent(new Event('focus')))
    await expect(date.getByRole('button', { name: 'Open System Settings' })).toHaveCount(0)
    await expect(date.getByTestId('note-date-next')).toHaveCount(0)
    await page.getByTestId('note-date-events-toggle').click()
    await expect(date.getByTestId('note-date-event')).toHaveCount(0)
    await page.getByTestId('note-date-unlink').click()
    await expect(date.getByTestId('note-date-events-toggle')).toHaveCount(0)
    await expect(date.getByTestId('note-date-event')).toHaveCount(1)
    await expect(page.getByTestId('note-title')).toHaveText(meeting.title)
    expect((await page.evaluate(id => window.yogurt.meetings.get(id), meeting.id))?.startedAt).toBe(meeting.startedAt)
    await page.getByTestId('note-attendees').click()
    await expect(date).toHaveCount(0)
    const people = page.getByTestId('people-card')
    await expect(people.getByTestId('people-email')).toHaveText(['[email protected]', '[email protected]'])
    await expect(people.locator('[data-me]')).toContainText('[email protected]')
    await expect(people.getByRole('heading', { name: 'Example', exact: true })).toBeVisible()
    await expect(people.getByRole('heading', { name: 'Other people', exact: true })).toHaveCount(0)
    await expect(people.locator('.person-initials')).toHaveCount(2)
    await expect(people).not.toContainText('Launch planning')
    // a mouse-opened card shows no row actions until hovered or reached by keyboard
    await expect(people.getByTestId('people-edit')).toHaveCSS('opacity', '0')
    await people.getByTestId('people-name').focus()
    await page.keyboard.press('Tab')
    await expect(people.getByTestId('people-edit')).toBeFocused()
    await expect(people.getByTestId('people-edit')).toHaveCSS('opacity', '1')
    await people.evaluate(async el => { await Promise.all(el.getAnimations().map(animation => animation.finished)) })
    const bounds = await people.boundingBox(), note = await page.getByTestId('note').boundingBox()
    expect(bounds!.y + bounds!.height).toBeLessThanOrEqual(note!.y + note!.height)
    const jamie = people.getByTestId('people-row').filter({ has: page.getByRole('button', { name: 'Jamie Quill', exact: true }) })
    const person = jamie.getByTestId('people-name')
    const remove = people.getByRole('button', { name: 'Remove from meeting' })
    await expect(remove).toHaveAttribute('title', 'Remove from meeting')
    await page.keyboard.press('Tab')
    await expect(remove).toBeFocused()
    await expect(remove).toHaveCSS('opacity', '1')
    await page.keyboard.press('Shift+Tab')
    await people.getByTestId('people-edit').press('Enter')
    await expect(people.getByRole('heading', { name: 'Edit attendee', exact: true })).toBeVisible()
    await expect(people.getByRole('button')).toHaveCount(2)
    await expect(remove).toHaveCount(0)
    await expect(people.getByTestId('people-list')).toHaveCount(0)
    expect(await people.boundingBox()).toMatchObject({ x: bounds!.x, y: bounds!.y, width: bounds!.width })
    const nameField = people.getByLabel('Name', { exact: true }), email = people.getByLabel('Email', { exact: true })
    const save = people.getByRole('button', { name: 'Save', exact: true })
    await expect(nameField).toBeFocused()
    await nameField.press('Tab')
    await expect(email).toBeFocused()
    await email.fill('jamie@')
    await save.click()
    await expect(email).toBeFocused()
    await expect(email).toHaveAccessibleDescription('Enter a valid email address.')
    await people.getByRole('button', { name: 'Cancel', exact: true }).click()
    await expect(person).toBeFocused()
    await person.click()
    await email.fill('[email protected]')
    await email.press('Escape')
    await expect(person).toBeFocused()
    await person.click()
    await nameField.fill('Unsaved name')
    await page.getByTestId('note-title').click()
    await expect(people).toHaveCount(0)
    await page.getByTestId('note-attendees').click()
    await expect(person).toHaveText('Jamie Quill')
    await expect(people.getByTestId('people-email')).toHaveText(['[email protected]', '[email protected]'])
    await person.click()
    await email.fill('')
    await email.press('Enter')
    await expect(person).toBeFocused()
    await expect(jamie.getByTestId('people-email')).toHaveCount(0)
    await person.click()
    await expect(email).toHaveAttribute('placeholder', 'Add email')
    await email.fill('[email protected]')
    await nameField.press('Enter')
    await expect(people.getByTestId('people-email')).toHaveText(['[email protected]', '[email protected]'])
    await expect(person).toBeFocused()
    await person.hover()
    await expect(people.getByTestId('people-edit')).toHaveCSS('opacity', '1')
    await expect(remove).toHaveCSS('opacity', '1')
    await remove.click()
    await expect(people.getByTestId('people-list')).toBeVisible()
    await expect(person).toHaveCount(0)
    await page.getByRole('button', { name: 'Undo', exact: true }).click()
    await page.getByTestId('note-attendees').click()
    await expect(people.getByTestId('people-email')).toHaveText(['[email protected]', '[email protected]'])
    await page.keyboard.press('Escape')
    await expect(page.getByTestId('note-attendees')).toBeFocused()
  } finally { await app.close() }
})