diff --git a/web/__tests__/plugins/plugin-install-flow.test.ts b/web/__tests__/plugins/plugin-install-flow.test.ts index 8edb6705d4..8fa2246198 100644 --- a/web/__tests__/plugins/plugin-install-flow.test.ts +++ b/web/__tests__/plugins/plugin-install-flow.test.ts @@ -12,8 +12,16 @@ vi.mock('@/config', () => ({ })) const mockToastNotify = vi.fn() -vi.mock('@/app/components/base/toast', () => ({ - default: { notify: (...args: unknown[]) => mockToastNotify(...args) }, +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign((message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }), })) const mockUploadGitHub = vi.fn() diff --git a/web/app/components/plugins/install-plugin/hooks.ts b/web/app/components/plugins/install-plugin/hooks.ts index 2c3ba48ec3..cc7148cc17 100644 --- a/web/app/components/plugins/install-plugin/hooks.ts +++ b/web/app/components/plugins/install-plugin/hooks.ts @@ -36,10 +36,10 @@ export const useGitHubReleases = () => { } catch (error) { if (error instanceof Error) { - toast.error(error.message,) + toast.error(error.message) } else { - toast.error('Failed to fetch repository releases',) + toast.error('Failed to fetch repository releases') } return [] } @@ -92,7 +92,7 @@ export const useGitHubUpload = () => { return GitHubPackage } catch (error) { - toast.error('Error uploading package',) + toast.error('Error uploading package') throw error } } diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx index afa0e8eb98..ff51698478 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx @@ -7,8 +7,8 @@ import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import Modal from '@/app/components/base/modal' -import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' import { toast } from '@/app/components/base/ui/toast' +import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' import { cn } from '@/utils/classnames' import { InstallStepFromGitHub } from '../../types' import Installed from '../base/installed' @@ -166,10 +166,10 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on >
-
+
{getTitle()}
-
+
{!([InstallStepFromGitHub.uploadFailed, InstallStepFromGitHub.installed, InstallStepFromGitHub.installFailed].includes(state.step)) && t('installFromGitHub.installNote', { ns: 'plugin' })}
diff --git a/web/app/components/plugins/plugin-detail-panel/__tests__/detail-header.spec.tsx b/web/app/components/plugins/plugin-detail-panel/__tests__/detail-header.spec.tsx index 1c7166b5f5..f8d6488128 100644 --- a/web/app/components/plugins/plugin-detail-panel/__tests__/detail-header.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/__tests__/detail-header.spec.tsx @@ -2,7 +2,6 @@ import type { PluginDetail } from '../../types' import { fireEvent, render, screen, waitFor } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' import * as amplitude from '@/app/components/base/amplitude' -import { toast } from '@/app/components/base/ui/toast' import { PluginSource } from '../../types' import DetailHeader from '../detail-header' diff --git a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-card.spec.tsx b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-card.spec.tsx index e50c5b35d2..237c72adf0 100644 --- a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-card.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-card.spec.tsx @@ -1,7 +1,6 @@ import type { EndpointListItem, PluginDetail } from '../../types' import { act, fireEvent, render, screen } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' import EndpointCard from '../endpoint-card' const mockHandleChange = vi.fn() @@ -9,6 +8,22 @@ const mockEnableEndpoint = vi.fn() const mockDisableEndpoint = vi.fn() const mockDeleteEndpoint = vi.fn() const mockUpdateEndpoint = vi.fn() +const mockToastNotify = vi.fn() + +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), +})) // Flags to control whether operations should fail const failureFlags = { @@ -127,8 +142,6 @@ describe('EndpointCard', () => { failureFlags.disable = false failureFlags.delete = false failureFlags.update = false - // Mock notifyToast to prevent toast elements from accumulating in DOM - vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) // Polyfill document.execCommand for copy-to-clipboard in jsdom if (typeof document.execCommand !== 'function') { document.execCommand = vi.fn().mockReturnValue(true) diff --git a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-modal.spec.tsx index 47504f666b..a467de7142 100644 --- a/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-modal.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/__tests__/endpoint-modal.spec.tsx @@ -2,9 +2,25 @@ import type { FormSchema } from '../../../base/form/types' import type { PluginDetail } from '../../types' import { fireEvent, render, screen } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' import EndpointModal from '../endpoint-modal' +const mockToastNotify = vi.fn() + +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), +})) + vi.mock('@/hooks/use-i18n', () => ({ useRenderI18nObject: () => (obj: Record | string) => typeof obj === 'string' ? obj : obj?.en_US || '', @@ -69,11 +85,9 @@ const mockPluginDetail: PluginDetail = { describe('EndpointModal', () => { const mockOnCancel = vi.fn() const mockOnSaved = vi.fn() - let mockToastNotify: ReturnType beforeEach(() => { vi.clearAllMocks() - mockToastNotify = vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) }) describe('Rendering', () => { diff --git a/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/__tests__/use-plugin-operations.spec.ts b/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/__tests__/use-plugin-operations.spec.ts index deb3b7b80e..77d41c5bce 100644 --- a/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/__tests__/use-plugin-operations.spec.ts +++ b/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/__tests__/use-plugin-operations.spec.ts @@ -3,7 +3,6 @@ import type { ModalStates, VersionTarget } from '../use-detail-header-state' import { act, renderHook } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' import * as amplitude from '@/app/components/base/amplitude' -import { toast } from '@/app/components/base/ui/toast' import { PluginSource } from '../../../../types' import { usePluginOperations } from '../use-plugin-operations' @@ -20,6 +19,7 @@ const { mockUninstallPlugin, mockFetchReleases, mockCheckForUpdates, + mockToastNotify, } = vi.hoisted(() => { return { mockSetShowUpdatePluginModal: vi.fn(), @@ -29,9 +29,25 @@ const { mockUninstallPlugin: vi.fn(() => Promise.resolve({ success: true })), mockFetchReleases: vi.fn(() => Promise.resolve([{ tag_name: 'v2.0.0' }])), mockCheckForUpdates: vi.fn(() => ({ needUpdate: true, toastProps: { type: 'success', message: 'Update available' } })), + mockToastNotify: vi.fn(), } }) +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), +})) + vi.mock('@/context/modal-context', () => ({ useModalContext: () => ({ setShowUpdatePluginModal: mockSetShowUpdatePluginModal, @@ -124,7 +140,6 @@ describe('usePluginOperations', () => { modalStates = createModalStatesMock() versionPicker = createVersionPickerMock() mockOnUpdate = vi.fn() - vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) vi.spyOn(amplitude, 'trackEvent').mockImplementation(() => {}) }) @@ -233,7 +248,7 @@ describe('usePluginOperations', () => { }) expect(mockCheckForUpdates).toHaveBeenCalled() - expect(notifyToast).toHaveBeenCalled() + expect(mockToastNotify).toHaveBeenCalledWith({ type: 'success', message: 'Update available' }) }) it('should show update plugin modal when update is needed', async () => { diff --git a/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/use-plugin-operations.ts b/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/use-plugin-operations.ts index 26a5bdabb5..ade47cec5f 100644 --- a/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/use-plugin-operations.ts +++ b/web/app/components/plugins/plugin-detail-panel/detail-header/hooks/use-plugin-operations.ts @@ -60,7 +60,7 @@ export const usePluginOperations = ({ } if (!meta?.repo || !meta?.version || !meta?.package) { - toast.error('Missing plugin metadata for GitHub update',) + toast.error('Missing plugin metadata for GitHub update') return } diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx index 6a94f4a41a..9f95d9c7e1 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx @@ -10,8 +10,8 @@ import Confirm from '@/app/components/base/confirm' import { CopyCheck } from '@/app/components/base/icons/src/vender/line/files' import Switch from '@/app/components/base/switch' import Tooltip from '@/app/components/base/tooltip' -import Indicator from '@/app/components/header/indicator' import { toast } from '@/app/components/base/ui/toast' +import Indicator from '@/app/components/header/indicator' import { addDefaultValue, toolCredentialToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import { useDeleteEndpoint, @@ -47,7 +47,7 @@ const EndpointCard = ({ await handleChange() }, onError: () => { - toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common') }) + toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common' })) setActive(false) }, }) @@ -57,7 +57,7 @@ const EndpointCard = ({ hideDisableConfirm() }, onError: () => { - toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common') }) + toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common' })) setActive(false) }, }) @@ -83,7 +83,7 @@ const EndpointCard = ({ hideDeleteConfirm() }, onError: () => { - toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common') }) + toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common' })) }, }) @@ -108,7 +108,7 @@ const EndpointCard = ({ hideEndpointModalConfirm() }, onError: () => { - toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common') }) + toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common' })) }, }) const handleUpdate = (state: Record) => updateEndpoint({ @@ -139,7 +139,7 @@ const EndpointCard = ({
-
+
{data.name}
@@ -154,8 +154,8 @@ const EndpointCard = ({
{data.declaration.endpoints.filter(endpoint => !endpoint.hidden).map((endpoint, index) => (
-
{endpoint.method}
-
+
{endpoint.method}
+
{`${data.url}${endpoint.path}`}
handleCopy(`${data.url}${endpoint.path}`)}> @@ -168,13 +168,13 @@ const EndpointCard = ({
{active && ( -
+
{t('detailPanel.serviceOk', { ns: 'plugin' })}
)} {!active && ( -
+
{t('detailPanel.disabled', { ns: 'plugin' })}
diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx index d322ac71fc..366139d12d 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx @@ -50,7 +50,7 @@ const EndpointList = ({ detail }: Props) => { hideEndpointModal() }, onError: () => { - toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common') }) + toast.error(t('actionMsg.modifiedUnsuccessfully', { ns: 'common' })) }, }) @@ -64,7 +64,7 @@ const EndpointList = ({ detail }: Props) => { return (
-
+
{t('detailPanel.endpoints', { ns: 'plugin' })} {
-
{t('detailPanel.endpointsTip', { ns: 'plugin' })}
+
{t('detailPanel.endpointsTip', { ns: 'plugin' })}
-
+
{t('detailPanel.endpointsDocLink', { ns: 'plugin' })}
@@ -95,7 +95,7 @@ const EndpointList = ({ detail }: Props) => {
{data.endpoints.length === 0 && ( -
{t('detailPanel.endpointsEmpty', { ns: 'plugin' })}
+
{t('detailPanel.endpointsEmpty', { ns: 'plugin' })}
)}
{data.endpoints.map((item, index) => ( diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx index 3f01a41dd5..4d93e14c8b 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx @@ -8,8 +8,8 @@ import { useTranslation } from 'react-i18next' import ActionButton from '@/app/components/base/action-button' import Button from '@/app/components/base/button' import Drawer from '@/app/components/base/drawer' -import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { toast } from '@/app/components/base/ui/toast' +import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { useRenderI18nObject } from '@/hooks/use-i18n' import { cn } from '@/utils/classnames' import { ReadmeEntrance } from '../readme-panel/entrance' @@ -48,7 +48,10 @@ const EndpointModal: FC = ({ const handleSave = () => { for (const field of formSchemas) { if (field.required && !tempCredential[field.name]) { - toast.error(t('errorMsg.fieldRequired', { ns: 'common', field: typeof field.label === 'string' ? field.label : getValueFromI18nObject(field.label as Record)) }) + toast.error(t('errorMsg.fieldRequired', { + ns: 'common', + field: typeof field.label === 'string' ? field.label : getValueFromI18nObject(field.label as Record), + })) return } } @@ -83,12 +86,12 @@ const EndpointModal: FC = ({ <>
-
{t('detailPanel.endpointModalTitle', { ns: 'plugin' })}
+
{t('detailPanel.endpointModalTitle', { ns: 'plugin' })}
-
{t('detailPanel.endpointModalDesc', { ns: 'plugin' })}
+
{t('detailPanel.endpointModalDesc', { ns: 'plugin' })}
@@ -109,7 +112,7 @@ const EndpointModal: FC = ({ href={item.url} target="_blank" rel="noopener noreferrer" - className="body-xs-regular inline-flex items-center text-text-accent-secondary" + className="inline-flex items-center text-text-accent-secondary body-xs-regular" > {t('howToGet', { ns: 'tools' })} diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/__tests__/index.spec.tsx index 84494a4394..107d42ada2 100644 --- a/web/app/components/plugins/plugin-detail-panel/model-selector/__tests__/index.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/model-selector/__tests__/index.spec.tsx @@ -4,11 +4,26 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { ConfigurationMethodEnum, ModelStatusEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' // Import component after mocks -import { toast } from '@/app/components/base/ui/toast' import ModelParameterModal from '../index' // ==================== Mock Setup ==================== +const mockToastNotify = vi.fn() +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), +})) + // Mock provider context const mockProviderContextValue = { isAPIKeySet: true, @@ -53,8 +68,6 @@ vi.mock('@/utils/completion-params', () => ({ fetchAndMergeValidCompletionParams: (...args: unknown[]) => mockFetchAndMergeValidCompletionParams(...args), })) -const mockToastNotify = vi.spyOn(Toast, 'notify') - // Mock child components vi.mock('@/app/components/header/account-setting/model-provider-page/model-selector', () => ({ default: ({ defaultModel, modelList, scopeFeatures, onSelect }: { @@ -244,7 +257,6 @@ const setupModelLists = (config: { describe('ModelParameterModal', () => { beforeEach(() => { vi.clearAllMocks() - mockToastNotify.mockReturnValue({}) mockProviderContextValue.isAPIKeySet = true mockProviderContextValue.modelProviders = [] setupModelLists() @@ -865,9 +877,7 @@ describe('ModelParameterModal', () => { // Assert await waitFor(() => { - expect(notifyToast).toHaveBeenCalledWith( - expect.objectContaining({ type: 'warning' }), - ) + expect(mockToastNotify).toHaveBeenCalledWith(expect.objectContaining({ type: 'warning' })) }) }) @@ -892,9 +902,7 @@ describe('ModelParameterModal', () => { // Assert await waitFor(() => { - expect(notifyToast).toHaveBeenCalledWith( - expect.objectContaining({ type: 'error' }), - ) + expect(mockToastNotify).toHaveBeenCalledWith(expect.objectContaining({ type: 'error' })) }) }) }) diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx index 8db63d68e6..6838bcec43 100644 --- a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx @@ -15,6 +15,7 @@ import { PopoverContent, PopoverTrigger, } from '@/app/components/base/ui/popover' +import { toast } from '@/app/components/base/ui/toast' import { ModelStatusEnum, ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { useModelList, @@ -22,7 +23,6 @@ import { import AgentModelTrigger from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal/agent-model-trigger' import Trigger from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger' import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector' -import { toast } from '@/app/components/base/ui/toast' import { useProviderContext } from '@/context/provider-context' import { cn } from '@/utils/classnames' import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params' @@ -134,12 +134,11 @@ const ModelParameterModal: FC = ({ const keys = Object.keys(removedDetails || {}) if (keys.length) { - toast.warning(`${t('modelProvider.parametersInvalidRemoved', { ns: 'common')}: ${keys.map(k => `${k} (${removedDetails[k]})`).join(', ')}`, - }) + toast.warning(`${t('modelProvider.parametersInvalidRemoved', { ns: 'common' })}: ${keys.map(k => `${k} (${removedDetails[k]})`).join(', ')}`) } } catch { - toast.error(t('error', { ns: 'common') }) + toast.error(t('error', { ns: 'common' })) } } @@ -152,7 +151,8 @@ const ModelParameterModal: FC = ({ mode: targetModelItem?.model_properties.mode as string, completion_params: nextCompletionParams, } - : {})) + : {}), + }) } const handleLLMParamsChange = (newParams: FormValue) => { diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/log-viewer.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/log-viewer.spec.tsx index 2c0835d58d..351c1f9d2d 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/log-viewer.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/log-viewer.spec.tsx @@ -1,12 +1,26 @@ import type { TriggerLogEntity } from '@/app/components/workflow/block-selector/types' import { cleanup, fireEvent, render, screen } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' import LogViewer from '../log-viewer' const mockToastNotify = vi.fn() const mockWriteText = vi.fn() +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), +})) + vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', () => ({ default: ({ value }: { value: unknown }) => (
{JSON.stringify(value)}
@@ -57,10 +71,6 @@ beforeEach(() => { }, configurable: true, }) - vi.spyOn(Toast, 'notify').mockImplementation((args) => { - mockToastNotify(args) - return { clear: vi.fn() } - }) }) describe('LogViewer', () => { diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/selector-view.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/selector-view.spec.tsx index e9cd0b0c84..44cec53e28 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/selector-view.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/selector-view.spec.tsx @@ -1,7 +1,6 @@ import type { TriggerSubscription } from '@/app/components/workflow/block-selector/types' import { fireEvent, render, screen } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' import { TriggerCredentialTypeEnum } from '@/app/components/workflow/block-selector/types' import { SubscriptionSelectorView } from '../selector-view' @@ -26,6 +25,18 @@ vi.mock('@/service/use-triggers', () => ({ useDeleteTriggerSubscription: () => ({ mutate: mockDelete, isPending: false }), })) +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign(vi.fn(), { + success: vi.fn(), + error: vi.fn(), + warning: vi.fn(), + info: vi.fn(), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }), +})) + const createSubscription = (overrides: Partial = {}): TriggerSubscription => ({ id: 'sub-1', name: 'Subscription One', @@ -42,7 +53,6 @@ const createSubscription = (overrides: Partial = {}): Trigg beforeEach(() => { vi.clearAllMocks() mockSubscriptions = [createSubscription()] - vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) }) describe('SubscriptionSelectorView', () => { diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/subscription-card.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/subscription-card.spec.tsx index 3ffdfa8348..4665c921ca 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/subscription-card.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/__tests__/subscription-card.spec.tsx @@ -1,7 +1,6 @@ import type { TriggerSubscription } from '@/app/components/workflow/block-selector/types' import { fireEvent, render, screen } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' import { TriggerCredentialTypeEnum } from '@/app/components/workflow/block-selector/types' import SubscriptionCard from '../subscription-card' @@ -30,6 +29,18 @@ vi.mock('@/service/use-triggers', () => ({ useDeleteTriggerSubscription: () => ({ mutate: vi.fn(), isPending: false }), })) +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign(vi.fn(), { + success: vi.fn(), + error: vi.fn(), + warning: vi.fn(), + info: vi.fn(), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }), +})) + const createSubscription = (overrides: Partial = {}): TriggerSubscription => ({ id: 'sub-1', name: 'Subscription One', @@ -45,7 +56,6 @@ const createSubscription = (overrides: Partial = {}): Trigg beforeEach(() => { vi.clearAllMocks() - vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) }) describe('SubscriptionCard', () => { diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/index.spec.tsx index 004c291b44..a36c108160 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/index.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/index.spec.tsx @@ -2,8 +2,8 @@ import type { SimpleDetail } from '../../../store' import type { TriggerOAuthConfig, TriggerProviderApiEntity, TriggerSubscription, TriggerSubscriptionBuilder } from '@/app/components/workflow/block-selector/types' import { fireEvent, render, screen, waitFor } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { SupportedCreationMethods } from '@/app/components/plugins/types' import { toast } from '@/app/components/base/ui/toast' +import { SupportedCreationMethods } from '@/app/components/plugins/types' import { TriggerCredentialTypeEnum } from '@/app/components/workflow/block-selector/types' import { CreateButtonType, CreateSubscriptionButton, DEFAULT_METHOD } from '../index' diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/oauth-client.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/oauth-client.spec.tsx index 2030e49189..ce53bf5b9a 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/oauth-client.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/__tests__/oauth-client.spec.tsx @@ -87,9 +87,18 @@ vi.mock('@/hooks/use-oauth', () => ({ const mockToastNotify = vi.fn() vi.mock('@/app/components/base/ui/toast', () => ({ - default: { - notify: (params: unknown) => mockToastNotify(params), - }, + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), })) const mockClipboardWriteText = vi.fn() diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/__tests__/use-oauth-client-state.spec.ts b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/__tests__/use-oauth-client-state.spec.ts index 70500c5524..68864b0b80 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/__tests__/use-oauth-client-state.spec.ts +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/__tests__/use-oauth-client-state.spec.ts @@ -78,9 +78,18 @@ vi.mock('@/hooks/use-oauth', () => ({ const mockToastNotify = vi.fn() vi.mock('@/app/components/base/ui/toast', () => ({ - default: { - notify: (params: unknown) => mockToastNotify(params), - }, + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), })) // ============================================================================ diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts index 36925035a6..99c42f6fc5 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts @@ -7,8 +7,8 @@ import type { BuildTriggerSubscriptionPayload } from '@/service/use-triggers' import { debounce } from 'es-toolkit/compat' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { SupportedCreationMethods } from '@/app/components/plugins/types' import { toast } from '@/app/components/base/ui/toast' +import { SupportedCreationMethods } from '@/app/components/plugins/types' import { TriggerCredentialTypeEnum } from '@/app/components/workflow/block-selector/types' import { useBuildTriggerSubscription, @@ -154,7 +154,7 @@ export const useCommonModalState = ({ onError: async (error: unknown) => { const errorMessage = await parsePluginErrorMessage(error) || t('modal.errors.updateFailed', { ns: 'pluginTrigger' }) console.error('Failed to update subscription builder:', error) - toast.error(errorMessage,) + toast.error(errorMessage) }, }, ) @@ -233,7 +233,7 @@ export const useCommonModalState = ({ const handleVerify = useCallback(() => { // Guard against uninitialized state if (!detail?.provider || !subscriptionBuilder?.id) { - toast.error('Subscription builder not initialized',) + toast.error('Subscription builder not initialized') return } @@ -241,7 +241,7 @@ export const useCommonModalState = ({ const credentials = apiKeyCredentialsFormValues.values if (!Object.keys(credentials).length) { - toast.error('Please fill in all required credentials',) + toast.error('Please fill in all required credentials') return } @@ -275,7 +275,7 @@ export const useCommonModalState = ({ // Handle create const handleCreate = useCallback(() => { if (!subscriptionBuilder) { - toast.error('Subscription builder not found',) + toast.error('Subscription builder not found') return } @@ -315,7 +315,7 @@ export const useCommonModalState = ({ }, onError: async (error: unknown) => { const errorMessage = await parsePluginErrorMessage(error) || t('subscription.createFailed', { ns: 'pluginTrigger' }) - toast.error(errorMessage,) + toast.error(errorMessage) }, }, ) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts index 180a83ed11..e5a5ded9df 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts @@ -138,8 +138,7 @@ export const useOAuthClientState = ({ toast.success(t('modal.oauth.remove.success', { ns: 'pluginTrigger' })) }, onError: (error: unknown) => { - toast.error(getErrorMessage(error, t('modal.oauth.remove.failed', { ns: 'pluginTrigger' })), - }) + toast.error(getErrorMessage(error, t('modal.oauth.remove.failed', { ns: 'pluginTrigger' }))) }, }) }, [providerName, deleteOAuth, onClose, t]) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/index.spec.tsx index 982e795478..126d8e366d 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/index.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/__tests__/index.spec.tsx @@ -14,11 +14,11 @@ import { OAuthEditModal } from '../oauth-edit-modal' const mockToastNotify = vi.fn() vi.mock('@/app/components/base/ui/toast', () => ({ - toast: Object.assign((params: unknown) => mockToastNotify(params), { - success: (params: unknown) => mockToastNotify(params), - error: (params: unknown) => mockToastNotify(params), - warning: (params: unknown) => mockToastNotify(params), - info: (params: unknown) => mockToastNotify(params), + toast: Object.assign((message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), dismiss: vi.fn(), update: vi.fn(), promise: vi.fn(), diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx index b103ca9c1d..247beaa626 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx @@ -9,8 +9,8 @@ import { EncryptedBottom } from '@/app/components/base/encrypted-bottom' import { BaseForm } from '@/app/components/base/form/components/base' import { FormTypeEnum } from '@/app/components/base/form/types' import Modal from '@/app/components/base/modal/modal' -import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { toast } from '@/app/components/base/ui/toast' +import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { useUpdateTriggerSubscription, useVerifyTriggerSubscription } from '@/service/use-triggers' import { parsePluginErrorMessage } from '@/utils/error-parser' import { ReadmeShowType } from '../../../readme-panel/store' @@ -65,7 +65,7 @@ const StatusStep = ({ isActive, text, onClick, clickable }: { }) => { return (
{ const errorMessage = await parsePluginErrorMessage(error) || t('modal.apiKey.verify.error', { ns: 'pluginTrigger' }) - toast.error(errorMessage,) + toast.error(errorMessage) }, }, ) @@ -192,7 +192,7 @@ export const ApiKeyEditModal = ({ onClose, subscription, pluginDetail }: Props) }, onError: async (error: unknown) => { const errorMessage = await parsePluginErrorMessage(error) || t('subscription.list.item.actions.edit.error', { ns: 'pluginTrigger' }) - toast.error(errorMessage,) + toast.error(errorMessage) }, }, ) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/manual-edit-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/manual-edit-modal.tsx index 56b53b4325..e1741da8e7 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/manual-edit-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/manual-edit-modal.tsx @@ -8,8 +8,8 @@ import { useTranslation } from 'react-i18next' import { BaseForm } from '@/app/components/base/form/components/base' import { FormTypeEnum } from '@/app/components/base/form/types' import Modal from '@/app/components/base/modal/modal' -import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { toast } from '@/app/components/base/ui/toast' +import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { useUpdateTriggerSubscription } from '@/service/use-triggers' import { ReadmeShowType } from '../../../readme-panel/store' import { usePluginStore } from '../../store' @@ -99,8 +99,7 @@ export const ManualEditModal = ({ onClose, subscription, pluginDetail }: Props) onClose() }, onError: (error: unknown) => { - toast.error(getErrorMessage(error, t('subscription.list.item.actions.edit.error', { ns: 'pluginTrigger' })), - }) + toast.error(getErrorMessage(error, t('subscription.list.item.actions.edit.error', { ns: 'pluginTrigger' }))) }, }, ) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/oauth-edit-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/oauth-edit-modal.tsx index acadae14d1..c43a00a322 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/oauth-edit-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/oauth-edit-modal.tsx @@ -8,8 +8,8 @@ import { useTranslation } from 'react-i18next' import { BaseForm } from '@/app/components/base/form/components/base' import { FormTypeEnum } from '@/app/components/base/form/types' import Modal from '@/app/components/base/modal/modal' -import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { toast } from '@/app/components/base/ui/toast' +import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance' import { useUpdateTriggerSubscription } from '@/service/use-triggers' import { ReadmeShowType } from '../../../readme-panel/store' import { usePluginStore } from '../../store' @@ -99,8 +99,7 @@ export const OAuthEditModal = ({ onClose, subscription, pluginDetail }: Props) = onClose() }, onError: (error: unknown) => { - toast.error(getErrorMessage(error, t('subscription.list.item.actions.edit.error', { ns: 'pluginTrigger' })), - }) + toast.error(getErrorMessage(error, t('subscription.list.item.actions.edit.error', { ns: 'pluginTrigger' }))) }, }, ) diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/__tests__/index.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/__tests__/index.spec.tsx index f61420c990..537e99d733 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/__tests__/index.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/__tests__/index.spec.tsx @@ -299,11 +299,11 @@ vi.mock('@/app/components/header/account-setting/model-provider-page/model-modal // Mock Toast - need to track notify calls for assertions const mockToastNotify = vi.fn() vi.mock('@/app/components/base/ui/toast', () => ({ - toast: Object.assign((...args: unknown[]) => mockToastNotify(...args), { - success: (...args: unknown[]) => mockToastNotify(...args), - error: (...args: unknown[]) => mockToastNotify(...args), - warning: (...args: unknown[]) => mockToastNotify(...args), - info: (...args: unknown[]) => mockToastNotify(...args), + toast: Object.assign((message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), dismiss: vi.fn(), update: vi.fn(), promise: vi.fn(), diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx index edc6d8731c..e1b8ca86fe 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-credentials-form.spec.tsx @@ -11,11 +11,15 @@ vi.mock('@/utils/classnames', () => ({ })) vi.mock('@/app/components/base/ui/toast', () => ({ - default: { notify: vi.fn() }, -})) - -vi.mock('@/app/components/base/toast/context', () => ({ - useToastContext: () => ({ notify: vi.fn() }), + toast: Object.assign(vi.fn(), { + success: vi.fn(), + error: vi.fn(), + warning: vi.fn(), + info: vi.fn(), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }), })) const mockFormSchemas = [ diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-credentials-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-credentials-form.tsx index 8249131bb8..f4d39c9ec1 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-credentials-form.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-credentials-form.tsx @@ -10,8 +10,8 @@ import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import Loading from '@/app/components/base/loading' -import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { toast } from '@/app/components/base/ui/toast' +import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { addDefaultValue, toolCredentialToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import { useRenderI18nObject } from '@/hooks/use-i18n' import { fetchBuiltInToolCredential, fetchBuiltInToolCredentialSchema } from '@/service/tools' @@ -49,7 +49,10 @@ const ToolCredentialForm: FC = ({ return for (const field of credentialSchema) { if (field.required && !tempCredential[field.name]) { - toast.error(t('errorMsg.fieldRequired', { ns: 'common', field: getValueFromI18nObject(field.label)) }) + toast.error(t('errorMsg.fieldRequired', { + ns: 'common', + field: getValueFromI18nObject(field.label), + })) return } } diff --git a/web/app/components/plugins/plugin-item/__tests__/action.spec.tsx b/web/app/components/plugins/plugin-item/__tests__/action.spec.tsx index 1d31ccfc82..b4d21c9403 100644 --- a/web/app/components/plugins/plugin-item/__tests__/action.spec.tsx +++ b/web/app/components/plugins/plugin-item/__tests__/action.spec.tsx @@ -1,7 +1,6 @@ import type { MetaData, PluginCategoryEnum } from '../../types' import { fireEvent, render, screen, waitFor } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { toast } from '@/app/components/base/ui/toast' // ==================== Imports (after mocks) ==================== @@ -17,12 +16,29 @@ const { mockCheckForUpdates, mockSetShowUpdatePluginModal, mockInvalidateInstalledPluginList, + mockToastNotify, } = vi.hoisted(() => ({ mockUninstallPlugin: vi.fn(), mockFetchReleases: vi.fn(), mockCheckForUpdates: vi.fn(), mockSetShowUpdatePluginModal: vi.fn(), mockInvalidateInstalledPluginList: vi.fn(), + mockToastNotify: vi.fn(), +})) + +vi.mock('@/app/components/base/ui/toast', () => ({ + toast: Object.assign( + (message: string, options?: { type?: string }) => mockToastNotify({ type: options?.type, message }), + { + success: (message: string) => mockToastNotify({ type: 'success', message }), + error: (message: string) => mockToastNotify({ type: 'error', message }), + warning: (message: string) => mockToastNotify({ type: 'warning', message }), + info: (message: string) => mockToastNotify({ type: 'info', message }), + dismiss: vi.fn(), + update: vi.fn(), + promise: vi.fn(), + }, + ), })) // Mock uninstall plugin service @@ -140,13 +156,8 @@ const getActionButtons = () => screen.getAllByRole('button') const queryActionButtons = () => screen.queryAllByRole('button') describe('Action Component', () => { - // Spy on notifyToast - real component but we track calls - let toastNotifySpy: ReturnType - beforeEach(() => { vi.clearAllMocks() - // Spy on notifyToast and mock implementation to avoid DOM side effects - toastNotifySpy = vi.spyOn(Toast, 'notify').mockImplementation(() => ({ clear: vi.fn() })) mockUninstallPlugin.mockResolvedValue({ success: true }) mockFetchReleases.mockResolvedValue([]) mockCheckForUpdates.mockReturnValue({ @@ -155,10 +166,6 @@ describe('Action Component', () => { }) }) - afterEach(() => { - toastNotifySpy.mockRestore() - }) - // ==================== Rendering Tests ==================== describe('Rendering', () => { it('should render delete button when isShowDelete is true', () => { @@ -563,9 +570,9 @@ describe('Action Component', () => { render() fireEvent.click(getActionButtons()[0]) - // Assert - notifyToast is called with the toast props + // Assert - toast is called with the translated payload await waitFor(() => { - expect(toastNotifySpy).toHaveBeenCalledWith({ type: 'success', message: 'Already up to date' }) + expect(mockToastNotify).toHaveBeenCalledWith({ type: 'success', message: 'Already up to date' }) }) }) diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index 373a1f03f0..15257ab41d 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -5364,6 +5364,36 @@ "count": 1 } }, + "app/components/plugins/plugin-detail-panel/endpoint-card.tsx": { + "no-restricted-imports": { + "count": 2 + }, + "tailwindcss/enforce-consistent-class-order": { + "count": 5 + }, + "ts/no-explicit-any": { + "count": 2 + } + }, + "app/components/plugins/plugin-detail-panel/endpoint-list.tsx": { + "no-restricted-imports": { + "count": 1 + }, + "tailwindcss/enforce-consistent-class-order": { + "count": 4 + }, + "ts/no-explicit-any": { + "count": 2 + } + }, + "app/components/plugins/plugin-detail-panel/endpoint-modal.tsx": { + "tailwindcss/enforce-consistent-class-order": { + "count": 3 + }, + "ts/no-explicit-any": { + "count": 7 + } + }, "app/components/plugins/plugin-detail-panel/model-list.tsx": { "tailwindcss/enforce-consistent-class-order": { "count": 2 @@ -5372,6 +5402,11 @@ "count": 1 } }, + "app/components/plugins/plugin-detail-panel/model-selector/index.tsx": { + "ts/no-explicit-any": { + "count": 3 + } + }, "app/components/plugins/plugin-detail-panel/model-selector/llm-params-panel.tsx": { "tailwindcss/enforce-consistent-class-order": { "count": 1 @@ -5424,6 +5459,11 @@ "count": 1 } }, + "app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts": { + "erasable-syntax-only/enums": { + "count": 2 + } + }, "app/components/plugins/plugin-detail-panel/subscription-list/create/index.tsx": { "no-restricted-imports": { "count": 3 @@ -5453,6 +5493,16 @@ "count": 1 } }, + "app/components/plugins/plugin-detail-panel/subscription-list/edit/manual-edit-modal.tsx": { + "no-restricted-imports": { + "count": 1 + } + }, + "app/components/plugins/plugin-detail-panel/subscription-list/edit/oauth-edit-modal.tsx": { + "no-restricted-imports": { + "count": 1 + } + }, "app/components/plugins/plugin-detail-panel/subscription-list/index.tsx": { "react-refresh/only-export-components": { "count": 1