From 698bcde00bc332fd40b2ecdf85dc950afd373933 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Fri, 15 May 2026 13:10:44 +0300 Subject: [PATCH] refactor(vue): share generated test id helpers --- packages/vue/src/index.ts | 10 +++++++++- packages/vue/src/testing/test-id.ts | 20 ++++++++++++++++++++ src/components/Toolbar/ToolFlyout.vue | 14 ++++++++++---- src/components/VariablesDialog.vue | 4 ++-- src/components/chat/AcpPermissionDialog.vue | 6 +++--- tests/e2e/toolbar/basic.spec.ts | 17 +++++++++-------- tests/e2e/variables/dialog.spec.ts | 7 ++++--- tests/helpers/test-ids.ts | 11 +++++++++++ 8 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 tests/helpers/test-ids.ts diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts index 549b1dbf8..39e8f4736 100644 --- a/packages/vue/src/index.ts +++ b/packages/vue/src/index.ts @@ -47,7 +47,15 @@ export { useToolbarState } from '#vue/primitives/Toolbar/useToolbarState' export { useNodeFontStatus } from '#vue/shared/font-status/use' export { usePropScrub } from '#vue/controls/prop-scrub/use' export { toolCursor } from '#vue/editor/tool-cursor' -export { testId, testIdSelector } from '#vue/testing/test-id' +export { + acpPermissionOptionTestId, + testId, + testIdSelector, + toolbarFlyoutItemTestId, + toolbarFlyoutTestId, + toolbarToolTestId, + variablesAddTestId +} from '#vue/testing/test-id' export { vTestId } from '#vue/testing/v-test-id' export type { RequiredTestIdProps, diff --git a/packages/vue/src/testing/test-id.ts b/packages/vue/src/testing/test-id.ts index 60e0273d0..3334ad709 100644 --- a/packages/vue/src/testing/test-id.ts +++ b/packages/vue/src/testing/test-id.ts @@ -22,6 +22,26 @@ export function testIdSelector(id: TestId): string { return `[data-test-id="${cssEscape(id)}"]` } +export function toolbarToolTestId(tool: string, mobile = false): TestId { + return `${mobile ? 'mobile-' : ''}toolbar-tool-${tool.toLowerCase()}` +} + +export function toolbarFlyoutTestId(tool: string, mobile = false): TestId { + return `${mobile ? 'mobile-' : ''}toolbar-flyout-${tool.toLowerCase()}` +} + +export function toolbarFlyoutItemTestId(tool: string, mobile = false): TestId { + return `${mobile ? 'mobile-' : ''}toolbar-flyout-item-${tool.toLowerCase()}` +} + +export function variablesAddTestId(type: string): TestId { + return `variables-add-${type.toLowerCase()}` +} + +export function acpPermissionOptionTestId(kind: string): TestId { + return `acp-permission-option-${kind}` +} + function cssEscape(value: string): string { return CSS.escape(value) } diff --git a/src/components/Toolbar/ToolFlyout.vue b/src/components/Toolbar/ToolFlyout.vue index 4051ce223..a6e176ae8 100644 --- a/src/components/Toolbar/ToolFlyout.vue +++ b/src/components/Toolbar/ToolFlyout.vue @@ -11,7 +11,13 @@ import IconChevronDown from '~icons/lucide/chevron-down' import { menu } from '@/components/ui/menu' import ToolButton from '@/components/Toolbar/ToolButton.vue' -import { vTestId, ToolbarItem } from '@open-pencil/vue' +import { + toolbarFlyoutItemTestId, + toolbarFlyoutTestId, + toolbarToolTestId, + vTestId, + ToolbarItem +} from '@open-pencil/vue' import type { Tool } from '@open-pencil/vue' import type { EditorToolDef } from '@open-pencil/core/editor' @@ -58,7 +64,7 @@ function activeKeyForTool() {