From 7389737e58f4c27d9323b636b0911d8690a0efc0 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Wed, 27 Nov 2024 12:59:48 +0200 Subject: [PATCH] test: adjust tooltip tests --- .../render-types/parts/CanvasNodeTooltip.test.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/editor-ui/src/components/canvas/elements/nodes/render-types/parts/CanvasNodeTooltip.test.ts b/packages/editor-ui/src/components/canvas/elements/nodes/render-types/parts/CanvasNodeTooltip.test.ts index b97064a1bd1ee..65c251439baa0 100644 --- a/packages/editor-ui/src/components/canvas/elements/nodes/render-types/parts/CanvasNodeTooltip.test.ts +++ b/packages/editor-ui/src/components/canvas/elements/nodes/render-types/parts/CanvasNodeTooltip.test.ts @@ -2,13 +2,14 @@ import CanvasNodeTooltip from './CanvasNodeTooltip.vue'; import { createComponentRenderer } from '@/__tests__/render'; import type { CanvasNodeDefaultRender } from '@/types'; import { createCanvasNodeProvide } from '@/__tests__/data'; +import { waitFor } from '@testing-library/vue'; const renderComponent = createComponentRenderer(CanvasNodeTooltip); describe('CanvasNodeTooltip', () => { describe('rendering', () => { - it('should render tooltip when tooltip option is provided', () => { - const { getByText } = renderComponent({ + it('should render tooltip when tooltip option is provided', async () => { + const { container, getByText } = renderComponent({ props: { visible: true, }, @@ -26,25 +27,28 @@ describe('CanvasNodeTooltip', () => { }); expect(getByText('Test tooltip text')).toBeInTheDocument(); + await waitFor(() => expect(container.querySelector('.el-popper')).toBeVisible()); }); it('should not render tooltip when tooltip option is not provided', () => { const { container } = renderComponent({ props: { - visible: true, + visible: false, }, global: { provide: createCanvasNodeProvide({ data: { render: { - options: {}, + options: { + tooltip: 'Test tooltip text', + }, } as CanvasNodeDefaultRender, }, }), }, }); - expect(container.querySelector('.tooltipTrigger')).not.toBeInTheDocument(); + expect(container.querySelector('.el-popper')).not.toBeVisible(); }); }); });