diff --git a/web/app/components/app/configuration/base/warning-mask/cannot-query-dataset.spec.tsx b/web/app/components/app/configuration/base/warning-mask/cannot-query-dataset.spec.tsx new file mode 100644 index 0000000000..d625e9fb72 --- /dev/null +++ b/web/app/components/app/configuration/base/warning-mask/cannot-query-dataset.spec.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import CannotQueryDataset from './cannot-query-dataset' + +describe('CannotQueryDataset WarningMask', () => { + test('should render dataset warning copy and action button', () => { + const onConfirm = jest.fn() + render() + + expect(screen.getByText('appDebug.feature.dataSet.queryVariable.unableToQueryDataSet')).toBeInTheDocument() + expect(screen.getByText('appDebug.feature.dataSet.queryVariable.unableToQueryDataSetTip')).toBeInTheDocument() + expect(screen.getByRole('button', { name: 'appDebug.feature.dataSet.queryVariable.ok' })).toBeInTheDocument() + }) + + test('should invoke onConfirm when OK button clicked', () => { + const onConfirm = jest.fn() + render() + + fireEvent.click(screen.getByRole('button', { name: 'appDebug.feature.dataSet.queryVariable.ok' })) + expect(onConfirm).toHaveBeenCalledTimes(1) + }) +}) diff --git a/web/app/components/app/configuration/base/warning-mask/formatting-changed.spec.tsx b/web/app/components/app/configuration/base/warning-mask/formatting-changed.spec.tsx new file mode 100644 index 0000000000..a968bde272 --- /dev/null +++ b/web/app/components/app/configuration/base/warning-mask/formatting-changed.spec.tsx @@ -0,0 +1,39 @@ +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import FormattingChanged from './formatting-changed' + +describe('FormattingChanged WarningMask', () => { + test('should display translation text and both actions', () => { + const onConfirm = jest.fn() + const onCancel = jest.fn() + + render( + , + ) + + expect(screen.getByText('appDebug.formattingChangedTitle')).toBeInTheDocument() + expect(screen.getByText('appDebug.formattingChangedText')).toBeInTheDocument() + expect(screen.getByRole('button', { name: 'common.operation.cancel' })).toBeInTheDocument() + expect(screen.getByRole('button', { name: /common\.operation\.refresh/ })).toBeInTheDocument() + }) + + test('should call callbacks when buttons are clicked', () => { + const onConfirm = jest.fn() + const onCancel = jest.fn() + render( + , + ) + + fireEvent.click(screen.getByRole('button', { name: /common\.operation\.refresh/ })) + fireEvent.click(screen.getByRole('button', { name: 'common.operation.cancel' })) + + expect(onConfirm).toHaveBeenCalledTimes(1) + expect(onCancel).toHaveBeenCalledTimes(1) + }) +}) diff --git a/web/app/components/app/configuration/base/warning-mask/has-not-set-api.spec.tsx b/web/app/components/app/configuration/base/warning-mask/has-not-set-api.spec.tsx new file mode 100644 index 0000000000..46608374da --- /dev/null +++ b/web/app/components/app/configuration/base/warning-mask/has-not-set-api.spec.tsx @@ -0,0 +1,26 @@ +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import HasNotSetAPI from './has-not-set-api' + +describe('HasNotSetAPI WarningMask', () => { + test('should show default title when trial not finished', () => { + render() + + expect(screen.getByText('appDebug.notSetAPIKey.title')).toBeInTheDocument() + expect(screen.getByText('appDebug.notSetAPIKey.description')).toBeInTheDocument() + }) + + test('should show trail finished title when flag is true', () => { + render() + + expect(screen.getByText('appDebug.notSetAPIKey.trailFinished')).toBeInTheDocument() + }) + + test('should call onSetting when primary button clicked', () => { + const onSetting = jest.fn() + render() + + fireEvent.click(screen.getByRole('button', { name: 'appDebug.notSetAPIKey.settingBtn' })) + expect(onSetting).toHaveBeenCalledTimes(1) + }) +}) diff --git a/web/app/components/app/configuration/base/warning-mask/index.spec.tsx b/web/app/components/app/configuration/base/warning-mask/index.spec.tsx new file mode 100644 index 0000000000..6d533a423d --- /dev/null +++ b/web/app/components/app/configuration/base/warning-mask/index.spec.tsx @@ -0,0 +1,25 @@ +import React from 'react' +import { render, screen } from '@testing-library/react' +import WarningMask from './index' + +describe('WarningMask', () => { + // Rendering of title, description, and footer content + describe('Rendering', () => { + test('should display provided title, description, and footer node', () => { + const footer = + // Arrange + render( + , + ) + + // Assert + expect(screen.getByText('Access Restricted')).toBeInTheDocument() + expect(screen.getByText('Only workspace owners may modify this section.')).toBeInTheDocument() + expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument() + }) + }) +}) diff --git a/web/app/components/app/configuration/config-var/select-type-item/index.spec.tsx b/web/app/components/app/configuration/config-var/select-type-item/index.spec.tsx new file mode 100644 index 0000000000..469164e607 --- /dev/null +++ b/web/app/components/app/configuration/config-var/select-type-item/index.spec.tsx @@ -0,0 +1,45 @@ +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import SelectTypeItem from './index' +import { InputVarType } from '@/app/components/workflow/types' + +describe('SelectTypeItem', () => { + // Rendering pathways based on type and selection state + describe('Rendering', () => { + test('should render ok', () => { + // Arrange + const { container } = render( + , + ) + + // Assert + expect(screen.getByText('appDebug.variableConfig.text-input')).toBeInTheDocument() + expect(container.querySelector('svg')).not.toBeNull() + }) + }) + + // User interaction outcomes + describe('Interactions', () => { + test('should trigger onClick when item is pressed', () => { + const handleClick = jest.fn() + // Arrange + render( + , + ) + + // Act + fireEvent.click(screen.getByText('appDebug.variableConfig.paragraph')) + + // Assert + expect(handleClick).toHaveBeenCalledTimes(1) + }) + }) +})