Files
tolaria/tests/smoke/trashed-archived-not-saved.spec.ts
Test c9a5d20c12 test: Playwright smoke test for trash → Changes badge
Also track mock frontmatter writes in mockSavedSinceCommit so the
Changes panel updates correctly in browser dev mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 23:08:18 +01:00

40 lines
1.5 KiB
TypeScript

import { test, expect } from '@playwright/test'
import { openCommandPalette, executeCommand } from './helpers'
test.describe('Trash/archive notes appear in Changes', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/')
await page.waitForLoadState('networkidle')
})
test('trashing a note increments the Changes badge', async ({ page }) => {
const sidebar = page.locator('.app__sidebar')
// Wait for Changes nav item (mock starts with 3 modified files)
const changesRow = sidebar.locator('div', { hasText: /^Changes/ }).first()
await changesRow.waitFor({ timeout: 5000 })
// Read the initial badge count from the Changes row
const badge = changesRow.locator('span').last()
const initialCount = Number(await badge.textContent())
expect(initialCount).toBeGreaterThan(0)
// Click the first note in the list to select it
const noteListContainer = page.locator('[data-testid="note-list-container"]')
await noteListContainer.waitFor({ timeout: 5000 })
// Click on the first visible note item (border-b items inside the list)
const firstNote = noteListContainer.locator('.cursor-pointer').first()
await firstNote.click()
// Trash the active note via command palette
await openCommandPalette(page)
await executeCommand(page, 'Trash Note')
// Wait for the badge count to increase
await expect(async () => {
const text = await badge.textContent()
expect(Number(text)).toBeGreaterThan(initialCount)
}).toPass({ timeout: 5000 })
})
})