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.

9.2 KB
Raw Blame
import { openFromCorner } from './cornerNavigation'
import { expectBesideAsk } from './toastPosition'
import { _electron as electron, expect, test } from '@playwright/test'
import { mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'

async function launch() {
  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-feedback-')),
  } })
  const page = await app.firstWindow()
  await expect(page.getByTestId('home')).toBeVisible()
  return { app, page }
}

test('first reads have skeletons; a loaded transcript stays mounted across tabs', async ({}, testInfo) => {
  const { app, page } = await launch()
  try {
    const startX = (await page.getByTestId('workspace-heading').boundingBox())!.x
    const id = await app.evaluate(() => (globalThis as any).__fake__.bigMeeting(40))
    await app.evaluate(({ ipcMain }) => {
      for (const channel of ['meetings:cards', 'meetings:trashed', 'meetings:get', 'notes:get', 'transcript:get', 'settings:get', 'permissions:status', 'conversations:list', 'conversations:get']) {
        const old = (ipcMain as any)._invokeHandlers.get(channel)
        ipcMain.removeHandler(channel)
        ipcMain.handle(channel, async (...args) => { await new Promise(resolve => setTimeout(resolve, 650)); return old(...args) })
      }
    })
    await openFromCorner(page, 'settings-open')
    await expect(page.getByTestId('settings-loading')).toBeVisible()
    await expect(page.getByTestId('settings-heading')).toBeVisible()
    await expect(page.getByTestId('login-toggle')).toHaveCount(0)
    await page.screenshot({ path: testInfo.outputPath('settings-loading.png') })
    await expect(page.getByTestId('settings-loading')).toHaveCount(0)
    await page.getByTestId('nav-home').click()
    await expect(page.getByTestId('meetings-loading')).toBeVisible()
    await expect(page.getByTestId('new-note')).toBeVisible()
    expect((await page.getByTestId('workspace-heading').boundingBox())!.x).toBe(startX)
    await expect(page.getByTestId('meetings-loading')).toHaveCount(0)
    await openFromCorner(page, 'nav-trash')
    await expect(page.getByTestId('meetings-loading')).toBeVisible()
    await expect(page.getByTestId('trash-none')).toHaveCount(0)
    await expect(page.getByTestId('trash-none')).toBeVisible()
    await page.getByTestId('nav-chat').click()
    await expect(page.getByTestId('chat-loading')).toBeVisible()
    await expect(page.getByTestId('chat-loading')).toHaveCount(0)
    await expect(page.getByTestId('chat-recent-list')).toHaveCount(0)
    await page.evaluate(id => window.yogurt.nav.go(`/note/${id}`), id)
    await expect(page.getByTestId('note-loading')).toBeVisible()
    // Like the real note, the header pads under the toolbar, so its title row must sit below it.
    expect((await page.locator('.loading-note .note-title-type').boundingBox())!.y).toBeGreaterThan((await page.locator('.workspace-toolbar').boundingBox())!.height)
    await page.screenshot({ path: testInfo.outputPath('note-loading.png') })
    await expect(page.getByTestId('note-transcript-toggle')).toBeVisible()
    await page.getByTestId('note-transcript-toggle').click()
    await expect(page.getByTestId('transcript-loading')).toBeVisible()
    await page.screenshot({ path: testInfo.outputPath('transcript-loading.png') })
    await expect(page.getByTestId('transcript-empty')).toHaveCount(0)
    await expect(page.getByTestId('transcript-line')).toHaveCount(40)
    await page.getByTestId('transcript').evaluate(el => { (el as any).__loadedOnce = true })
    await page.getByTestId('note-notes-tab').click()
    await page.getByTestId('note-transcript-toggle').click()
    expect(await page.getByTestId('transcript').evaluate(el => (el as any).__loadedOnce)).toBe(true)
    await expect(page.getByTestId('transcript-loading')).toHaveCount(0)
    await expect(page.getByTestId('transcript-line').first()).toBeVisible()
  } finally { await app.close() }
})

test('the same Undo toast clears docked controls across pages and stays reachable in modal Ask', async ({}, testInfo) => {
  const { app, page } = await launch()
  try {
    await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().find(w => !w.isDestroyed())!.setSize(1280, 900))
    const ids = await app.evaluate(() => [(globalThis as any).__fake__.bigMeeting(4), (globalThis as any).__fake__.bigMeeting(6)])
    const thread = await page.evaluate(() => window.yogurt.conversations.ask(null, 'What was discussed?'))
    const openThread = () => page.evaluate(id => window.yogurt.nav.go(`/chat/${id}`), thread)
    await openThread()
    await expect(page.getByTestId('chat-page-turn').first()).toBeVisible()
    const composer = page.locator('.ask-full-thread .ask-composer')
    const beforeToast = await composer.boundingBox()
    // Use the same public UI action so the real Undo toast and timer are exercised.
    await page.getByTestId('nav-home').click()
    await page.evaluate(id => window.yogurt.meetings.rename(id, 'Toast test removal'), ids[1])
    const removal = page.locator('.native-meeting-row').filter({ hasText: 'Toast test removal' })
    await removal.hover()
    await removal.getByTestId('past-note-more').click()
    await page.getByTestId('past-note-trash').click()
    const toast = page.getByTestId('trash-toast')
    const expectPosition = (bar?: string) => expect.poll(() => toast.evaluate((el, selector) => {
      const rect = el.getBoundingClientRect()
      const edge = selector ? document.querySelector(selector)?.getBoundingClientRect().top : innerHeight
      return edge === undefined ? null : [Math.round(innerWidth - rect.right), Math.round(edge - rect.bottom)]
    }, bar)).toEqual([20, bar ? 12 : 20])
    await expectPosition()
    const original = await toast.elementHandle()
    await page.getByTestId('nav-chat').click()
    await expect.poll(async () => {
      const toast = await page.getByTestId('trash-toast').boundingBox(), composer = await page.getByTestId('chat-page-box').boundingBox()
      return !!toast && !!composer && composer.y + composer.height < toast.y
    }).toBe(true)
    await expectPosition()
    await toast.hover()
    await openThread()
    await expect(page.getByTestId('chat-page-turn').first()).toBeVisible()
    await expectPosition('.ask-full-thread .ask-composer')
    expect(await composer.boundingBox()).toEqual(beforeToast)
    await page.evaluate(() => window.yogurt.nav.go('/settings'))
    await expect(page.locator('.settings-screen')).toBeVisible()
    await expectPosition()
    await page.getByTestId('sidebar-collapse').click()
    await expectPosition()
    await page.emulateMedia({ reducedMotion: 'reduce' })
    await page.evaluate(() => window.yogurt.nav.go('/trash'))
    await expect(page.getByTestId('trash-page')).toBeVisible()
    await expectPosition()
    await page.evaluate(id => window.yogurt.nav.go(`/note/${id}`), ids[0])
    await expect(page.getByTestId('chat-open')).toBeVisible()
    await expectPosition('.note-footer')
    await toast.hover()
    await page.screenshot({ path: testInfo.outputPath('toast-closed.png') })
    await page.getByTestId('chat-open').click()
    await expectBesideAsk(toast)
    expect(await page.locator('.app-toast-viewport').evaluate(el => el.getAnimations().length)).toBe(0)
    await page.evaluate(() => document.documentElement.dir = 'rtl')
    await expectBesideAsk(toast)
    await page.evaluate(() => document.documentElement.dir = 'ltr')
    await toast.hover()
    await page.getByTestId('chat-panel').evaluate(el => Promise.allSettled([el, ...el.querySelectorAll('.chat-morph-surface,.chat-panel-contents')].flatMap(node => node.getAnimations()).map(a => a.finished)))
    await page.emulateMedia({ colorScheme: 'dark' })
    await expectBesideAsk(toast)
    await page.screenshot({ path: testInfo.outputPath('toast-beside-ask.png') })
    await page.getByTestId('chat-close').click()
    await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().find(w => !w.isDestroyed())!.setSize(820, 740))
    await expect(page.getByTestId('chat-open')).toHaveAttribute('aria-expanded', 'false')
    await expectPosition('.note-footer')
    await page.getByTestId('chat-open').click()
    await expect(page.getByTestId('chat-panel')).toHaveAttribute('aria-modal', 'true')
    await expectPosition('.chat-composer')
    await page.getByTestId('chat-panel').evaluate(el => Promise.allSettled([el, ...el.querySelectorAll('.chat-morph-surface,.chat-panel-contents')].flatMap(node => node.getAnimations()).map(a => a.finished)))
    await page.screenshot({ path: testInfo.outputPath('toast-narrow-chat.png') })
    expect(await toast.evaluate((el, first) => el === first, original)).toBe(true)
    const panel = page.getByTestId('chat-panel')
    const win = await app.browserWindow(page)
    await win.evaluate(w => w.webContents.setZoomFactor(2))
    await expect.poll(() => page.evaluate(() => innerHeight)).toBeLessThanOrEqual(420)
    await expectPosition('.chat-composer')
    const withToast = await panel.boundingBox()
    await page.getByTestId('trash-undo').click()
    await expect(page.locator('.app-toast[data-kind="trash-toast"]')).toHaveCount(0)
    expect(await panel.boundingBox()).toEqual(withToast)
  } finally { await app.close() }
})