From 10474f407d07f03235f15378d037238e148d442b Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Fri, 29 Sep 2023 16:52:03 +0100 Subject: [PATCH] Update eslint config to include JSX files By default eslint only processes files with `.js` extension. Add an override to include `.jsx` Run `npm run lint:fix` to address to issues that can be automatically resolved. Fix a11y bug with Task component keyboard nav that this highlighted. --- .eslintrc.cjs | 9 ++- .../DetailsHeader/DetailsHeader.jsx | 2 +- .../src/components/Loading/Loading.jsx | 2 +- .../src/components/Log/Log.test.jsx | 24 ++++-- .../components/PipelineRun/PipelineRun.jsx | 62 ++++++++------ .../components/src/components/Step/Step.jsx | 4 +- .../components/src/components/Task/Task.jsx | 81 ++++++++++++------- packages/graph/src/components/Graph/Graph.jsx | 2 +- .../ClusterInterceptors.test.jsx | 18 ++--- .../ClusterTasksDropdown.test.jsx | 24 +++--- .../ClusterTriggerBinding.test.jsx | 30 +++---- .../ClusterTriggerBindings.test.jsx | 26 +++--- .../CreateTaskRun/CreateTaskRun.test.jsx | 33 ++++---- .../EventListener/EventListener.test.jsx | 20 +++-- .../EventListeners/EventListeners.test.jsx | 32 +++++--- .../HeaderBarContent/HeaderBarContent.jsx | 3 +- .../HeaderBarContent.test.jsx | 22 +++-- .../ImportResources/ImportResources.test.jsx | 65 +++++++-------- .../Interceptors/Interceptors.test.jsx | 32 +++++--- .../NamespacesDropdown.test.jsx | 20 +++-- .../PipelineRun/PipelineRun.test.jsx | 25 +++--- .../PipelineRuns/PipelineRuns.test.jsx | 21 ++--- .../PipelinesDropdown.test.jsx | 25 +++--- .../ServiceAccountsDropdown.test.jsx | 43 +++++----- src/containers/Settings/Settings.test.jsx | 8 +- src/containers/SideNav/SideNav.test.jsx | 5 +- src/containers/TaskRuns/TaskRuns.test.jsx | 5 +- .../TasksDropdown/TasksDropdown.test.jsx | 19 +++-- src/containers/Trigger/Trigger.test.jsx | 5 +- .../TriggerBinding/TriggerBinding.test.jsx | 20 +++-- .../TriggerBindings/TriggerBindings.test.jsx | 32 +++++--- .../TriggerTemplate/TriggerTemplate.test.jsx | 30 ++++--- .../TriggerTemplates.test.jsx | 37 +++++---- src/containers/Triggers/Triggers.test.jsx | 10 ++- src/containers/YAMLEditor/YAMLEditor.jsx | 8 +- src/containers/YAMLEditor/YAMLEditor.test.jsx | 6 +- vite.config.js | 4 +- 37 files changed, 471 insertions(+), 343 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 013bbc544..87ae40525 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -13,7 +13,7 @@ limitations under the License. module.exports = { env: { browser: true, - es2021: true, + es2022: true, node: true }, extends: [ @@ -31,6 +31,9 @@ module.exports = { vi: true }, overrides: [ + { + files: ['*.js', '*.jsx'] + }, { files: ['*.cy.js'], rules: { @@ -42,7 +45,7 @@ module.exports = { ecmaFeatures: { jsx: true }, - ecmaVersion: 2021, + ecmaVersion: 2022, sourceType: 'module' }, plugins: ['notice', 'react', 'formatjs'], @@ -53,7 +56,7 @@ module.exports = { 'formatjs/enforce-default-message': 'error', 'formatjs/enforce-id': 'error', 'formatjs/no-complex-selectors': 'error', - 'formatjs/no-literal-string-in-jsx': 'error', + 'formatjs/no-literal-string-in-jsx': 'off', // TODO: [AG] re-enable this after cleanup 'formatjs/no-multiple-whitespaces': 'error', 'formatjs/no-multiple-plurals': 'error', 'import/named': 'off', diff --git a/packages/components/src/components/DetailsHeader/DetailsHeader.jsx b/packages/components/src/components/DetailsHeader/DetailsHeader.jsx index 3aa6e8765..7f047037f 100644 --- a/packages/components/src/components/DetailsHeader/DetailsHeader.jsx +++ b/packages/components/src/components/DetailsHeader/DetailsHeader.jsx @@ -28,7 +28,7 @@ class DetailsHeader extends Component { stepStatus.terminated || {}); } - if (!startTime || !endTime || new Date(startTime).getTime() == 0) { + if (!startTime || !endTime || new Date(startTime).getTime() === 0) { return null; } diff --git a/packages/components/src/components/Loading/Loading.jsx b/packages/components/src/components/Loading/Loading.jsx index c42f17e67..d98a0e2d0 100644 --- a/packages/components/src/components/Loading/Loading.jsx +++ b/packages/components/src/components/Loading/Loading.jsx @@ -32,4 +32,4 @@ export default function Loading({ message }) { {messageToDisplay} ); -}; +} diff --git a/packages/components/src/components/Log/Log.test.jsx b/packages/components/src/components/Log/Log.test.jsx index 2b1694855..b3a908eb2 100644 --- a/packages/components/src/components/Log/Log.test.jsx +++ b/packages/components/src/components/Log/Log.test.jsx @@ -123,8 +123,9 @@ describe('Log', () => { { length: 19999 }, (_v, i) => `Line ${i + 1}\n` ).join(''); - vi.spyOn(Element.prototype, 'getBoundingClientRect') - .mockReturnValue({ bottom: 0 }); + vi.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ + bottom: 0 + }); vi.spyOn(Element.prototype, 'scrollTop', 'get') .mockReturnValue(-1) // to ensure el.scrollHeight - el.clientHeight > el.scrollTop i.e. 0 - 0 > -1 .mockReturnValueOnce(0); @@ -154,8 +155,9 @@ describe('Log', () => { { length: 19999 }, (_v, i) => `Line ${i + 1}\n` ).join(''); - vi.spyOn(Element.prototype, 'getBoundingClientRect') - .mockReturnValue({ bottom: 0 }); + vi.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ + bottom: 0 + }); vi.spyOn(Element.prototype, 'scrollTop', 'get') .mockReturnValue(-1) // to ensure el.scrollHeight - el.clientHeight > el.scrollTop i.e. 0 - 0 > -1 .mockReturnValueOnce(0); @@ -185,8 +187,11 @@ describe('Log', () => { { length: 20000 }, (_v, i) => `Line ${i + 1}\n` ).join(''); - vi.spyOn(Element.prototype, 'getBoundingClientRect') - .mockReturnValue({ bottom: 0, top: 0, right: 0 }); + vi.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ + bottom: 0, + top: 0, + right: 0 + }); vi.spyOn(Element.prototype, 'scrollTop', 'get').mockReturnValue(1); const spiedFn = vi.spyOn(Element.prototype, 'scrollTop', 'set'); // the scrollTop value is changed in scrollToBottomLog @@ -211,8 +216,11 @@ describe('Log', () => { { length: 20000 }, (_v, i) => `Line ${i + 1}\n` ).join(''); - vi.spyOn(Element.prototype, 'getBoundingClientRect') - .mockReturnValue({ bottom: 0, top: 0, right: 0 }); + vi.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ + bottom: 0, + top: 0, + right: 0 + }); vi.spyOn(Element.prototype, 'scrollTop', 'get').mockReturnValue(1); vi.spyOn(Element.prototype, 'scrollHeight', 'get').mockReturnValue(2); const spiedFn = vi.spyOn(Element.prototype, 'scrollTop', 'set'); // the scrollTop value is changed in scrollToBottomLog diff --git a/packages/components/src/components/PipelineRun/PipelineRun.jsx b/packages/components/src/components/PipelineRun/PipelineRun.jsx index ed0102640..3d1ce2ab4 100644 --- a/packages/components/src/components/PipelineRun/PipelineRun.jsx +++ b/packages/components/src/components/PipelineRun/PipelineRun.jsx @@ -30,6 +30,16 @@ import StepDetails from '../StepDetails'; import TaskRunDetails from '../TaskRunDetails'; import TaskTree from '../TaskTree'; +function getPipelineTask({ pipelineRun, selectedTaskId, taskRun }) { + const memberOf = taskRun?.metadata?.labels?.[labelConstants.MEMBER_OF]; + const pipelineTask = ( + pipelineRun.spec?.pipelineSpec?.[memberOf] || + pipelineRun.status?.pipelineSpec?.[memberOf] + )?.find(task => task.name === selectedTaskId); + + return pipelineTask; +} + export /* istanbul ignore next */ class PipelineRunContainer extends Component { state = { isLogsMaximized: false @@ -112,16 +122,6 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { })); }; - getPipelineTask = ({ pipelineRun, selectedTaskId, taskRun }) => { - const memberOf = taskRun?.metadata?.labels?.[labelConstants.MEMBER_OF]; - const pipelineTask = ( - pipelineRun.spec?.pipelineSpec?.[memberOf] || - pipelineRun.status?.pipelineSpec?.[memberOf] - )?.find(task => task.name === selectedTaskId); - - return pipelineTask; - }; - loadTaskRuns = () => { const { pipelineRun } = this.props; if ( @@ -131,28 +131,36 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { return []; } - let { taskRuns } = this.props; + const { taskRuns } = this.props; return taskRuns || []; }; onTaskSelected = ({ - selectedRetry: retry, selectedStepId, selectedTaskId, taskRunName + selectedRetry: retry, + selectedStepId, + selectedTaskId, + taskRunName }) => { const { handleTaskSelected, pipelineRun } = this.props; const taskRuns = this.loadTaskRuns(); - let taskRun = taskRuns.find( - ({ metadata }) => - metadata.labels?.[labelConstants.PIPELINE_TASK] === selectedTaskId - ) || {}; + const taskRun = + taskRuns.find( + ({ metadata }) => + metadata.labels?.[labelConstants.PIPELINE_TASK] === selectedTaskId + ) || {}; - const pipelineTask = this.getPipelineTask({ pipelineRun, selectedTaskId, taskRun }); + const pipelineTask = getPipelineTask({ + pipelineRun, + selectedTaskId, + taskRun + }); handleTaskSelected({ selectedRetry: retry, selectedStepId, selectedTaskId, taskRunName: pipelineTask?.matrix ? taskRunName : undefined }); - } + }; render() { const { @@ -260,16 +268,20 @@ export /* istanbul ignore next */ class PipelineRunContainer extends Component { } const taskRuns = this.loadTaskRuns(); - let taskRun = taskRuns.find( - ({ metadata }) => - metadata.labels?.[labelConstants.PIPELINE_TASK] === selectedTaskId - ) || {}; + let taskRun = + taskRuns.find( + ({ metadata }) => + metadata.labels?.[labelConstants.PIPELINE_TASK] === selectedTaskId + ) || {}; - const pipelineTask = this.getPipelineTask({ pipelineRun, selectedTaskId, taskRun }); + const pipelineTask = getPipelineTask({ + pipelineRun, + selectedTaskId, + taskRun + }); if (pipelineTask?.matrix && selectedTaskRunName) { taskRun = taskRuns.find( - ({ metadata }) => - metadata.name === selectedTaskRunName + ({ metadata }) => metadata.name === selectedTaskRunName ); } diff --git a/packages/components/src/components/Step/Step.jsx b/packages/components/src/components/Step/Step.jsx index 80e09ea00..9a5fb2e6e 100644 --- a/packages/components/src/components/Step/Step.jsx +++ b/packages/components/src/components/Step/Step.jsx @@ -91,9 +91,9 @@ class Step extends Component { data-reason={reason} data-selected={selected || undefined} > - e.key === 'Enter' && this.handleClick(e)} > diff --git a/packages/components/src/components/Task/Task.jsx b/packages/components/src/components/Task/Task.jsx index 1c1e2ac68..185d7b385 100644 --- a/packages/components/src/components/Task/Task.jsx +++ b/packages/components/src/components/Task/Task.jsx @@ -137,18 +137,24 @@ class Task extends Component { }); if (selectedRetry === '0') { - retryName = intl.formatMessage({ - id: 'dashboard.pipelineRun.pipelineTaskName.firstAttempt', - defaultMessage: '{pipelineTaskName} (first attempt)' - }, { pipelineTaskName: displayName }); + retryName = intl.formatMessage( + { + id: 'dashboard.pipelineRun.pipelineTaskName.firstAttempt', + defaultMessage: '{pipelineTaskName} (first attempt)' + }, + { pipelineTaskName: displayName } + ); } else { - retryName = intl.formatMessage({ - id: 'dashboard.pipelineRun.pipelineTaskName.retry', - defaultMessage: '{pipelineTaskName} (retry {retryNumber, number})' - }, { - pipelineTaskName: displayName, - retryNumber: selectedRetry || taskRun.status.retriesStatus.length - }); + retryName = intl.formatMessage( + { + id: 'dashboard.pipelineRun.pipelineTaskName.retry', + defaultMessage: '{pipelineTaskName} (retry {retryNumber, number})' + }, + { + pipelineTaskName: displayName, + retryNumber: selectedRetry || taskRun.status.retriesStatus.length + } + ); } } @@ -161,8 +167,9 @@ class Task extends Component { data-succeeded={succeeded} data-selected={(expanded && !selectedStepId) || undefined} > - e.key === 'Enter' && this.handleTaskSelected(e)} @@ -173,34 +180,47 @@ class Task extends Component { reason={reason} status={succeeded} /> - {retryName || displayName} + + {retryName || displayName} + {expanded && taskRun.status?.retriesStatus ? ( - { - taskRun.status.retriesStatus.map((_retryStatus, index) => { + {taskRun.status.retriesStatus + .map((_retryStatus, index) => { return { id: index, - text: index === 0 ? - intl.formatMessage({ - id: 'dashboard.pipelineRun.retries.viewFirstAttempt', - defaultMessage: 'View first attempt' - }) : - intl.formatMessage({ - id: 'dashboard.pipelineRun.retries.viewRetry', - defaultMessage: 'View retry {retryNumber, number}' - }, { retryNumber: index }) + text: + index === 0 + ? intl.formatMessage({ + id: 'dashboard.pipelineRun.retries.viewFirstAttempt', + defaultMessage: 'View first attempt' + }) + : intl.formatMessage( + { + id: 'dashboard.pipelineRun.retries.viewRetry', + defaultMessage: 'View retry {retryNumber, number}' + }, + { retryNumber: index } + ) }; - }).concat([{ id: '', text: intl.formatMessage({ - id: 'dashboard.pipelineRun.retries.viewLatestRetry', - defaultMessage: 'View latest retry' - })}]).map(item => + }) + .concat([ + { + id: '', + text: intl.formatMessage({ + id: 'dashboard.pipelineRun.retries.viewLatestRetry', + defaultMessage: 'View latest retry' + }) + } + ]) + .map(item => ( onRetryChange(item.id)} requireTitle /> - ) - } + ))} ) : null} {expandIcon} diff --git a/packages/graph/src/components/Graph/Graph.jsx b/packages/graph/src/components/Graph/Graph.jsx index 2fbd424e0..d57a9cd2f 100644 --- a/packages/graph/src/components/Graph/Graph.jsx +++ b/packages/graph/src/components/Graph/Graph.jsx @@ -17,7 +17,7 @@ import ELK from 'elkjs/lib/elk.bundled'; import { ArrowRightMarker } from '@carbon/charts-react/diagrams/Marker'; -import Edge from '../Edge/'; +import Edge from '../Edge'; import Node from '../Node/Node'; function buildEdges({ direction, edges }) { diff --git a/src/containers/ClusterInterceptors/ClusterInterceptors.test.jsx b/src/containers/ClusterInterceptors/ClusterInterceptors.test.jsx index 3c19843f6..5b88e27f6 100644 --- a/src/containers/ClusterInterceptors/ClusterInterceptors.test.jsx +++ b/src/containers/ClusterInterceptors/ClusterInterceptors.test.jsx @@ -30,9 +30,9 @@ const clusterInterceptor = { describe('ClusterInterceptors', () => { it('renders loading state', async () => { - vi - .spyOn(API, 'useClusterInterceptors') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(API, 'useClusterInterceptors').mockImplementation(() => ({ + isLoading: true + })); const { queryByText } = renderWithRouter(, { path: paths.clusterInterceptors.all(), route: urls.clusterInterceptors.all() @@ -41,9 +41,9 @@ describe('ClusterInterceptors', () => { }); it('renders data', async () => { - vi - .spyOn(API, 'useClusterInterceptors') - .mockImplementation(() => ({ data: [clusterInterceptor] })); + vi.spyOn(API, 'useClusterInterceptors').mockImplementation(() => ({ + data: [clusterInterceptor] + })); const { queryByText } = renderWithRouter(, { path: paths.clusterInterceptors.all(), route: urls.clusterInterceptors.all() @@ -54,9 +54,9 @@ describe('ClusterInterceptors', () => { it('handles error', async () => { const error = 'fake_errorMessage'; - vi - .spyOn(API, 'useClusterInterceptors') - .mockImplementation(() => ({ error })); + vi.spyOn(API, 'useClusterInterceptors').mockImplementation(() => ({ + error + })); const { queryByText } = renderWithRouter(, { path: paths.clusterInterceptors.all(), route: urls.clusterInterceptors.all() diff --git a/src/containers/ClusterTasksDropdown/ClusterTasksDropdown.test.jsx b/src/containers/ClusterTasksDropdown/ClusterTasksDropdown.test.jsx index 80c2f24ca..57bd8f6ff 100644 --- a/src/containers/ClusterTasksDropdown/ClusterTasksDropdown.test.jsx +++ b/src/containers/ClusterTasksDropdown/ClusterTasksDropdown.test.jsx @@ -61,9 +61,9 @@ const checkDropdownItems = ({ describe('ClusterTasksDropdown', () => { it('renders items', () => { - vi - .spyOn(API, 'useClusterTasks') - .mockImplementation(() => ({ data: clusterTasks })); + vi.spyOn(API, 'useClusterTasks').mockImplementation(() => ({ + data: clusterTasks + })); const { getByPlaceholderText, getAllByText, queryByText } = render( ); @@ -77,9 +77,9 @@ describe('ClusterTasksDropdown', () => { }); it('renders controlled selection', () => { - vi - .spyOn(API, 'useClusterTasks') - .mockImplementation(() => ({ data: clusterTasks })); + vi.spyOn(API, 'useClusterTasks').mockImplementation(() => ({ + data: clusterTasks + })); // Select item 'clustertask-1' const { queryByDisplayValue, queryByPlaceholderText, rerender } = render( { }); it('renders loading state', () => { - vi - .spyOn(API, 'useClusterTasks') - .mockImplementation(() => ({ isFetching: true })); + vi.spyOn(API, 'useClusterTasks').mockImplementation(() => ({ + isFetching: true + })); const { queryByPlaceholderText } = render( ); @@ -123,9 +123,9 @@ describe('ClusterTasksDropdown', () => { }); it('handles onChange event', () => { - vi - .spyOn(API, 'useClusterTasks') - .mockImplementation(() => ({ data: clusterTasks })); + vi.spyOn(API, 'useClusterTasks').mockImplementation(() => ({ + data: clusterTasks + })); const onChange = vi.fn(); const { getByPlaceholderText, getByText } = render( diff --git a/src/containers/ClusterTriggerBinding/ClusterTriggerBinding.test.jsx b/src/containers/ClusterTriggerBinding/ClusterTriggerBinding.test.jsx index 4e596a994..ae40c6491 100644 --- a/src/containers/ClusterTriggerBinding/ClusterTriggerBinding.test.jsx +++ b/src/containers/ClusterTriggerBinding/ClusterTriggerBinding.test.jsx @@ -64,9 +64,9 @@ const clusterTriggerBindingWithLabels = { it('ClusterTriggerBindingContainer handles error state', async () => { const error = 'fake_error_message'; - vi - .spyOn(API, 'useClusterTriggerBinding') - .mockImplementation(() => ({ error })); + vi.spyOn(API, 'useClusterTriggerBinding').mockImplementation(() => ({ + error + })); const { getByText } = renderWithRouter( @@ -76,9 +76,9 @@ it('ClusterTriggerBindingContainer handles error state', async () => { }); it('ClusterTriggerBindingContainer renders overview', async () => { - vi - .spyOn(API, 'useClusterTriggerBinding') - .mockImplementation(() => ({ data: clusterTriggerBindingSimple })); + vi.spyOn(API, 'useClusterTriggerBinding').mockImplementation(() => ({ + data: clusterTriggerBindingSimple + })); const { getByText } = renderWithRouter( @@ -93,9 +93,9 @@ it('ClusterTriggerBindingContainer renders overview', async () => { }); it('ClusterTriggerBindingContainer renders YAML', async () => { - vi - .spyOn(API, 'useClusterTriggerBinding') - .mockImplementation(() => ({ data: clusterTriggerBindingSimple })); + vi.spyOn(API, 'useClusterTriggerBinding').mockImplementation(() => ({ + data: clusterTriggerBindingSimple + })); const clusterTriggerBindingName = 'cluster-trigger-binding-simple'; const { getByText } = renderWithRouter( @@ -119,9 +119,9 @@ it('ClusterTriggerBindingContainer renders YAML', async () => { }); it('ClusterTriggerBindingContainer does not render label section if they are not present', async () => { - vi - .spyOn(API, 'useClusterTriggerBinding') - .mockImplementation(() => ({ data: clusterTriggerBindingSimple })); + vi.spyOn(API, 'useClusterTriggerBinding').mockImplementation(() => ({ + data: clusterTriggerBindingSimple + })); const { getByText } = renderWithRouter( @@ -132,9 +132,9 @@ it('ClusterTriggerBindingContainer does not render label section if they are not }); it('ClusterTriggerBindingContainer renders labels section if they are present', async () => { - vi - .spyOn(API, 'useClusterTriggerBinding') - .mockImplementation(() => ({ data: clusterTriggerBindingWithLabels })); + vi.spyOn(API, 'useClusterTriggerBinding').mockImplementation(() => ({ + data: clusterTriggerBindingWithLabels + })); const { getByText } = renderWithRouter( diff --git a/src/containers/ClusterTriggerBindings/ClusterTriggerBindings.test.jsx b/src/containers/ClusterTriggerBindings/ClusterTriggerBindings.test.jsx index 3147e756b..eb08c64b5 100644 --- a/src/containers/ClusterTriggerBindings/ClusterTriggerBindings.test.jsx +++ b/src/containers/ClusterTriggerBindings/ClusterTriggerBindings.test.jsx @@ -44,9 +44,9 @@ it('ClusterTriggerBindings renders with no bindings', () => { }); it('ClusterTriggerBindings renders with one binding', () => { - vi - .spyOn(API, 'useClusterTriggerBindings') - .mockImplementation(() => ({ data: [clusterTriggerBinding] })); + vi.spyOn(API, 'useClusterTriggerBindings').mockImplementation(() => ({ + data: [clusterTriggerBinding] + })); const { queryByText } = renderWithRouter(, { path: '/clustertriggerbindings', @@ -58,11 +58,11 @@ it('ClusterTriggerBindings renders with one binding', () => { }); it('ClusterTriggerBindings can be filtered on a single label filter', async () => { - vi - .spyOn(API, 'useClusterTriggerBindings') - .mockImplementation(({ filters }) => ({ + vi.spyOn(API, 'useClusterTriggerBindings').mockImplementation( + ({ filters }) => ({ data: filters.length ? [] : [clusterTriggerBinding] - })); + }) + ); const { queryByText, getByPlaceholderText, getByText } = renderWithRouter( , @@ -82,9 +82,9 @@ it('ClusterTriggerBindings can be filtered on a single label filter', async () = }); it('ClusterTriggerBindings renders in loading state', () => { - vi - .spyOn(API, 'useClusterTriggerBindings') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(API, 'useClusterTriggerBindings').mockImplementation(() => ({ + isLoading: true + })); const { queryByText } = renderWithRouter(, { path: '/clustertriggerbindings', @@ -98,9 +98,9 @@ it('ClusterTriggerBindings renders in loading state', () => { it('ClusterTriggerBindings renders in error state', () => { const error = 'fake_error_message'; - vi - .spyOn(API, 'useClusterTriggerBindings') - .mockImplementation(() => ({ error })); + vi.spyOn(API, 'useClusterTriggerBindings').mockImplementation(() => ({ + error + })); const { queryByText } = renderWithRouter(, { path: '/clustertriggerbindings', diff --git a/src/containers/CreateTaskRun/CreateTaskRun.test.jsx b/src/containers/CreateTaskRun/CreateTaskRun.test.jsx index 82f03b318..32901218a 100644 --- a/src/containers/CreateTaskRun/CreateTaskRun.test.jsx +++ b/src/containers/CreateTaskRun/CreateTaskRun.test.jsx @@ -95,14 +95,16 @@ const submitButton = allByText => allByText('Create')[0]; describe('CreateTaskRun', () => { beforeEach(() => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ data: [serviceAccount] })); - vi.spyOn(TasksAPI, 'useTasks') - .mockImplementation(() => ({ data: tasks })); - vi.spyOn(ClusterTasksAPI, 'useClusterTasks') - .mockImplementation(() => ({ data: clusterTasks })); - vi.spyOn(TaskRunsAPI, 'getTaskRuns') - .mockImplementation(() => taskRuns.byId); + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ data: [serviceAccount] }) + ); + vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ data: tasks })); + vi.spyOn(ClusterTasksAPI, 'useClusterTasks').mockImplementation(() => ({ + data: clusterTasks + })); + vi.spyOn(TaskRunsAPI, 'getTaskRuns').mockImplementation( + () => taskRuns.byId + ); vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [ @@ -113,8 +115,9 @@ describe('CreateTaskRun', () => { }); it('renders empty, dropdowns disabled when no namespace selected', async () => { - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); const { getByPlaceholderText, getByText, @@ -175,8 +178,9 @@ describe('CreateTaskRun', () => { }); it('resets Task and ServiceAccount when namespace changes', async () => { - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: 'namespace-1' })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: 'namespace-1' + })); const { getByPlaceholderText, getByText, getByDisplayValue } = renderWithRouter(); @@ -201,8 +205,9 @@ describe('CreateTaskRun', () => { }); it('handles onClose event', () => { - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: 'namespace-1' })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: 'namespace-1' + })); vi.spyOn(window.history, 'pushState'); const { getByText } = renderWithRouter(); fireEvent.click(getByText(/cancel/i)); diff --git a/src/containers/EventListener/EventListener.test.jsx b/src/containers/EventListener/EventListener.test.jsx index bf819006d..2e374dafb 100644 --- a/src/containers/EventListener/EventListener.test.jsx +++ b/src/containers/EventListener/EventListener.test.jsx @@ -129,8 +129,9 @@ const fakeEventListenerWithLabels = { const props = { intl }; it('EventListener displays with formatted labels', async () => { - vi.spyOn(API, 'useEventListener') - .mockImplementation(() => ({ data: fakeEventListenerWithLabels })); + vi.spyOn(API, 'useEventListener').mockImplementation(() => ({ + data: fakeEventListenerWithLabels + })); const { queryByText, getByText } = renderWithRouter( , { @@ -171,8 +172,9 @@ it('EventListener handles no serviceAccountName', async () => { serviceAccountName: undefined } }; - vi.spyOn(API, 'useEventListener') - .mockImplementation(() => ({ data: eventListener })); + vi.spyOn(API, 'useEventListener').mockImplementation(() => ({ + data: eventListener + })); const { queryByText, getByText } = renderWithRouter( , { @@ -193,8 +195,9 @@ it('EventListener handles no service type', async () => { serviceType: undefined } }; - vi.spyOn(API, 'useEventListener') - .mockImplementation(() => ({ data: eventListener })); + vi.spyOn(API, 'useEventListener').mockImplementation(() => ({ + data: eventListener + })); const { queryByText, getByText } = renderWithRouter( , { @@ -215,8 +218,9 @@ it('EventListener handles no triggers', async () => { triggers: [] } }; - vi.spyOn(API, 'useEventListener') - .mockImplementation(() => ({ data: eventListener })); + vi.spyOn(API, 'useEventListener').mockImplementation(() => ({ + data: eventListener + })); const { queryByText, getByText } = renderWithRouter( ); diff --git a/src/containers/EventListeners/EventListeners.test.jsx b/src/containers/EventListeners/EventListeners.test.jsx index e625e84ca..1ca3077bf 100644 --- a/src/containers/EventListeners/EventListeners.test.jsx +++ b/src/containers/EventListeners/EventListeners.test.jsx @@ -37,13 +37,15 @@ describe('EventListeners', () => { vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [{ metadata: { name: 'default' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); }); it('renders with no bindings', () => { - vi.spyOn(EventListenersAPI, 'useEventListeners') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(EventListenersAPI, 'useEventListeners').mockImplementation(() => ({ + data: [] + })); const { getByText } = renderWithRouter(, { path: '/eventlisteners', @@ -55,8 +57,9 @@ describe('EventListeners', () => { }); it('renders with one binding', () => { - vi.spyOn(EventListenersAPI, 'useEventListeners') - .mockImplementation(() => ({ data: [eventListener] })); + vi.spyOn(EventListenersAPI, 'useEventListeners').mockImplementation(() => ({ + data: [eventListener] + })); const { queryByText, queryByTitle } = renderWithRouter(, { path: '/eventlisteners', @@ -70,10 +73,11 @@ describe('EventListeners', () => { }); it('can be filtered on a single label filter', async () => { - vi.spyOn(EventListenersAPI, 'useEventListeners') - .mockImplementation(({ filters }) => ({ + vi.spyOn(EventListenersAPI, 'useEventListeners').mockImplementation( + ({ filters }) => ({ data: filters.length ? [] : [eventListener] - })); + }) + ); const { getByPlaceholderText, getByText, queryByText } = renderWithRouter( , @@ -90,8 +94,9 @@ describe('EventListeners', () => { }); it('renders in loading state', () => { - vi.spyOn(EventListenersAPI, 'useEventListeners') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(EventListenersAPI, 'useEventListeners').mockImplementation(() => ({ + isLoading: true + })); const { queryByText } = renderWithRouter(, { path: '/eventlisteners', @@ -105,8 +110,9 @@ describe('EventListeners', () => { it('renders in error state', () => { const error = 'fake_error_message'; - vi.spyOn(EventListenersAPI, 'useEventListeners') - .mockImplementation(() => ({ error })); + vi.spyOn(EventListenersAPI, 'useEventListeners').mockImplementation(() => ({ + error + })); const { queryByText } = renderWithRouter(, { path: '/eventlisteners', diff --git a/src/containers/HeaderBarContent/HeaderBarContent.jsx b/src/containers/HeaderBarContent/HeaderBarContent.jsx index 18a60ee59..585df3211 100644 --- a/src/containers/HeaderBarContent/HeaderBarContent.jsx +++ b/src/containers/HeaderBarContent/HeaderBarContent.jsx @@ -47,7 +47,8 @@ export default function HeaderBarContent({ isFetchingConfig, logoutButton }) { } function handleNamespaceSelected(event) { - const newNamespace = event.selectedItem?.id || tenantNamespaces[0] || ALL_NAMESPACES; + const newNamespace = + event.selectedItem?.id || tenantNamespaces[0] || ALL_NAMESPACES; selectNamespace(newNamespace); if (!namespacedMatch) { diff --git a/src/containers/HeaderBarContent/HeaderBarContent.test.jsx b/src/containers/HeaderBarContent/HeaderBarContent.test.jsx index 8e8e1d060..a5f296a66 100644 --- a/src/containers/HeaderBarContent/HeaderBarContent.test.jsx +++ b/src/containers/HeaderBarContent/HeaderBarContent.test.jsx @@ -24,8 +24,10 @@ describe('HeaderBarContent', () => { it('selects namespace based on URL', () => { const namespace = 'default'; const selectNamespace = vi.fn(); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: null, selectNamespace })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: null, + selectNamespace + })); const path = '/namespaces/:namespace/foo'; renderWithRouter(, { path, @@ -151,17 +153,23 @@ describe('HeaderBarContent', () => { const tenantNamespace2 = 'fake_tenantNamespace2'; const path = '/namespaces/:namespace/fake/path'; const selectNamespace = vi.fn(); - vi.spyOn(API, 'useTenantNamespaces').mockImplementation(() => [tenantNamespace1, tenantNamespace2]); + vi.spyOn(API, 'useTenantNamespaces').mockImplementation(() => [ + tenantNamespace1, + tenantNamespace2 + ]); vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ namespacedMatch: { path, params: { namespace: tenantNamespace2 } }, selectedNamespace: tenantNamespace2, selectNamespace })); vi.spyOn(window.history, 'pushState'); - const { getByDisplayValue, getByTitle } = renderWithRouter(, { - path, - route: `/namespaces/${tenantNamespace2}/fake/path` - }); + const { getByDisplayValue, getByTitle } = renderWithRouter( + , + { + path, + route: `/namespaces/${tenantNamespace2}/fake/path` + } + ); await waitFor(() => getByDisplayValue(tenantNamespace2)); fireEvent.click(getByTitle(/clear selected item/i)); expect(selectNamespace).toHaveBeenCalledWith(tenantNamespace1); diff --git a/src/containers/ImportResources/ImportResources.test.jsx b/src/containers/ImportResources/ImportResources.test.jsx index a6f03ada6..a38fc43db 100644 --- a/src/containers/ImportResources/ImportResources.test.jsx +++ b/src/containers/ImportResources/ImportResources.test.jsx @@ -28,8 +28,9 @@ describe('ImportResources component', () => { { metadata: { name: 'tekton-dashboard' } } ] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); }); it('Displays errors when Repository URL and Namespace is empty', async () => { @@ -77,34 +78,33 @@ describe('ImportResources component', () => { const repositoryURLValue = 'https://github.com/test/testing'; const revisionValue = 'main'; - vi.spyOn(API, 'importResources') - .mockImplementation( - ({ - importerNamespace, - labels, - namespace, - path, - repositoryURL, - revision, - serviceAccount - }) => { - const labelsShouldEqual = { - gitOrg: 'test', - gitRepo: 'testing', - gitServer: 'github.com' - }; - - expect(repositoryURL).toEqual(repositoryURLValue); - expect(path).toEqual(pathValue); - expect(revision).toEqual(revisionValue); - expect(namespace).toEqual('default'); - expect(labels).toEqual(labelsShouldEqual); - expect(serviceAccount).toEqual(''); - expect(importerNamespace).toEqual('tekton-dashboard'); - - return Promise.resolve(headers); - } - ); + vi.spyOn(API, 'importResources').mockImplementation( + ({ + importerNamespace, + labels, + namespace, + path, + repositoryURL, + revision, + serviceAccount + }) => { + const labelsShouldEqual = { + gitOrg: 'test', + gitRepo: 'testing', + gitServer: 'github.com' + }; + + expect(repositoryURL).toEqual(repositoryURLValue); + expect(path).toEqual(pathValue); + expect(revision).toEqual(revisionValue); + expect(namespace).toEqual('default'); + expect(labels).toEqual(labelsShouldEqual); + expect(serviceAccount).toEqual(''); + expect(importerNamespace).toEqual('tekton-dashboard'); + + return Promise.resolve(headers); + } + ); const namespace = 'default'; @@ -142,8 +142,9 @@ describe('ImportResources component', () => { it('Invalid data submit displays invalidText', async () => { const importResourcesResponseMock = { response: { status: 500 } }; - vi.spyOn(API, 'importResources') - .mockImplementation(() => Promise.reject(importResourcesResponseMock)); + vi.spyOn(API, 'importResources').mockImplementation(() => + Promise.reject(importResourcesResponseMock) + ); const { getAllByPlaceholderText, getByPlaceholderText, getByText } = await render(); diff --git a/src/containers/Interceptors/Interceptors.test.jsx b/src/containers/Interceptors/Interceptors.test.jsx index e45ba5e8e..45a476384 100644 --- a/src/containers/Interceptors/Interceptors.test.jsx +++ b/src/containers/Interceptors/Interceptors.test.jsx @@ -37,13 +37,15 @@ describe('Interceptors', () => { vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [{ metadata: { name: 'default' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); }); it('renders with no interceptors', () => { - vi.spyOn(InterceptorsAPI, 'useInterceptors') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(InterceptorsAPI, 'useInterceptors').mockImplementation(() => ({ + data: [] + })); const { getByText } = renderWithRouter(, { path: '/interceptors', @@ -55,8 +57,9 @@ describe('Interceptors', () => { }); it('renders with one interceptor', () => { - vi.spyOn(InterceptorsAPI, 'useInterceptors') - .mockImplementation(() => ({ data: [interceptor] })); + vi.spyOn(InterceptorsAPI, 'useInterceptors').mockImplementation(() => ({ + data: [interceptor] + })); const { queryByText } = renderWithRouter(, { path: '/interceptors', @@ -69,10 +72,11 @@ describe('Interceptors', () => { }); it('can be filtered on a single label filter', async () => { - vi.spyOn(InterceptorsAPI, 'useInterceptors') - .mockImplementation(({ filters }) => ({ + vi.spyOn(InterceptorsAPI, 'useInterceptors').mockImplementation( + ({ filters }) => ({ data: filters.length ? [] : [interceptor] - })); + }) + ); const { queryByText, getByPlaceholderText, getByText } = renderWithRouter( , @@ -89,8 +93,9 @@ describe('Interceptors', () => { }); it('renders in loading state', () => { - vi.spyOn(InterceptorsAPI, 'useInterceptors') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(InterceptorsAPI, 'useInterceptors').mockImplementation(() => ({ + isLoading: true + })); const { queryByText } = renderWithRouter(, { path: '/interceptors', @@ -104,8 +109,9 @@ describe('Interceptors', () => { it('renders in error state', () => { const error = 'fake_error_message'; - vi.spyOn(InterceptorsAPI, 'useInterceptors') - .mockImplementation(() => ({ error })); + vi.spyOn(InterceptorsAPI, 'useInterceptors').mockImplementation(() => ({ + error + })); const { queryByText } = renderWithRouter(, { path: '/interceptors', diff --git a/src/containers/NamespacesDropdown/NamespacesDropdown.test.jsx b/src/containers/NamespacesDropdown/NamespacesDropdown.test.jsx index 2fd0d80e9..404cdc28a 100644 --- a/src/containers/NamespacesDropdown/NamespacesDropdown.test.jsx +++ b/src/containers/NamespacesDropdown/NamespacesDropdown.test.jsx @@ -31,8 +31,9 @@ const namespaceResources = namespaces.map(namespace => ({ const initialTextRegExp = /select namespace/i; it('NamespacesDropdown renders items', () => { - vi.spyOn(API, 'useNamespaces') - .mockImplementation(() => ({ data: namespaceResources })); + vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ + data: namespaceResources + })); const { getAllByText, getByPlaceholderText, queryByText } = render( ); @@ -47,8 +48,9 @@ it('NamespacesDropdown renders items', () => { }); it('NamespacesDropdown renders controlled selection', () => { - vi.spyOn(API, 'useNamespaces') - .mockImplementation(() => ({ data: namespaceResources })); + vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ + data: namespaceResources + })); // Select item 'namespace-1' const { queryByPlaceholderText, queryByDisplayValue, rerender } = render( @@ -72,15 +74,17 @@ it('NamespacesDropdown renders empty', () => { }); it('NamespacesDropdown renders loading skeleton', () => { - vi.spyOn(API, 'useNamespaces') - .mockImplementation(() => ({ isFetching: true })); + vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ + isFetching: true + })); const { queryByPlaceholderText } = render(); expect(queryByPlaceholderText(initialTextRegExp)).toBeFalsy(); }); it('NamespacesDropdown handles onChange event', () => { - vi.spyOn(API, 'useNamespaces') - .mockImplementation(() => ({ data: namespaceResources })); + vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ + data: namespaceResources + })); const onChange = vi.fn(); const { getByPlaceholderText, getByText } = render( diff --git a/src/containers/PipelineRun/PipelineRun.test.jsx b/src/containers/PipelineRun/PipelineRun.test.jsx index 24342503c..e06e615e6 100644 --- a/src/containers/PipelineRun/PipelineRun.test.jsx +++ b/src/containers/PipelineRun/PipelineRun.test.jsx @@ -36,13 +36,14 @@ const pipelineRun = { }; it('PipelineRunContainer renders data', async () => { - vi.spyOn(PipelineRunsAPI, 'usePipelineRun') - .mockImplementation(() => ({ data: pipelineRun })); - vi.spyOn(TaskRunsAPI, 'useTaskRuns') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(PipelineRunsAPI, 'usePipelineRun').mockImplementation(() => ({ + data: pipelineRun + })); + vi.spyOn(TaskRunsAPI, 'useTaskRuns').mockImplementation(() => ({ data: [] })); vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ data: [] })); - vi.spyOn(ClusterTasksAPI, 'useClusterTasks') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(ClusterTasksAPI, 'useClusterTasks').mockImplementation(() => ({ + data: [] + })); const { getByText } = renderWithRouter(); await waitFor(() => getByText(pipelineRun.metadata.name)); @@ -51,8 +52,10 @@ it('PipelineRunContainer renders data', async () => { it('PipelineRunContainer renders not found state', async () => { const namespace = 'fake_namespace'; const pipelineRunName = 'fake_pipelineRunName'; - vi.spyOn(PipelineRunsAPI, 'usePipelineRun') - .mockImplementation(() => ({ data: null, error: null })); + vi.spyOn(PipelineRunsAPI, 'usePipelineRun').mockImplementation(() => ({ + data: null, + error: null + })); const { findByText } = renderWithRouter( , @@ -67,8 +70,10 @@ it('PipelineRunContainer renders not found state', async () => { it('PipelineRunContainer renders error state', async () => { const namespace = 'fake_namespace'; const pipelineRunName = 'fake_pipelineRunName'; - vi.spyOn(PipelineRunsAPI, 'usePipelineRun') - .mockImplementation(() => ({ data: null, error: 'some error' })); + vi.spyOn(PipelineRunsAPI, 'usePipelineRun').mockImplementation(() => ({ + data: null, + error: 'some error' + })); const { findByText } = renderWithRouter( , diff --git a/src/containers/PipelineRuns/PipelineRuns.test.jsx b/src/containers/PipelineRuns/PipelineRuns.test.jsx index 6d02a67d3..051835b1f 100644 --- a/src/containers/PipelineRuns/PipelineRuns.test.jsx +++ b/src/containers/PipelineRuns/PipelineRuns.test.jsx @@ -101,10 +101,12 @@ const pipelineRuns = [ describe('PipelineRuns container', () => { beforeEach(() => { - vi.spyOn(PipelinesAPI, 'usePipelines') - .mockImplementation(() => ({ data: pipelines })); - vi.spyOn(PipelineRunsAPI, 'usePipelineRuns') - .mockImplementation(() => ({ data: [...pipelineRuns] })); + vi.spyOn(PipelinesAPI, 'usePipelines').mockImplementation(() => ({ + data: pipelines + })); + vi.spyOn(PipelineRunsAPI, 'usePipelineRuns').mockImplementation(() => ({ + data: [...pipelineRuns] + })); vi.spyOn(API, 'useIsReadOnly').mockImplementation(() => true); }); @@ -194,8 +196,7 @@ describe('PipelineRuns container', () => { PipelineRunsAPI.usePipelineRuns.mockImplementation(() => ({ data: [pipelineRuns[0]] })); - vi.spyOn(PipelineRunsAPI, 'rerunPipelineRun') - .mockImplementation(() => []); + vi.spyOn(PipelineRunsAPI, 'rerunPipelineRun').mockImplementation(() => []); const { getAllByTitle, getByText } = renderWithRouter( , { @@ -215,10 +216,10 @@ describe('PipelineRuns container', () => { it('handles start event in PipelineRuns page', async () => { vi.spyOn(API, 'useIsReadOnly').mockImplementation(() => false); - vi.spyOn(PipelineRunsAPI, 'usePipelineRuns') - .mockImplementation(() => ({ data: [pipelineRuns[2]] })); - vi.spyOn(PipelineRunsAPI, 'startPipelineRun') - .mockImplementation(() => []); + vi.spyOn(PipelineRunsAPI, 'usePipelineRuns').mockImplementation(() => ({ + data: [pipelineRuns[2]] + })); + vi.spyOn(PipelineRunsAPI, 'startPipelineRun').mockImplementation(() => []); const { getAllByTitle, getByText } = renderWithRouter( , { diff --git a/src/containers/PipelinesDropdown/PipelinesDropdown.test.jsx b/src/containers/PipelinesDropdown/PipelinesDropdown.test.jsx index 8cfe1e725..80112fae5 100644 --- a/src/containers/PipelinesDropdown/PipelinesDropdown.test.jsx +++ b/src/containers/PipelinesDropdown/PipelinesDropdown.test.jsx @@ -69,8 +69,9 @@ const checkDropdownItems = ({ describe('PipelinesDropdown', () => { it('renders items', () => { - vi.spyOn(API, 'usePipelines') - .mockImplementation(() => ({ data: pipelines })); + vi.spyOn(API, 'usePipelines').mockImplementation(() => ({ + data: pipelines + })); const { getByPlaceholderText, getAllByText, queryByText } = render( ); @@ -83,8 +84,9 @@ describe('PipelinesDropdown', () => { }); it('renders controlled selection', () => { - vi.spyOn(API, 'usePipelines') - .mockImplementation(() => ({ data: pipelines })); + vi.spyOn(API, 'usePipelines').mockImplementation(() => ({ + data: pipelines + })); // Select item 'pipeline-1' const { queryByDisplayValue, queryByPlaceholderText, rerender } = render( @@ -103,8 +105,9 @@ describe('PipelinesDropdown', () => { it('renders empty', () => { vi.spyOn(API, 'usePipelines').mockImplementation(() => ({ data: [] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: 'blue' })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: 'blue' + })); const { queryByPlaceholderText } = render(); expect( queryByPlaceholderText(/no pipelines found in the 'blue' namespace/i) @@ -122,15 +125,17 @@ describe('PipelinesDropdown', () => { }); it('renders loading state', () => { - vi.spyOn(API, 'usePipelines') - .mockImplementation(() => ({ isFetching: true })); + vi.spyOn(API, 'usePipelines').mockImplementation(() => ({ + isFetching: true + })); const { queryByPlaceholderText } = render(); expect(queryByPlaceholderText(initialTextRegExp)).toBeFalsy(); }); it('handles onChange event', () => { - vi.spyOn(API, 'usePipelines') - .mockImplementation(() => ({ data: pipelines })); + vi.spyOn(API, 'usePipelines').mockImplementation(() => ({ + data: pipelines + })); const onChange = vi.fn(); const { getByPlaceholderText, getByText } = render( diff --git a/src/containers/ServiceAccountsDropdown/ServiceAccountsDropdown.test.jsx b/src/containers/ServiceAccountsDropdown/ServiceAccountsDropdown.test.jsx index a62b80275..22670c980 100644 --- a/src/containers/ServiceAccountsDropdown/ServiceAccountsDropdown.test.jsx +++ b/src/containers/ServiceAccountsDropdown/ServiceAccountsDropdown.test.jsx @@ -80,15 +80,17 @@ describe('ServiceAccountsDropdown', () => { vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [{ metadata: { name: 'blue' } }, { metadata: { name: 'green' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: 'blue' })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: 'blue' + })); }); it('renders items', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ data: [serviceAccount1, serviceAccount2] - })); + }) + ); const { getByPlaceholderText, getAllByText, queryByText } = render( ); @@ -102,10 +104,11 @@ describe('ServiceAccountsDropdown', () => { }); it('renders controlled selection', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ data: [serviceAccount1, serviceAccount2] - })); + }) + ); // Select item 'service-account-1' const { queryByPlaceholderText, queryByDisplayValue, rerender } = render( { }); it('renders controlled namespace', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(({ namespace }) => ({ + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + ({ namespace }) => ({ data: namespace === 'green' ? [serviceAccount3] : [] - })); + }) + ); // Select namespace 'green' const { queryByText, getByPlaceholderText, getAllByText } = render( @@ -148,8 +152,9 @@ describe('ServiceAccountsDropdown', () => { }); it('renders empty', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ data: [] }) + ); // Select item 'service-account-1' const { queryByPlaceholderText } = render( @@ -163,17 +168,19 @@ describe('ServiceAccountsDropdown', () => { }); it('renders loading skeleton', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ isFetching: true })); + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ isFetching: true }) + ); const { queryByText } = render(); expect(queryByText(initialTextRegExp)).toBeFalsy(); }); it('handles onChange event', () => { - vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts') - .mockImplementation(() => ({ + vi.spyOn(ServiceAccountsAPI, 'useServiceAccounts').mockImplementation( + () => ({ data: [serviceAccount1, serviceAccount2] - })); + }) + ); const onChange = vi.fn(); const { getByPlaceholderText, getByText } = render( diff --git a/src/containers/Settings/Settings.test.jsx b/src/containers/Settings/Settings.test.jsx index 41f522f5f..36b593131 100644 --- a/src/containers/Settings/Settings.test.jsx +++ b/src/containers/Settings/Settings.test.jsx @@ -38,8 +38,7 @@ describe('Settings', () => { }); it('should render the log timestamp settings correctly', () => { - vi.spyOn(APIUtils, 'isLogTimestampsEnabled') - .mockImplementation(() => true); + vi.spyOn(APIUtils, 'isLogTimestampsEnabled').mockImplementation(() => true); vi.spyOn(APIUtils, 'setLogTimestampsEnabled'); const { getByLabelText, getByText } = render(); @@ -52,8 +51,9 @@ describe('Settings', () => { }); it('should render the v1 API settings correctly', () => { - vi.spyOn(APIUtils, 'isPipelinesV1ResourcesEnabled') - .mockImplementation(() => true); + vi.spyOn(APIUtils, 'isPipelinesV1ResourcesEnabled').mockImplementation( + () => true + ); vi.spyOn(APIUtils, 'setPipelinesV1ResourcesEnabled'); const { getByLabelText, getByText } = render(); diff --git a/src/containers/SideNav/SideNav.test.jsx b/src/containers/SideNav/SideNav.test.jsx index 0b0934dd1..f354e0054 100644 --- a/src/containers/SideNav/SideNav.test.jsx +++ b/src/containers/SideNav/SideNav.test.jsx @@ -44,8 +44,9 @@ it('SideNav renders only when expanded', () => { }); it('SideNav renders with extensions', () => { - vi.spyOn(extensionsAPI, 'useExtensions') - .mockImplementation(() => ({ data: mockExtensions })); + vi.spyOn(extensionsAPI, 'useExtensions').mockImplementation(() => ({ + data: mockExtensions + })); const { queryByText } = renderWithRouter(); expect(queryByText('Pipelines')).toBeTruthy(); expect(queryByText('Tasks')).toBeTruthy(); diff --git a/src/containers/TaskRuns/TaskRuns.test.jsx b/src/containers/TaskRuns/TaskRuns.test.jsx index 6c046fa33..2498fb05d 100644 --- a/src/containers/TaskRuns/TaskRuns.test.jsx +++ b/src/containers/TaskRuns/TaskRuns.test.jsx @@ -62,8 +62,9 @@ const taskRuns = [ describe('TaskRuns container', () => { beforeEach(() => { - vi.spyOn(taskRunsAPI, 'useTaskRuns') - .mockImplementation(() => ({ data: taskRuns })); + vi.spyOn(taskRunsAPI, 'useTaskRuns').mockImplementation(() => ({ + data: taskRuns + })); }); it('Duplicate label filters are prevented', async () => { diff --git a/src/containers/TasksDropdown/TasksDropdown.test.jsx b/src/containers/TasksDropdown/TasksDropdown.test.jsx index 48d7ce615..58d9bc79f 100644 --- a/src/containers/TasksDropdown/TasksDropdown.test.jsx +++ b/src/containers/TasksDropdown/TasksDropdown.test.jsx @@ -73,13 +73,13 @@ describe('TasksDropdown', () => { vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [{ metadata: { name: 'blue' } }, { metadata: { name: 'green' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: 'blue' })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: 'blue' + })); }); it('renders items', () => { - vi.spyOn(TasksAPI, 'useTasks') - .mockImplementation(() => ({ data: tasks })); + vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ data: tasks })); const { getByPlaceholderText, getAllByText, queryByText } = render( ); @@ -93,8 +93,7 @@ describe('TasksDropdown', () => { }); it('renders controlled selection', () => { - vi.spyOn(TasksAPI, 'useTasks') - .mockImplementation(() => ({ data: tasks })); + vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ data: tasks })); // Select item 'task-1' const { queryByDisplayValue, queryByPlaceholderText, rerender } = render( @@ -129,15 +128,15 @@ describe('TasksDropdown', () => { }); it('renders loading state', () => { - vi.spyOn(TasksAPI, 'useTasks') - .mockImplementation(() => ({ isFetching: true })); + vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ + isFetching: true + })); const { queryByPlaceholderText } = render(); expect(queryByPlaceholderText(initialTextRegExp)).toBeFalsy(); }); it('handles onChange event', () => { - vi.spyOn(TasksAPI, 'useTasks') - .mockImplementation(() => ({ data: tasks })); + vi.spyOn(TasksAPI, 'useTasks').mockImplementation(() => ({ data: tasks })); const onChange = vi.fn(); const { getByPlaceholderText, getByText } = render( diff --git a/src/containers/Trigger/Trigger.test.jsx b/src/containers/Trigger/Trigger.test.jsx index 85d6bf787..2c2feaf87 100644 --- a/src/containers/Trigger/Trigger.test.jsx +++ b/src/containers/Trigger/Trigger.test.jsx @@ -27,8 +27,9 @@ const intl = createIntl({ describe('TriggerContainer', () => { it('handles error state', async () => { const errorMessage = 'fake_errorMessage'; - vi.spyOn(API, 'useTrigger') - .mockImplementation(() => ({ error: errorMessage })); + vi.spyOn(API, 'useTrigger').mockImplementation(() => ({ + error: errorMessage + })); const { getByText } = renderWithRouter(); await waitFor(() => getByText('Error loading resource')); diff --git a/src/containers/TriggerBinding/TriggerBinding.test.jsx b/src/containers/TriggerBinding/TriggerBinding.test.jsx index 22b477b32..a192d0e40 100644 --- a/src/containers/TriggerBinding/TriggerBinding.test.jsx +++ b/src/containers/TriggerBinding/TriggerBinding.test.jsx @@ -77,8 +77,9 @@ it('TriggerBindingContainer handles error state', async () => { }); it('TriggerBindingContainer renders details', async () => { - vi.spyOn(API, 'useTriggerBinding') - .mockImplementation(() => ({ data: triggerBindingSimple })); + vi.spyOn(API, 'useTriggerBinding').mockImplementation(() => ({ + data: triggerBindingSimple + })); const { getByText } = renderWithRouter( @@ -94,8 +95,9 @@ it('TriggerBindingContainer renders details', async () => { }); it('TriggerBindingContainer renders YAML', async () => { - vi.spyOn(API, 'useTriggerBinding') - .mockImplementation(() => ({ data: triggerBindingSimple })); + vi.spyOn(API, 'useTriggerBinding').mockImplementation(() => ({ + data: triggerBindingSimple + })); const triggerBindingName = 'trigger-binding-simple'; const { getByText } = renderWithRouter( @@ -121,8 +123,9 @@ it('TriggerBindingContainer renders YAML', async () => { }); it('TriggerBindingContainer does not render label section if they are not present', async () => { - vi.spyOn(API, 'useTriggerBinding') - .mockImplementation(() => ({ data: triggerBindingSimple })); + vi.spyOn(API, 'useTriggerBinding').mockImplementation(() => ({ + data: triggerBindingSimple + })); const { getByText } = renderWithRouter( @@ -133,8 +136,9 @@ it('TriggerBindingContainer does not render label section if they are not presen }); it('TriggerBindingContainer renders labels section if they are present', async () => { - vi.spyOn(API, 'useTriggerBinding') - .mockImplementation(() => ({ data: triggerBindingWithLabels })); + vi.spyOn(API, 'useTriggerBinding').mockImplementation(() => ({ + data: triggerBindingWithLabels + })); const { getByText } = renderWithRouter( diff --git a/src/containers/TriggerBindings/TriggerBindings.test.jsx b/src/containers/TriggerBindings/TriggerBindings.test.jsx index 48f617aa8..8f9b24a42 100644 --- a/src/containers/TriggerBindings/TriggerBindings.test.jsx +++ b/src/containers/TriggerBindings/TriggerBindings.test.jsx @@ -37,13 +37,15 @@ describe('TriggerBindings', () => { vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ data: [{ metadata: { name: 'default' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); }); it('renders with no bindings', () => { - vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings').mockImplementation( + () => ({ data: [] }) + ); const { getByText } = renderWithRouter(, { path: '/triggerbindings', @@ -55,8 +57,9 @@ describe('TriggerBindings', () => { }); it('renders with one binding', () => { - vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings') - .mockImplementation(() => ({ data: [triggerBinding] })); + vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings').mockImplementation( + () => ({ data: [triggerBinding] }) + ); const { queryByText } = renderWithRouter(, { path: '/triggerbindings', @@ -69,10 +72,11 @@ describe('TriggerBindings', () => { }); it('can be filtered on a single label filter', async () => { - vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings') - .mockImplementation(({ filters }) => ({ + vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings').mockImplementation( + ({ filters }) => ({ data: filters.length ? [] : [triggerBinding] - })); + }) + ); const { queryByText, getByPlaceholderText, getByText } = renderWithRouter( , @@ -89,8 +93,9 @@ describe('TriggerBindings', () => { }); it('renders in loading state', () => { - vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings').mockImplementation( + () => ({ isLoading: true }) + ); const { queryByText } = renderWithRouter(, { path: '/triggerbindings', @@ -104,8 +109,9 @@ describe('TriggerBindings', () => { it('renders in error state', () => { const error = 'fake_error_message'; - vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings') - .mockImplementation(() => ({ error })); + vi.spyOn(TriggerBindingsAPI, 'useTriggerBindings').mockImplementation( + () => ({ error }) + ); const { queryByText } = renderWithRouter(, { path: '/triggerbindings', diff --git a/src/containers/TriggerTemplate/TriggerTemplate.test.jsx b/src/containers/TriggerTemplate/TriggerTemplate.test.jsx index f5e0c73cd..ead14502c 100644 --- a/src/containers/TriggerTemplate/TriggerTemplate.test.jsx +++ b/src/containers/TriggerTemplate/TriggerTemplate.test.jsx @@ -144,8 +144,9 @@ it('TriggerTemplateContainer handles error state', async () => { }); it('TriggerTemplateContainer renders', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplate })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplate + })); const { getAllByText, getByText } = renderWithRouter( @@ -171,8 +172,9 @@ it('TriggerTemplateContainer renders', async () => { }); it('TriggerTemplateContainer contains overview tab with accurate information', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplate })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplate + })); const { getByText } = renderWithRouter( @@ -185,8 +187,9 @@ it('TriggerTemplateContainer contains overview tab with accurate information', a }); it('TriggerTemplateContainer contains YAML tab with accurate information', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplate })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplate + })); const { getByText } = renderWithRouter( , { @@ -209,8 +212,9 @@ it('TriggerTemplateContainer contains YAML tab with accurate information', async }); it('TriggerTemplateContainer does not render label section if they are not present', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplate })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplate + })); const { getByText, queryByText } = renderWithRouter( @@ -221,8 +225,9 @@ it('TriggerTemplateContainer does not render label section if they are not prese }); it('TriggerTemplateContainer renders labels section if they are present', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplateWithLabels })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplateWithLabels + })); const { getByText } = renderWithRouter( @@ -239,8 +244,9 @@ it('TriggerTemplateContainer renders labels section if they are present', async }); it('TriggerTemplateContainer contains formatted labels', async () => { - vi.spyOn(API, 'useTriggerTemplate') - .mockImplementation(() => ({ data: fakeTriggerTemplateWithLabels })); + vi.spyOn(API, 'useTriggerTemplate').mockImplementation(() => ({ + data: fakeTriggerTemplateWithLabels + })); const { getByText } = renderWithRouter( diff --git a/src/containers/TriggerTemplates/TriggerTemplates.test.jsx b/src/containers/TriggerTemplates/TriggerTemplates.test.jsx index e752a406b..6d777280e 100644 --- a/src/containers/TriggerTemplates/TriggerTemplates.test.jsx +++ b/src/containers/TriggerTemplates/TriggerTemplates.test.jsx @@ -33,13 +33,16 @@ const triggerTemplate = { }; it('TriggerTemplates renders with no templates', () => { - vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates') - .mockImplementation(() => ({ data: [] })); + vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates').mockImplementation( + () => ({ data: [] }) + ); - vi.spyOn(API, 'useNamespaces') - .mockImplementation(() => ({ data: [{ metadata: { name: 'default' } }] })); - vi.spyOn(APIUtils, 'useSelectedNamespace') - .mockImplementation(() => ({ selectedNamespace: ALL_NAMESPACES })); + vi.spyOn(API, 'useNamespaces').mockImplementation(() => ({ + data: [{ metadata: { name: 'default' } }] + })); + vi.spyOn(APIUtils, 'useSelectedNamespace').mockImplementation(() => ({ + selectedNamespace: ALL_NAMESPACES + })); const { queryByText } = renderWithRouter(, { path: '/triggertemplates', @@ -51,8 +54,9 @@ it('TriggerTemplates renders with no templates', () => { }); it('TriggerTemplates renders with one template', () => { - vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates') - .mockImplementation(() => ({ data: [triggerTemplate] })); + vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates').mockImplementation( + () => ({ data: [triggerTemplate] }) + ); const { queryByText } = renderWithRouter(, { path: '/triggertemplates', @@ -65,10 +69,11 @@ it('TriggerTemplates renders with one template', () => { }); it('TriggerTemplates can be filtered on a single label filter', async () => { - vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates') - .mockImplementation(({ filters }) => ({ + vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates').mockImplementation( + ({ filters }) => ({ data: filters.length ? [] : [triggerTemplate] - })); + }) + ); const { queryByText, getByPlaceholderText, getByText } = renderWithRouter( , @@ -85,8 +90,9 @@ it('TriggerTemplates can be filtered on a single label filter', async () => { }); it('TriggerTemplates renders in loading state', () => { - vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates').mockImplementation( + () => ({ isLoading: true }) + ); const { queryByText } = renderWithRouter(, { path: '/triggertemplates', @@ -99,8 +105,9 @@ it('TriggerTemplates renders in loading state', () => { it('TriggerTemplates renders in error state', () => { const error = 'fake_error_message'; - vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates') - .mockImplementation(() => ({ error })); + vi.spyOn(TriggerTemplatesAPI, 'useTriggerTemplates').mockImplementation( + () => ({ error }) + ); const { queryByText } = renderWithRouter(, { path: '/triggertemplates', diff --git a/src/containers/Triggers/Triggers.test.jsx b/src/containers/Triggers/Triggers.test.jsx index 32f257509..4e0c98a2a 100644 --- a/src/containers/Triggers/Triggers.test.jsx +++ b/src/containers/Triggers/Triggers.test.jsx @@ -24,8 +24,9 @@ describe('Triggers', () => { }); it('renders loading state', async () => { - vi.spyOn(API, 'useTriggers') - .mockImplementation(() => ({ isLoading: true })); + vi.spyOn(API, 'useTriggers').mockImplementation(() => ({ + isLoading: true + })); const { queryByText } = renderWithRouter(, { path: paths.triggers.all(), route: urls.triggers.all() @@ -58,8 +59,9 @@ describe('Triggers', () => { it('handles error', async () => { const errorMessage = 'fake_errorMessage'; - vi.spyOn(API, 'useTriggers') - .mockImplementation(() => ({ error: errorMessage })); + vi.spyOn(API, 'useTriggers').mockImplementation(() => ({ + error: errorMessage + })); const { queryByText } = renderWithRouter(, { path: paths.triggers.all(), route: urls.triggers.all() diff --git a/src/containers/YAMLEditor/YAMLEditor.jsx b/src/containers/YAMLEditor/YAMLEditor.jsx index 6a385a798..b8895bd04 100644 --- a/src/containers/YAMLEditor/YAMLEditor.jsx +++ b/src/containers/YAMLEditor/YAMLEditor.jsx @@ -157,14 +157,18 @@ export default function YAMLEditor({ /> )} - {loading ? : ( + {loading ? ( + + ) : ( diff --git a/src/containers/YAMLEditor/YAMLEditor.test.jsx b/src/containers/YAMLEditor/YAMLEditor.test.jsx index 2614f456a..f113fda54 100644 --- a/src/containers/YAMLEditor/YAMLEditor.test.jsx +++ b/src/containers/YAMLEditor/YAMLEditor.test.jsx @@ -134,7 +134,8 @@ describe('YAMLEditor', () => { }); it('handle submit', async () => { - const handleCreate = vi.fn() + const handleCreate = vi + .fn() .mockImplementation(() => Promise.resolve({ data: {} })); const { queryAllByText, getByText, getByRole } = renderWithRouter( @@ -157,7 +158,8 @@ describe('YAMLEditor', () => { const errorResponseMock = { response: { status: 404, text: () => Promise.resolve('Whoops!') } }; - const handleCreate = vi.fn() + const handleCreate = vi + .fn() .mockImplementation(() => Promise.reject(errorResponseMock)); const { queryAllByText, getByText, getByRole } = renderWithRouter( diff --git a/vite.config.js b/vite.config.js index 67bc626d4..bf89fccc6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -32,13 +32,13 @@ export default defineConfig(({ mode }) => ({ assetsDir: '.', // Relative to the root outDir: 'cmd/dashboard/kodata', - target: 'es2021' + target: 'es2022' }, css: { devSourcemap: true }, esbuild: { - target: 'es2021' + target: 'es2022' }, plugins: [ createHtmlPlugin({}),