From a0ddaed6d3c02069b83f154c35c2492204374d6c Mon Sep 17 00:00:00 2001 From: akashseth-ifp Date: Tue, 24 Feb 2026 10:31:30 +0530 Subject: [PATCH] test(web): Fix failing web test in 'Web Tests' GitHub Action (#32481) --- .../app/configuration/config-var/index.spec.tsx | 5 +++-- .../components/app/overview/customize/index.spec.tsx | 10 ++-------- .../create/__tests__/common-modal.spec.tsx | 7 ++----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/web/app/components/app/configuration/config-var/index.spec.tsx b/web/app/components/app/configuration/config-var/index.spec.tsx index 490d7b4410..096358c805 100644 --- a/web/app/components/app/configuration/config-var/index.spec.tsx +++ b/web/app/components/app/configuration/config-var/index.spec.tsx @@ -2,7 +2,7 @@ import type { ReactNode } from 'react' import type { IConfigVarProps } from './index' import type { ExternalDataTool } from '@/models/common' import type { PromptVariable } from '@/models/debug' -import { act, fireEvent, render, screen, waitFor } from '@testing-library/react' +import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react' import * as React from 'react' import { vi } from 'vitest' import Toast from '@/app/components/base/toast' @@ -237,7 +237,8 @@ describe('ConfigVar', () => { expect(actionButtons).toHaveLength(2) fireEvent.click(actionButtons[0]) - const saveButton = await screen.findByRole('button', { name: 'common.operation.save' }) + const editDialog = await screen.findByRole('dialog') + const saveButton = within(editDialog).getByRole('button', { name: 'common.operation.save' }) fireEvent.click(saveButton) await waitFor(() => { diff --git a/web/app/components/app/overview/customize/index.spec.tsx b/web/app/components/app/overview/customize/index.spec.tsx index e1bb7e938d..fab78347d0 100644 --- a/web/app/components/app/overview/customize/index.spec.tsx +++ b/web/app/components/app/overview/customize/index.spec.tsx @@ -323,14 +323,8 @@ describe('CustomizeModal', () => { expect(screen.getByText('appOverview.overview.appInfo.customize.title')).toBeInTheDocument() }) - // Find the close button by navigating from the heading to the close icon - // The close icon is an SVG inside a sibling div of the title - const heading = screen.getByRole('heading', { name: /customize\.title/i }) - const closeIcon = heading.parentElement!.querySelector('svg') - - // Assert - closeIcon must exist for the test to be valid - expect(closeIcon).toBeInTheDocument() - fireEvent.click(closeIcon!) + const closeButton = screen.getByTestId('modal-close-button') + fireEvent.click(closeButton) expect(onClose).toHaveBeenCalledTimes(1) }) }) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/common-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/common-modal.spec.tsx index 20eac10903..b9953bd249 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/common-modal.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/common-modal.spec.tsx @@ -714,6 +714,7 @@ describe('CommonCreateModal', () => { describe('Manual Properties Change', () => { it('should call updateBuilder when manual properties change', async () => { + const builder = createMockSubscriptionBuilder() const detailWithManualSchema = createMockPluginDetail({ declaration: { trigger: { @@ -729,11 +730,7 @@ describe('CommonCreateModal', () => { }) mockUsePluginStore.mockReturnValue(detailWithManualSchema) - render() - - await waitFor(() => { - expect(mockCreateBuilder).toHaveBeenCalled() - }) + render() const input = screen.getByTestId('form-field-webhook_url') fireEvent.change(input, { target: { value: 'https://example.com/webhook' } })