AI-native design editor. Open-source Figma alternative.
refactor(toolbar): reuse test id helpers
Danila Poyarkov692ddf9a3f10
diff --git a/src/components/Toolbar/DesktopToolbar.vue b/src/components/Toolbar/DesktopToolbar.vueindex 03dda3374..cdb9e87d0 100644--- a/src/components/Toolbar/DesktopToolbar.vue+++ b/src/components/Toolbar/DesktopToolbar.vue@@ -2,7 +2,7 @@import Tip from '@/components/ui/Tip.vue'import ToolButton from '@/components/Toolbar/ToolButton.vue'import ToolFlyout from '@/components/Toolbar/ToolFlyout.vue'-import { ToolbarItem } from '@open-pencil/vue'+import { toolbarToolTestId, ToolbarItem } from '@open-pencil/vue'import type { Tool } from '@open-pencil/vue'import type { EditorToolDef } from '@open-pencil/core/editor'@@ -55,7 +55,7 @@ function activeKeyForTool(tool: EditorToolDef) {<ToolbarItem v-else v-slot="{ active, actions }" :tool="tool.key"><Tip :label="`${toolLabels[tool.key]} (${tool.shortcut})`"><ToolButton- :test-id="`toolbar-tool-${tool.key.toLowerCase()}`"+ :test-id="toolbarToolTestId(tool.key)":icon="toolIcons[tool.key]":active="active || isActive(tool)"@click="actions.select"diff --git a/src/components/Toolbar/MobileToolbar.vue b/src/components/Toolbar/MobileToolbar.vueindex 4b72a193b..4fdc67e4d 100644--- a/src/components/Toolbar/MobileToolbar.vue+++ b/src/components/Toolbar/MobileToolbar.vue@@ -7,7 +7,7 @@ import IconChevronRight from '~icons/lucide/chevron-right'import ToolButton from '@/components/Toolbar/ToolButton.vue'import ToolFlyout from '@/components/Toolbar/ToolFlyout.vue'import ToolbarActionGroup from '@/components/Toolbar/ToolbarActionGroup.vue'-import { ToolbarItem } from '@open-pencil/vue'+import { toolbarToolTestId, ToolbarItem } from '@open-pencil/vue'import type { Tool } from '@open-pencil/vue'import type { EditorToolDef } from '@open-pencil/core/editor'@@ -118,7 +118,7 @@ function activeKeyForTool(tool: EditorToolDef) {<ToolbarItem v-else v-slot="{ active, actions }" :tool="tool.key"><ToolButtonmobile- :test-id="`mobile-toolbar-tool-${tool.key.toLowerCase()}`"+ :test-id="toolbarToolTestId(tool.key, true)":icon="toolIcons[tool.key]":active="active || activeKeyForTool(tool) === activeTool"@click="actions.select"diff --git a/tests/helpers/test-ids.ts b/tests/helpers/test-ids.tsindex 8e62ad7ee..c1aa4894d 100644--- a/tests/helpers/test-ids.ts+++ b/tests/helpers/test-ids.ts@@ -1,11 +1,6 @@-export function toolbarFlyoutTestId(tool: string, mobile = false) {- return `${mobile ? 'mobile-' : ''}toolbar-flyout-${tool.toLowerCase()}`-}--export function toolbarFlyoutItemTestId(tool: string, mobile = false) {- return `${mobile ? 'mobile-' : ''}toolbar-flyout-item-${tool.toLowerCase()}`-}--export function variablesAddTestId(type: string) {- return `variables-add-${type.toLowerCase()}`-}+export {+ toolbarFlyoutItemTestId,+ toolbarFlyoutTestId,+ toolbarToolTestId,+ variablesAddTestId+} from '#vue/testing/test-id'