guanghu/tests/smoke/command-palette-new-note-dedupe.spec.ts
冰朔 8739805f99
Some checks failed
Auto-update PR branches / Update open PR branches (push) Has been cancelled
CI / Frontend Static Quality Checks (push) Has been cancelled
CI / Frontend Tests & Coverage (push) Has been cancelled
CI / Rust Tests & Quality Checks (push) Has been cancelled
CI / Linux build verification (push) Has been cancelled
Release (Alpha) / Compute alpha version (push) Has been cancelled
Release (Alpha) / Build release artifacts (push) Has been cancelled
Release (Alpha) / GitHub Release (alpha) (push) Has been cancelled
Release (Alpha) / Update docs and release pages (push) Has been cancelled
Deploy docs / Build VitePress site (push) Has been cancelled
Deploy docs / Deploy to GitHub Pages (push) Has been cancelled
光湖开源源码快照 · Tolaria AGPL 分叉基线 · 独立更新链
2026-07-05 17:45:16 +08:00

46 lines
1.7 KiB
TypeScript

import { test, expect } from '@playwright/test'
import { openCommandPalette } from './helpers'
test.describe('Command palette new note command dedupe', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' })
await expect(page.locator('[data-testid="sidebar-top-nav"]')).toBeVisible({ timeout: 10_000 })
})
test('searching new note shows one canonical New Note command with Cmd+N', async ({ page }) => {
await openCommandPalette(page)
const commandInput = page.locator('input[placeholder="Type a command..."]')
await commandInput.fill('new note')
const newNoteRow = page
.locator('div.mx-1.flex.cursor-pointer')
.filter({ has: page.getByText('New Note', { exact: true }) })
await expect(newNoteRow).toHaveCount(1)
await expect(newNoteRow.getByText('⌘N', { exact: true })).toBeVisible()
await expect(page.getByText('Create New Note', { exact: true })).toHaveCount(0)
await expect(page.getByText('New note', { exact: true })).toHaveCount(0)
})
test('searching new ty shows one canonical New Type command and opens the type dialog', async ({ page }) => {
await openCommandPalette(page)
const commandInput = page.locator('input[placeholder="Type a command..."]')
await commandInput.fill('new ty')
const newTypeRow = page
.locator('div.mx-1.flex.cursor-pointer')
.filter({ has: page.getByText('New Type', { exact: true }) })
await expect(newTypeRow).toHaveCount(1)
await page.keyboard.press('Enter')
await expect(page.getByText('Create New Type', { exact: true })).toBeVisible()
await page.keyboard.press('Escape')
await expect(page.getByText('Create New Type', { exact: true })).not.toBeVisible()
})
})