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.

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

test('the hidden sidebar peeks over a full-width page and keeps folder actions available, including at narrow widths', 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-peek-')),
  } })
  try {
    const page = await app.firstWindow()
    await expect(page.getByTestId('home')).toBeVisible()
    await page.emulateMedia({ reducedMotion: 'no-preference' })
    await page.getByTestId('folder-create').click()
    await page.getByTestId('folder-name-input').fill('Standup')
    await page.getByTestId('folder-name-save').click()
    const corner = page.getByTestId('corner-menu-button')
    const footer = page.locator('.workspace-corner')
    await expect(footer).toHaveCSS('border-top-width', '1px')
    const markInset = () => corner.locator('svg path').evaluate(mark =>
      Math.round(mark.getBoundingClientRect().left - mark.closest('.workspace-corner')!.getBoundingClientRect().left))
    await expect.poll(markInset).toBe(21)
    const panel = page.getByRole('complementary', { name: 'Main navigation' })
    const content = page.locator('.workspace-content')
    await page.getByTestId('sidebar-collapse').click()
    await expect(panel).toHaveCount(0)
    await expect.poll(() => content.evaluate(el => el.getBoundingClientRect().width)).toBe(await page.evaluate(() => innerWidth))
    await expect(corner).not.toBeInViewport()
    await expect(page.getByRole('button', { name: 'Help and settings' })).toHaveCount(0)
    const toggle = page.getByTestId('sidebar-expand')
    await page.mouse.move(500, 200)
    await toggle.hover()
    await expect(page.getByRole('tooltip')).toHaveText('Show sidebar (⌃⌘S)')
    await expect(panel).toBeVisible()
    await expect(panel).toHaveCSS('pointer-events', 'auto')
    // Pause beyond the old 80ms deadline in the strip above the panel, outside the 124px window bar.
    await page.mouse.move(190, 47, { steps: 5 })
    await page.waitForTimeout(180)
    await expect(panel).toBeVisible()
    await panel.getByTestId('search-open').hover()
    await expect(toggle).toHaveAttribute('aria-expanded', 'true')
    await page.mouse.move(500, 200)
    await expect(panel).toHaveCount(0)
    await page.mouse.move(12, 200)
    await expect(panel).toBeVisible()
    await expect(panel.getByTestId('corner-menu-button')).toBeInViewport()
    await expect.poll(() => footer.evaluate(el => innerHeight - el.getBoundingClientRect().bottom)).toBe(0)
    expect(await content.evaluate(el => el.getBoundingClientRect().x)).toBe(0)
    await expect(page.getByTestId('nav-trash')).toHaveCount(0)
    await expect(page.getByTestId('settings-open')).toHaveCount(0)
    await expect(page.getByTestId('nav-chat')).toHaveAccessibleName('Ask')
    await page.getByTestId('nav-chat').click()
    await expect(page.getByTestId('workspace-heading')).toHaveText('Ask')
    await expect(panel).toHaveCount(0)
    await toggle.press('ArrowDown')
    await page.getByTestId('sidebar-folder-open').click({ button: 'right' })
    await expect(page.getByTestId('sidebar-folder-rename')).toBeVisible()
    await expect.poll(async () => (await page.getByTestId('sidebar-folder-menu').boundingBox())!.width).toBeGreaterThanOrEqual(180)
    await page.getByTestId('sidebar-folder-rename').click()
    await expect(page.getByTestId('folder-name-input')).toBeFocused()
    await page.keyboard.press('Escape')
    await expect(page.getByTestId('sidebar-folder-more')).toBeFocused()
    await page.getByTestId('sidebar-folder-open').press('Enter')
    await expect(page.getByTestId('folder-title')).toHaveText('Standup')
    await toggle.press('ArrowDown')
    await page.getByTestId('search-open').click()
    await expect(page.getByTestId('search-input')).toBeVisible()
    await page.keyboard.press('Escape')
    await openFromCorner(page, 'settings-open')
    await expect(page.getByTestId('settings')).toBeVisible()
    await openFromCorner(page, 'nav-trash')
    await expect(page.getByTestId('workspace-heading')).toHaveText('Trash')
    await page.emulateMedia({ reducedMotion: 'reduce' })
    await toggle.click()
    await page.getByTestId('sidebar-collapse').click()
    expect(await page.locator('#workspace-sidebar').evaluate(el => getComputedStyle(el).transitionDuration)).toBe('0s')
    await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].setSize(720, 700))
    await toggle.press('ArrowDown')
    await page.getByTestId('nav-home').click()
    await expect(panel).toHaveCount(0)
    expect((await content.boundingBox())!.width).toBe(await page.evaluate(() => innerWidth))
    expect(await page.locator('.workspace').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
    // The hidden sidebar's hover zone leaves hit testing to the meeting list, including its scroll area.
    const library = page.locator('.native-home > .native-library')
    expect(await library.evaluate(el => [2, 12, 15].every(x => el.contains(document.elementFromPoint(x, 200))))).toBe(true)
    expect(await page.locator('.workspace-sidebar-body').evaluate(el => getComputedStyle(el).overflowX)).toBe('hidden')
    await page.evaluate(() => window.yogurt.settings.setLanguage('ar'))
    await expect(page.locator('html')).toHaveAttribute('dir', 'rtl')
    await toggle.press('ArrowDown')
    const box = (await corner.boundingBox())!
    const mark = (await corner.locator('svg path').boundingBox())!
    expect(mark.x).toBeGreaterThanOrEqual(box.x)
    expect(mark.x + mark.width).toBeLessThanOrEqual(box.x + box.width)
    await corner.click()
    const menu = page.getByTestId('corner-menu')
    await expect(menu).toBeVisible()
    const popup = (await menu.boundingBox())!
    expect(popup.x).toBeGreaterThanOrEqual(0)
    expect(popup.y + popup.height).toBeLessThanOrEqual(box.y)
  } finally { await app.close() }
})