test: refresh smoke selectors for toolbar actions

This commit is contained in:
lucaronin
2026-04-17 02:49:51 +02:00
parent 22cefe4912
commit 4e7069174e
4 changed files with 41 additions and 40 deletions

View File

@@ -3,8 +3,8 @@ import { createFixtureVaultCopy, openFixtureVault, removeFixtureVaultCopy } from
let tempVaultDir: string
async function expectIconSize(pageTitle: string, page: Page) {
const icon = page.locator(`button[title="${pageTitle}"] svg`)
async function expectIconSize(buttonName: string, page: Page) {
const icon = page.getByRole('button', { name: buttonName }).locator('svg')
await expect(icon).toBeVisible({ timeout: 5_000 })
const box = await icon.boundingBox()
expect(box?.width).toBeGreaterThanOrEqual(15)
@@ -39,9 +39,9 @@ test.describe('Breadcrumb action icon size regression', () => {
await expect(page.locator('.breadcrumb-bar')).toBeVisible({ timeout: 5_000 })
await expectIconSize('Search in file', page)
await expectIconSize('Raw editor', page)
await expectIconSize('Open AI Chat', page)
await expectIconSize('Archive', page)
await expectIconSize('Search within this note', page)
await expectIconSize('Open the raw editor', page)
await expectIconSize('Open the AI panel', page)
await expectIconSize('Archive this note', page)
})
})

View File

@@ -16,8 +16,8 @@ test.describe('AI chat empty body fix — no regression', () => {
const editor = page.locator('.bn-editor')
await expect(editor).toBeVisible({ timeout: 3000 })
// Open AI Chat from the editor toolbar
await page.getByTitle('Open AI Chat').click()
// Open the AI panel from the editor toolbar
await page.getByRole('button', { name: 'Open the AI panel' }).click()
await expect(page.getByTestId('ai-panel')).toBeVisible({ timeout: 3000 })
// Send a message

View File

@@ -14,7 +14,7 @@ test.describe('Inline wikilink editor regression', () => {
await page.locator('.app__note-list .cursor-pointer').first().click()
await expect(page.locator('.bn-editor')).toBeVisible({ timeout: 3_000 })
await page.getByTitle('Open AI Chat').click()
await page.getByRole('button', { name: 'Open the AI panel' }).click()
await expect(page.getByTestId('ai-panel')).toBeVisible({ timeout: 3_000 })
})

View File

@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test'
import { test, expect, type Page } from '@playwright/test'
import { APP_COMMAND_IDS } from '../../src/hooks/appCommandCatalog'
import {
dispatchShortcutEvent,
@@ -13,6 +13,23 @@ import {
let tempVaultDir: string
async function openAlphaProjectInEditor(page: Page) {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
}
async function expectPropertiesPanelToggle(page: Page, toggle: () => Promise<void>) {
const propertiesButton = page.getByRole('button', { name: 'Open the properties panel' })
await expect(propertiesButton).toBeVisible({ timeout: 5_000 })
await toggle()
await expect(propertiesButton).toHaveCount(0)
await toggle()
await expect(page.getByRole('button', { name: 'Open the properties panel' })).toBeVisible({ timeout: 5_000 })
}
test.describe('keyboard command routing', () => {
test.beforeEach(() => {
tempVaultDir = createFixtureVaultCopy()
@@ -34,47 +51,33 @@ test.describe('keyboard command routing', () => {
})
test('desktop menu-command bridge toggles the properties panel through the shared command path @smoke', async ({ page }) => {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
await triggerMenuCommand(page, APP_COMMAND_IDS.viewToggleProperties)
await expect(page.getByTitle('Close Properties (⌘⇧I)')).toBeVisible({ timeout: 5_000 })
await triggerMenuCommand(page, APP_COMMAND_IDS.viewToggleProperties)
await expect(page.getByTitle('Properties (⌘⇧I)')).toBeVisible({ timeout: 5_000 })
await openAlphaProjectInEditor(page)
await expectPropertiesPanelToggle(page, async () => {
await triggerMenuCommand(page, APP_COMMAND_IDS.viewToggleProperties)
})
})
test('desktop keyboard shortcut toggles the properties panel through the renderer shortcut path @smoke', async ({ page }) => {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
await page.keyboard.press(process.platform === 'darwin' ? 'Meta+Shift+I' : 'Control+Shift+I')
await expect(page.getByTitle('Close Properties (⌘⇧I)')).toBeVisible({ timeout: 5_000 })
await page.keyboard.press(process.platform === 'darwin' ? 'Meta+Shift+I' : 'Control+Shift+I')
await expect(page.getByTitle('Properties (⌘⇧I)')).toBeVisible({ timeout: 5_000 })
await openAlphaProjectInEditor(page)
await expectPropertiesPanelToggle(page, async () => {
await page.keyboard.press(process.platform === 'darwin' ? 'Meta+Shift+I' : 'Control+Shift+I')
})
})
test('desktop menu-command bridge toggles organized state through the shared command path @smoke', async ({ page }) => {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
await openAlphaProjectInEditor(page)
await expect(page.getByTitle('Mark as organized (remove from Inbox) (Cmd+E)')).toBeVisible({ timeout: 5_000 })
await expect(page.getByRole('button', { name: 'Set note as organized' })).toBeVisible({ timeout: 5_000 })
await triggerMenuCommand(page, APP_COMMAND_IDS.noteToggleOrganized)
await expect(page.getByTitle('Mark as unorganized (back to Inbox) (Cmd+E)')).toBeVisible({ timeout: 5_000 })
await expect(page.getByRole('button', { name: 'Set note as not organized' })).toBeVisible({ timeout: 5_000 })
await triggerMenuCommand(page, APP_COMMAND_IDS.noteToggleOrganized)
await expect(page.getByTitle('Mark as organized (remove from Inbox) (Cmd+E)')).toBeVisible({ timeout: 5_000 })
await expect(page.getByRole('button', { name: 'Set note as organized' })).toBeVisible({ timeout: 5_000 })
})
test('renderer shortcut bridge toggles the raw editor through the shared keyboard handler @smoke', async ({ page }) => {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
await openAlphaProjectInEditor(page)
await triggerShortcutCommand(page, APP_COMMAND_IDS.editToggleRawEditor)
await expect(page.getByTestId('raw-editor-codemirror')).toBeVisible({ timeout: 5_000 })
@@ -85,9 +88,7 @@ test.describe('keyboard command routing', () => {
})
test('desktop menu-command bridge toggles the AI panel, while the wrong modifier event does not @smoke', async ({ page }) => {
await openFixtureVaultDesktopHarness(page, tempVaultDir)
await page.getByText('Alpha Project', { exact: true }).first().click()
await page.locator('.bn-editor').click()
await openAlphaProjectInEditor(page)
await dispatchShortcutEvent(page, {
key: 'l',