aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2022-04-13 14:55:13 +0200
committersonartech <sonartech@sonarsource.com>2022-04-14 20:03:30 +0000
commit36a8b6ed6eaf2b595d4b4e4cb85fd96d555249a0 (patch)
tree7e2275dbc5fa1e5082aa211ae9117b0aba1b4743 /server/sonar-web
parent441196af138862533d4c812a55c599cc9a19da5f (diff)
downloadsonarqube-36a8b6ed6eaf2b595d4b4e4cb85fd96d555249a0.tar.gz
sonarqube-36a8b6ed6eaf2b595d4b4e4cb85fd96d555249a0.zip
SONAR-16244 RTL tests for global background-tasks
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/api/mocks/ComputeEngineServiceMock.ts198
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx150
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stats-test.tsx44
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/StatusFilter-test.tsx41
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx29
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskDay-test.tsx36
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskExecutionTime-test.tsx27
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskId-test.tsx26
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskType-test.tsx26
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TypesFilter-test.tsx43
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Stats-test.tsx.snap33
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/StatusFilter-test.tsx.snap42
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap56
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskDay-test.tsx.snap18
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskExecutionTime-test.tsx.snap15
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskId-test.tsx.snap13
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskType-test.tsx.snap11
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TypesFilter-test.tsx.snap33
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/types/tasks.ts4
21 files changed, 358 insertions, 494 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/ComputeEngineServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/ComputeEngineServiceMock.ts
new file mode 100644
index 00000000000..f2aa024ec92
--- /dev/null
+++ b/server/sonar-web/src/main/js/api/mocks/ComputeEngineServiceMock.ts
@@ -0,0 +1,198 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { differenceInMilliseconds, isAfter, isBefore } from 'date-fns';
+import { cloneDeep, groupBy, sortBy } from 'lodash';
+import { mockTask } from '../../helpers/mocks/tasks';
+import { RequestData } from '../../helpers/request';
+import { Task, TaskStatuses, TaskTypes } from '../../types/tasks';
+import {
+ cancelAllTasks,
+ cancelTask,
+ getActivity,
+ getStatus,
+ getTypes,
+ getWorkers,
+ setWorkerCount
+} from '../ce';
+
+const RANDOM_RADIX = 36;
+const RANDOM_PREFIX = 2;
+
+const TASK_TYPES = [
+ TaskTypes.Report,
+ TaskTypes.IssueSync,
+ TaskTypes.AuditPurge,
+ TaskTypes.ProjectExport,
+ TaskTypes.AppRefresh,
+ TaskTypes.ProjectImport,
+ TaskTypes.ViewRefresh,
+ TaskTypes.ReportSubmit
+];
+
+const DEFAULT_TASKS: Task[] = [mockTask()];
+const DEFAULT_WORKERS = {
+ canSetWorkerCount: true,
+ value: 2
+};
+
+const CANCELABLE_TASK_STATUSES = [TaskStatuses.Pending];
+
+export default class ComputeEngineServiceMock {
+ tasks: Task[];
+ workers = { ...DEFAULT_WORKERS };
+
+ constructor() {
+ (cancelAllTasks as jest.Mock).mockImplementation(this.handleCancelAllTasks);
+ (cancelTask as jest.Mock).mockImplementation(this.handleCancelTask);
+ (getActivity as jest.Mock).mockImplementation(this.handleGetActivity);
+ (getStatus as jest.Mock).mockImplementation(this.handleGetStatus);
+ (getTypes as jest.Mock).mockImplementation(this.handleGetTypes);
+ (getWorkers as jest.Mock).mockImplementation(this.handleGetWorkers);
+ (setWorkerCount as jest.Mock).mockImplementation(this.handleSetWorkerCount);
+
+ this.tasks = cloneDeep(DEFAULT_TASKS);
+ }
+
+ handleCancelAllTasks = () => {
+ this.tasks.forEach(t => {
+ if (CANCELABLE_TASK_STATUSES.includes(t.status)) {
+ t.status = TaskStatuses.Canceled;
+ }
+ });
+
+ return Promise.resolve();
+ };
+
+ handleCancelTask = (id: string) => {
+ const task = this.tasks.find(t => t.id === id);
+
+ if (task && CANCELABLE_TASK_STATUSES.includes(task.status)) {
+ task.status = TaskStatuses.Canceled;
+ return Promise.resolve(task);
+ }
+
+ return Promise.reject();
+ };
+
+ handleGetActivity = (data: RequestData) => {
+ let results = cloneDeep(this.tasks);
+
+ results = results.filter(task => {
+ return !(
+ (data.component && task.componentKey !== data.component) ||
+ (data.status && !data.status.split(',').includes(task.status)) ||
+ (data.type && task.type !== data.type) ||
+ (data.minSubmittedAt && isBefore(task.submittedAt, data.minSubmittedAt)) ||
+ (data.maxExecutedAt &&
+ (!task.executedAt || isAfter(task.executedAt, data.maxExecutedAt))) ||
+ (data.q &&
+ !task.id.includes(data.q) &&
+ !task.componentName?.includes(data.q) &&
+ !task.componentKey?.includes(data.q))
+ );
+ });
+
+ if (data.onlyCurrents) {
+ /*
+ * This is more complex in real life, but it's a good enough approximation to suit tests
+ */
+ results = Object.values(groupBy(results, t => t.componentKey)).map(
+ tasks => sortBy(tasks, t => t.executedAt).pop()!
+ );
+ }
+
+ return Promise.resolve({
+ tasks: results.slice(0, 100),
+ paging: {
+ pageIndex: 1,
+ pageSize: 100,
+ total: results.length
+ }
+ });
+ };
+
+ handleGetStatus = (component?: string) => {
+ return Promise.resolve(
+ this.tasks
+ .filter(task => !component || task.componentKey === component)
+ .reduce(
+ (stats, task) => {
+ switch (task.status) {
+ case TaskStatuses.Failed:
+ stats.failing += 1;
+ break;
+ case TaskStatuses.InProgress:
+ stats.inProgress += 1;
+ break;
+ case TaskStatuses.Pending:
+ stats.pendingTime = Math.max(
+ stats.pendingTime,
+ differenceInMilliseconds(task.submittedAt, Date.now())
+ );
+ stats.pending += 1;
+ break;
+ }
+
+ return stats;
+ },
+ { failing: 0, inProgress: 0, pending: 0, pendingTime: 0 }
+ )
+ );
+ };
+
+ handleGetTypes = () => Promise.resolve([...TASK_TYPES]);
+
+ handleGetWorkers = () => Promise.resolve({ ...this.workers });
+
+ handleSetWorkerCount = (count: number) => {
+ this.workers.value = count;
+ return Promise.resolve();
+ };
+
+ /*
+ * Helpers
+ */
+
+ reset() {
+ this.tasks = cloneDeep(DEFAULT_TASKS);
+ this.workers = { ...DEFAULT_WORKERS };
+ }
+
+ toggleCanSetWorkerCount = (flag?: boolean) => {
+ this.workers.canSetWorkerCount = flag ?? !this.workers.canSetWorkerCount;
+ };
+
+ addTask = (overrides: Partial<Task> = {}) => {
+ const id = Math.random()
+ .toString(RANDOM_RADIX)
+ .slice(RANDOM_PREFIX);
+
+ this.tasks.push(
+ mockTask({
+ id,
+ ...overrides
+ })
+ );
+ };
+
+ clearTasks = () => {
+ this.tasks = [];
+ };
+}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx
new file mode 100644
index 00000000000..e313055f445
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/BackgroundTasks-it.tsx
@@ -0,0 +1,150 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import { screen, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { UserEvent } from '@testing-library/user-event/dist/types/setup';
+import ComputeEngineServiceMock from '../../../api/mocks/ComputeEngineServiceMock';
+import { renderAdminApp } from '../../../helpers/testReactTestingUtils';
+import { TaskStatuses, TaskTypes } from '../../../types/tasks';
+import routes from '../routes';
+
+jest.mock('../../../api/ce');
+
+let computeEngineServiceMock: ComputeEngineServiceMock;
+
+beforeAll(() => {
+ computeEngineServiceMock = new ComputeEngineServiceMock();
+});
+
+afterEach(() => computeEngineServiceMock.reset());
+
+describe('The Global background task page', () => {
+ it('should display the list of workers and allow edit', async () => {
+ const user = userEvent.setup();
+
+ renderGlobalBackgroundTasksApp();
+
+ expect(
+ within(await screen.findByText('background_tasks.number_of_workers')).getByText('2')
+ ).toBeInTheDocument();
+
+ const editWorkersButton = screen.getByRole('button', { name: 'edit' });
+ expect(editWorkersButton).toBeInTheDocument();
+
+ await user.click(editWorkersButton);
+
+ const modal = screen.getByRole('dialog');
+
+ expect(
+ within(modal).getByRole('heading', { name: 'background_tasks.change_number_of_workers' })
+ ).toBeInTheDocument();
+
+ await user.click(
+ within(modal).getByLabelText('background_tasks.change_number_of_workers', {
+ selector: 'input'
+ })
+ );
+
+ await user.keyboard('[ArrowDown][ArrowDown][Enter]');
+
+ await user.click(within(modal).getByRole('button', { name: 'save' }));
+
+ expect(
+ within(await screen.findByText('background_tasks.number_of_workers')).getByText('4')
+ ).toBeInTheDocument();
+ });
+
+ it('should display the list of tasks', async () => {
+ const user = userEvent.setup();
+
+ computeEngineServiceMock.clearTasks();
+ computeEngineServiceMock.addTask({ status: TaskStatuses.Canceled, type: TaskTypes.AppRefresh });
+ computeEngineServiceMock.addTask({ status: TaskStatuses.Failed, type: TaskTypes.AppRefresh });
+ computeEngineServiceMock.addTask({
+ executedAt: '2022-02-03T11:45:36+0200',
+ submittedAt: '2022-02-03T11:45:35+0200',
+ executionTimeMs: 167,
+ status: TaskStatuses.InProgress,
+ type: TaskTypes.IssueSync
+ });
+ computeEngineServiceMock.addTask({ status: TaskStatuses.Pending, type: TaskTypes.IssueSync });
+ computeEngineServiceMock.addTask({
+ componentKey: 'otherComponent',
+ status: TaskStatuses.Success,
+ type: TaskTypes.AppRefresh
+ });
+
+ renderGlobalBackgroundTasksApp();
+
+ expect(
+ await screen.findByRole('heading', { name: 'background_tasks.page' })
+ ).toBeInTheDocument();
+
+ expect(screen.getAllByRole('row')).toHaveLength(5); // including header, excluding pending (default filter)
+
+ await changeTaskFilter(user, 'status', 'background_task.status.IN_PROGRESS');
+ expect(await screen.findAllByRole('row')).toHaveLength(2); // including header
+
+ await changeTaskFilter(user, 'status', 'background_task.status.ALL');
+ expect(await screen.findAllByRole('row')).toHaveLength(6); // including header
+
+ await changeTaskFilter(user, 'type', `background_task.type.${TaskTypes.AppRefresh}`);
+ expect(await screen.findAllByRole('row')).toHaveLength(4); // including header
+
+ await user.click(screen.getByRole('checkbox', { name: 'yes' }));
+ expect(await screen.findAllByRole('row')).toHaveLength(3); // including header
+ await user.click(screen.getByRole('checkbox', { name: 'yes' }));
+
+ /*
+ * Must test date range filters, but it requires refactoring the DateRange component
+ */
+
+ const searchBox = screen.getByPlaceholderText('background_tasks.search_by_task_or_component');
+ expect(searchBox).toBeInTheDocument();
+ await user.click(searchBox);
+ await user.keyboard('other');
+
+ expect(await screen.findAllByRole('row')).toHaveLength(2); // including header
+
+ //reset filters
+ await user.click(screen.getByRole('button', { name: 'reset_verb' }));
+ expect(screen.getAllByRole('row')).toHaveLength(5);
+
+ // reset tasks (internally) and reload:
+ computeEngineServiceMock.reset();
+ await changeTaskFilter(user, 'status', 'background_task.status.ALL');
+ await user.click(screen.getByRole('button', { name: 'reload' }));
+ expect(await screen.findAllByRole('row')).toHaveLength(2);
+ });
+
+ /*
+ * Must also test row actions
+ */
+});
+
+async function changeTaskFilter(user: UserEvent, fieldLabel: string, value: string) {
+ await user.click(screen.getByLabelText(fieldLabel, { selector: 'input' }));
+ await user.click(screen.getByText(value));
+}
+
+function renderGlobalBackgroundTasksApp() {
+ renderAdminApp('admin/background_tasks', routes, {});
+}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx
index 12c5301f716..1bc53268cc6 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx
+++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Workers.tsx
@@ -127,6 +127,7 @@ export default class Workers extends React.PureComponent<{}, State> {
<EditButton
className="js-edit button-small spacer-left"
onClick={this.handleChangeClick}
+ title={translate('edit')}
/>
</Tooltip>
)}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stats-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stats-test.tsx
deleted file mode 100644
index 7dfa14c5361..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Stats-test.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import Stats, { Props } from '../Stats';
-
-it('should render correctly', () => {
- expect(shallowRender()).toMatchSnapshot();
-});
-
-it('should render correctly for a component', () => {
- expect(shallowRender({ component: mockComponent() })).toMatchSnapshot();
-});
-
-function shallowRender(props: Partial<Props> = {}) {
- return shallow(
- <Stats
- failingCount={4}
- onCancelAllPending={jest.fn()}
- onShowFailing={jest.fn()}
- pendingCount={2}
- pendingTime={110545}
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/StatusFilter-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/StatusFilter-test.tsx
deleted file mode 100644
index f38f267dd06..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/StatusFilter-test.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import StatusFilter from '../StatusFilter';
-
-it('should render correctly', () => {
- expect(shallowRender()).toMatchSnapshot('default');
-});
-
-it('should handle change', () => {
- const onChange = jest.fn();
- const wrapper = shallowRender({ onChange });
-
- const newValue = 'status1';
-
- wrapper.instance().handleChange({ value: newValue, label: 'Status 1' });
-
- expect(onChange).toBeCalledWith(newValue);
-});
-
-function shallowRender(overrides: Partial<StatusFilter['props']> = {}) {
- return shallow<StatusFilter>(<StatusFilter onChange={jest.fn()} {...overrides} />);
-}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx
deleted file mode 100644
index 6dcd246f5c8..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/Task-test.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import { mockTask } from '../../../../helpers/mocks/tasks';
-import Task from '../Task';
-
-it('renders', () => {
- expect(
- shallow(<Task onCancelTask={jest.fn()} onFilterTask={jest.fn()} task={mockTask()} />)
- ).toMatchSnapshot();
-});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskDay-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskDay-test.tsx
deleted file mode 100644
index eddea9408b9..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskDay-test.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import TaskDay from '../TaskDay';
-
-it('renders', () => {
- expect(
- shallow(
- <TaskDay prevSubmittedAt="2017-01-01T00:00:00.000Z" submittedAt="2017-01-02T00:00:00.000Z" />
- )
- ).toMatchSnapshot();
-
- expect(
- shallow(
- <TaskDay prevSubmittedAt="2017-01-01T00:00:00.000Z" submittedAt="2017-01-01T00:00:00.000Z" />
- )
- ).toMatchSnapshot();
-});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskExecutionTime-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskExecutionTime-test.tsx
deleted file mode 100644
index 22446ae62f3..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskExecutionTime-test.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import TaskExecutionTime from '../TaskExecutionTime';
-
-it('renders', () => {
- expect(shallow(<TaskExecutionTime />)).toMatchSnapshot();
- expect(shallow(<TaskExecutionTime ms={12345} />)).toMatchSnapshot();
-});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskId-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskId-test.tsx
deleted file mode 100644
index e995e3e53d9..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskId-test.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import TaskId from '../TaskId';
-
-it('renders', () => {
- expect(shallow(<TaskId id="173" />)).toMatchSnapshot();
-});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskType-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskType-test.tsx
deleted file mode 100644
index 5693ec57954..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskType-test.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import TaskType from '../TaskType';
-
-it('renders', () => {
- expect(shallow(<TaskType type="REPORT" />)).toMatchSnapshot();
-});
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TypesFilter-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TypesFilter-test.tsx
deleted file mode 100644
index 66dc3bbbe8d..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TypesFilter-test.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import TypesFilter from '../TypesFilter';
-
-it('should render correctly', () => {
- expect(shallowRender()).toMatchSnapshot('default');
-});
-
-it('should handle change', () => {
- const onChange = jest.fn();
- const wrapper = shallowRender({ onChange });
-
- const newValue = 't1';
-
- wrapper.instance().handleChange({ value: newValue, label: 'Type 1' });
-
- expect(onChange).toBeCalledWith(newValue);
-});
-
-function shallowRender(overrides: Partial<TypesFilter['props']> = {}) {
- return shallow<TypesFilter>(
- <TypesFilter onChange={jest.fn()} types={['t1', 't2']} value="t2" {...overrides} />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Stats-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Stats-test.tsx.snap
deleted file mode 100644
index 1253b96bb1f..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Stats-test.tsx.snap
+++ /dev/null
@@ -1,33 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<section
- className="big-spacer-top big-spacer-bottom"
->
- <withAppStateContext(StatPendingCount)
- onCancelAllPending={[MockFunction]}
- pendingCount={2}
- />
- <StatPendingTime
- className="huge-spacer-left"
- pendingCount={2}
- pendingTime={110545}
- />
- <StatStillFailing
- className="huge-spacer-left"
- failingCount={4}
- onShowFailing={[MockFunction]}
- />
-</section>
-`;
-
-exports[`should render correctly for a component 1`] = `
-<section
- className="big-spacer-top big-spacer-bottom"
->
- <withAppStateContext(StatPendingCount)
- onCancelAllPending={[MockFunction]}
- pendingCount={2}
- />
-</section>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/StatusFilter-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/StatusFilter-test.tsx.snap
deleted file mode 100644
index 9610a4326dd..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/StatusFilter-test.tsx.snap
+++ /dev/null
@@ -1,42 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly: default 1`] = `
-<Select
- aria-labelledby="background-task-status-filter-label"
- className="input-medium"
- onChange={[Function]}
- options={
- Array [
- Object {
- "label": "background_task.status.ALL",
- "value": "__ALL__",
- },
- Object {
- "label": "background_task.status.ALL_EXCEPT_PENDING",
- "value": "__ALL_EXCEPT_PENDING__",
- },
- Object {
- "label": "background_task.status.PENDING",
- "value": "PENDING",
- },
- Object {
- "label": "background_task.status.IN_PROGRESS",
- "value": "IN_PROGRESS",
- },
- Object {
- "label": "background_task.status.SUCCESS",
- "value": "SUCCESS",
- },
- Object {
- "label": "background_task.status.FAILED",
- "value": "FAILED",
- },
- Object {
- "label": "background_task.status.CANCELED",
- "value": "CANCELED",
- },
- ]
- }
- searchable={false}
-/>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap
deleted file mode 100644
index 3dde355f5a6..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Task-test.tsx.snap
+++ /dev/null
@@ -1,56 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<tr>
- <TaskStatus
- status="PENDING"
- />
- <TaskComponent
- task={
- Object {
- "analysisId": "x123",
- "componentKey": "foo",
- "componentName": "Foo",
- "componentQualifier": "TRK",
- "id": "AXR8jg_0mF2ZsYr8Wzs2",
- "status": "PENDING",
- "submittedAt": "2020-09-11T11:45:35+0200",
- "type": "REPORT",
- }
- }
- />
- <TaskId
- id="AXR8jg_0mF2ZsYr8Wzs2"
- />
- <TaskSubmitter />
- <TaskDay
- submittedAt="2020-09-11T11:45:35+0200"
- />
- <TaskDate
- date="2020-09-11T11:45:35+0200"
- />
- <TaskDate
- baseDate="2020-09-11T11:45:35+0200"
- />
- <TaskDate
- baseDate="2020-09-11T11:45:35+0200"
- />
- <TaskExecutionTime />
- <TaskActions
- onCancelTask={[MockFunction]}
- onFilterTask={[MockFunction]}
- task={
- Object {
- "analysisId": "x123",
- "componentKey": "foo",
- "componentName": "Foo",
- "componentQualifier": "TRK",
- "id": "AXR8jg_0mF2ZsYr8Wzs2",
- "status": "PENDING",
- "submittedAt": "2020-09-11T11:45:35+0200",
- "type": "REPORT",
- }
- }
- />
-</tr>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskDay-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskDay-test.tsx.snap
deleted file mode 100644
index 064c7b3427f..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskDay-test.tsx.snap
+++ /dev/null
@@ -1,18 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<td
- className="thin nowrap text-right small"
->
- <DateFormatter
- date="2017-01-02T00:00:00.000Z"
- long={true}
- />
-</td>
-`;
-
-exports[`renders 2`] = `
-<td
- className="thin nowrap text-right small"
-/>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskExecutionTime-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskExecutionTime-test.tsx.snap
deleted file mode 100644
index 536d0bff76b..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskExecutionTime-test.tsx.snap
+++ /dev/null
@@ -1,15 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<td
- className="thin nowrap text-right"
-/>
-`;
-
-exports[`renders 2`] = `
-<td
- className="thin nowrap text-right"
->
- 12s
-</td>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskId-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskId-test.tsx.snap
deleted file mode 100644
index 0fe227570dc..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskId-test.tsx.snap
+++ /dev/null
@@ -1,13 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<td
- className="thin nowrap"
->
- <div
- className="note"
- >
- 173
- </div>
-</td>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskType-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskType-test.tsx.snap
deleted file mode 100644
index 67fa0621b7e..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskType-test.tsx.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<span
- className="display-inline-block note"
->
- [
- background_task.type.REPORT
- ]
-</span>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TypesFilter-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TypesFilter-test.tsx.snap
deleted file mode 100644
index 67de93d90e5..00000000000
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TypesFilter-test.tsx.snap
+++ /dev/null
@@ -1,33 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly: default 1`] = `
-<Select
- aria-labelledby="background-task-type-filter-label"
- className="input-large"
- clearable={false}
- onChange={[Function]}
- options={
- Array [
- Object {
- "label": "background_task.type.ALL",
- "value": "ALL_TYPES",
- },
- Object {
- "label": "background_task.type.t1",
- "value": "t1",
- },
- Object {
- "label": "background_task.type.t2",
- "value": "t2",
- },
- ]
- }
- searchable={false}
- value={
- Object {
- "label": "background_task.type.t2",
- "value": "t2",
- }
- }
-/>
-`;
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap
index 503841e58e2..4829f3a5f53 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/Workers-test.tsx.snap
@@ -20,6 +20,7 @@ exports[`opens form 1`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
</div>
@@ -45,6 +46,7 @@ exports[`opens form 2`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
<WorkersForm
@@ -89,6 +91,7 @@ exports[`renders 2`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
</div>
@@ -125,6 +128,7 @@ exports[`renders 3`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
</div>
@@ -187,6 +191,7 @@ exports[`updates worker count 1`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
<WorkersForm
@@ -227,6 +232,7 @@ exports[`updates worker count 2`] = `
<EditButton
className="js-edit button-small spacer-left"
onClick={[Function]}
+ title="edit"
/>
</Tooltip>
</div>
diff --git a/server/sonar-web/src/main/js/types/tasks.ts b/server/sonar-web/src/main/js/types/tasks.ts
index 33e7e93ab05..bbae8708be9 100644
--- a/server/sonar-web/src/main/js/types/tasks.ts
+++ b/server/sonar-web/src/main/js/types/tasks.ts
@@ -23,7 +23,9 @@ export enum TaskTypes {
AppRefresh = 'APP_REFRESH',
ViewRefresh = 'VIEW_REFRESH',
ProjectExport = 'PROJECT_EXPORT',
- ProjectImport = 'PROJECT_IMPORT'
+ ProjectImport = 'PROJECT_IMPORT',
+ ReportSubmit = 'REPORT_SUBMIT',
+ AuditPurge = 'AUDIT_PURGE'
}
export enum TaskStatuses {