guanghu/tests/smoke/example.spec.ts
Guanghu Domestic Migration 9b41d51231
Some checks are pending
Auto-update PR branches / Update open PR branches (push) Waiting to run
CI / Frontend Static Quality Checks (push) Waiting to run
CI / Frontend Tests & Coverage (push) Waiting to run
CI / Rust Tests & Quality Checks (push) Waiting to run
CI / Linux build verification (push) Waiting to run
Deploy docs / Build VitePress site (push) Waiting to run
Deploy docs / Deploy to GitHub Pages (push) Blocked by required conditions
Release (Alpha) / Compute alpha version (push) Waiting to run
Release (Alpha) / Build release artifacts (push) Blocked by required conditions
Release (Alpha) / GitHub Release (alpha) (push) Blocked by required conditions
Release (Alpha) / Update docs and release pages (push) Blocked by required conditions
chore: import sanitized domestic snapshot for REPO-004
Source snapshot: 514ab1975951d94342ea38e64101d5a0f1c51c77
2026-07-17 15:55:28 +08:00

72 lines
2.2 KiB
TypeScript

import { test, expect } from '@playwright/test'
import {
openCommandPalette,
closeCommandPalette,
findCommand,
sendShortcut,
verifyVisible,
} from './helpers'
test.describe('Command Palette smoke tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' })
await expect(page.locator('[data-testid="sidebar-top-nav"]')).toBeVisible({ timeout: 10_000 })
})
test('Cmd+K opens the command palette @smoke', async ({ page }) => {
await openCommandPalette(page)
await verifyVisible(page, 'input[placeholder="Type a command..."]')
})
test('Escape closes the command palette', async ({ page }) => {
await openCommandPalette(page)
await closeCommandPalette(page)
await expect(
page.locator('input[placeholder="Type a command..."]'),
).not.toBeVisible()
})
test('typing filters the command list', async ({ page }) => {
await openCommandPalette(page)
const found = await findCommand(page, 'reload')
expect(found).toBe(true)
})
test('arrow keys navigate commands', async ({ page }) => {
await openCommandPalette(page)
const first = await page
.locator('[data-selected="true"]')
.first()
.textContent()
await page.keyboard.press('ArrowDown')
const second = await page
.locator('[data-selected="true"]')
.first()
.textContent()
expect(first).not.toBe(second)
})
})
test.describe('Keyboard shortcuts smoke tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' })
await expect(page.locator('[data-testid="sidebar-top-nav"]')).toBeVisible({ timeout: 10_000 })
})
test('Cmd+P opens quick open palette @smoke', async ({ page }) => {
await page.locator('body').click()
await sendShortcut(page, 'p', ['Control'])
await expect(
page.locator('input[placeholder="Search notes..."]'),
).toBeVisible()
})
test('Escape closes command palette after Cmd+K', async ({ page }) => {
await openCommandPalette(page)
await page.keyboard.press('Escape')
await expect(
page.locator('input[placeholder="Type a command..."]'),
).not.toBeVisible()
})
})