aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViktor Vorona <viktor.vorona@sonarsource.com>2023-06-12 13:40:04 +0200
committersonartech <sonartech@sonarsource.com>2023-06-12 20:02:49 +0000
commit7191b79893f8f51258005e74d18c06620206fe11 (patch)
treef078f3f4c4657becab7653a0c730a5d6323d9ab9
parent813bedb02173884e2031a1b575f5d8a74ac27ac5 (diff)
downloadsonarqube-7191b79893f8f51258005e74d18c06620206fe11.tar.gz
sonarqube-7191b79893f8f51258005e74d18c06620206fe11.zip
SONAR-18433 RTL Migration Project Branches
-rw-r--r--server/sonar-web/src/main/js/api/mocks/BranchesServiceMock.ts109
-rw-r--r--server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/projectInformation/projectRegulatoryReport/__tests__/RegulatoryReport-it.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/ProjectBranchesApp.tsx (renamed from server/sonar-web/src/main/js/apps/projectBranches/components/ProjectBranchesApp.tsx)14
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx245
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx11
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformationRenderer.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx52
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx68
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx111
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx70
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx118
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx48
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformationRenderer-test.tsx46
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/ProjectBranchesApp-test.tsx50
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx97
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap330
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap796
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap288
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap38
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/DeleteBranchModal-test.tsx.snap82
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformation-test.tsx.snap16
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformationRenderer-test.tsx.snap60
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/ProjectBranchesApp-test.tsx.snap113
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/RenameBranchModal-test.tsx.snap190
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/routes.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx15
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx1
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
39 files changed, 372 insertions, 2624 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/BranchesServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/BranchesServiceMock.ts
index c7fb23c56e0..fa6847c1382 100644
--- a/server/sonar-web/src/main/js/api/mocks/BranchesServiceMock.ts
+++ b/server/sonar-web/src/main/js/api/mocks/BranchesServiceMock.ts
@@ -18,36 +18,111 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { cloneDeep } from 'lodash';
-import { mockBranch } from '../../helpers/mocks/branch-like';
-import { BranchLike } from '../../types/branch-like';
-import { getBranches } from '../branches';
+import { mockBranch, mockPullRequest } from '../../helpers/mocks/branch-like';
+import { Branch, PullRequest } from '../../types/branch-like';
+import {
+ deleteBranch,
+ deletePullRequest,
+ excludeBranchFromPurge,
+ getBranches,
+ getPullRequests,
+ renameBranch,
+} from '../branches';
+
+jest.mock('../branches');
+
+const defaultBranches: Branch[] = [
+ mockBranch({ isMain: true, name: 'master', status: { qualityGateStatus: 'OK' } }),
+ mockBranch({
+ excludedFromPurge: false,
+ name: 'delete-branch',
+ analysisDate: '2018-01-30',
+ status: { qualityGateStatus: 'ERROR' },
+ }),
+ mockBranch({ name: 'normal-branch', status: { qualityGateStatus: 'ERROR' } }),
+];
+
+const defaultPullRequests: PullRequest[] = [
+ mockPullRequest({
+ title: 'TEST-191 update master',
+ key: '01',
+ status: { qualityGateStatus: 'OK' },
+ }),
+ mockPullRequest({
+ title: 'TEST-192 update normal-branch',
+ key: '02',
+ analysisDate: '2018-01-30',
+ base: 'normal-branch',
+ target: 'normal-branch',
+ status: { qualityGateStatus: 'ERROR' },
+ }),
+ mockPullRequest({
+ title: 'TEST-193 dumb commit',
+ key: '03',
+ target: 'normal-branch',
+ status: { qualityGateStatus: 'ERROR' },
+ }),
+];
export default class BranchesServiceMock {
- branchLikes: BranchLike[];
- defaultBranchLikes: BranchLike[] = [
- mockBranch({ isMain: true, name: 'master' }),
- mockBranch({ excludedFromPurge: false, name: 'delete-branch' }),
- mockBranch({ name: 'normal-branch' }),
- ];
+ branches: Branch[];
+ pullRequests: PullRequest[];
constructor() {
- this.branchLikes = cloneDeep(this.defaultBranchLikes);
- (getBranches as jest.Mock).mockImplementation(this.getBranchesHandler);
+ this.branches = cloneDeep(defaultBranches);
+ this.pullRequests = cloneDeep(defaultPullRequests);
+ jest.mocked(getBranches).mockImplementation(this.getBranchesHandler);
+ jest.mocked(getPullRequests).mockImplementation(this.getPullRequestsHandler);
+ jest.mocked(deleteBranch).mockImplementation(this.deleteBranchHandler);
+ jest.mocked(deletePullRequest).mockImplementation(this.deletePullRequestHandler);
+ jest.mocked(renameBranch).mockImplementation(this.renameBranchHandler);
+ jest.mocked(excludeBranchFromPurge).mockImplementation(this.excludeBranchFromPurgeHandler);
}
getBranchesHandler = () => {
- return Promise.resolve(this.branchLikes);
+ return this.reply(this.branches);
+ };
+
+ getPullRequestsHandler = () => {
+ return this.reply(this.pullRequests);
+ };
+
+ deleteBranchHandler: typeof deleteBranch = ({ branch }) => {
+ this.branches = this.branches.filter((b) => b.name !== branch);
+ return this.reply({});
+ };
+
+ deletePullRequestHandler: typeof deletePullRequest = ({ pullRequest }) => {
+ this.pullRequests = this.pullRequests.filter((b) => b.key !== pullRequest);
+ return this.reply({});
+ };
+
+ renameBranchHandler: typeof renameBranch = (_, name) => {
+ this.branches = this.branches.map((b) => (b.isMain ? { ...b, name } : b));
+ return this.reply({});
+ };
+
+ excludeBranchFromPurgeHandler: typeof excludeBranchFromPurge = (_, name, value) => {
+ this.branches = this.branches.map((b) =>
+ b.name === name ? { ...b, excludedFromPurge: value } : b
+ );
+ return this.reply({});
};
emptyBranches = () => {
- this.branchLikes = [];
+ this.branches = [];
};
- addBranch = (branch: BranchLike) => {
- this.branchLikes.push(branch);
+ addBranch = (branch: Branch) => {
+ this.branches.push(branch);
};
- resetBranches = () => {
- this.branchLikes = cloneDeep(this.defaultBranchLikes);
+ reset = () => {
+ this.branches = cloneDeep(defaultBranches);
+ this.pullRequests = cloneDeep(defaultPullRequests);
};
+
+ reply<T>(response: T): Promise<T> {
+ return Promise.resolve(cloneDeep(response));
+ }
}
diff --git a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts
index c58f7d8473e..d5ca5119c96 100644
--- a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts
+++ b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts
@@ -40,6 +40,8 @@ import {
setSettingValue,
} from '../settings';
+jest.mock('../settings');
+
const isEmptyField = (o: any) => isObject(o) && Object.values(o).some(isEmptyString);
const isEmptyString = (i: any) => isString(i) && i.trim() === '';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/projectRegulatoryReport/__tests__/RegulatoryReport-it.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/projectRegulatoryReport/__tests__/RegulatoryReport-it.tsx
index fd6a18fda7a..00bec0d8b5c 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/projectRegulatoryReport/__tests__/RegulatoryReport-it.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/projectRegulatoryReport/__tests__/RegulatoryReport-it.tsx
@@ -26,15 +26,13 @@ import { renderComponent } from '../../../../../../../helpers/testReactTestingUt
import { BranchLike } from '../../../../../../../types/branch-like';
import RegulatoryReport from '../RegulatoryReport';
-jest.mock('../../../../../../../api/branches');
-
let handler: BranchesServiceMock;
beforeAll(() => {
handler = new BranchesServiceMock();
});
-afterEach(() => handler.resetBranches());
+afterEach(() => handler.reset());
describe('RegulatoryReport tests', () => {
it('should open the regulatory report page', async () => {
diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx
index 9474685d525..a015819f6d6 100644
--- a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx
+++ b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx
@@ -30,8 +30,6 @@ import { SettingsKey } from '../../../../types/settings';
import routes from '../../routes';
import { HousekeepingPolicy } from '../../utils';
-jest.mock('../../../../api/settings');
-
const extensions = [
{ key: AdminPageExtension.GovernanceConsole, name: 'Portfolios' },
{ key: 'license/app', name: 'License Manager' },
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/ProjectBranchesApp.tsx b/server/sonar-web/src/main/js/apps/projectBranches/ProjectBranchesApp.tsx
index 5af1f9e3ad3..48407906d2f 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/ProjectBranchesApp.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/ProjectBranchesApp.tsx
@@ -19,12 +19,12 @@
*/
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
-import withComponentContext from '../../../app/components/componentContext/withComponentContext';
-import { translate } from '../../../helpers/l10n';
-import { BranchLike } from '../../../types/branch-like';
-import { Component } from '../../../types/types';
-import BranchLikeTabs from './BranchLikeTabs';
-import LifetimeInformation from './LifetimeInformation';
+import withComponentContext from '../../app/components/componentContext/withComponentContext';
+import { translate } from '../../helpers/l10n';
+import { BranchLike } from '../../types/branch-like';
+import { Component } from '../../types/types';
+import BranchLikeTabs from './components/BranchLikeTabs';
+import LifetimeInformation from './components/LifetimeInformation';
export interface ProjectBranchesAppProps {
branchLikes: BranchLike[];
@@ -32,7 +32,7 @@ export interface ProjectBranchesAppProps {
onBranchesChange: () => void;
}
-export function ProjectBranchesApp(props: ProjectBranchesAppProps) {
+function ProjectBranchesApp(props: ProjectBranchesAppProps) {
const { branchLikes, component } = props;
return (
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx b/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx
new file mode 100644
index 00000000000..749c5c8830d
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/projectBranches/__tests__/ProjectBranchesApp-it.tsx
@@ -0,0 +1,245 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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 { act, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import React, { useEffect, useState } from 'react';
+import { byRole } from 'testing-library-selector';
+import BranchesServiceMock from '../../../api/mocks/BranchesServiceMock';
+import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock';
+import BranchStatusContextProvider from '../../../app/components/branch-status/BranchStatusContextProvider';
+import withBranchStatusActions from '../../../app/components/branch-status/withBranchStatusActions';
+import { ComponentContext } from '../../../app/components/componentContext/ComponentContext';
+import { mockComponent } from '../../../helpers/mocks/component';
+import { mockAppState } from '../../../helpers/testMocks';
+import { renderComponent } from '../../../helpers/testReactTestingUtils';
+import { AppState } from '../../../types/appstate';
+import { BranchLike } from '../../../types/branch-like';
+import { SettingsKey } from '../../../types/settings';
+import ProjectBranchesApp from '../ProjectBranchesApp';
+
+const handler = new BranchesServiceMock();
+const settingsHandler = new SettingsServiceMock();
+
+const ui = {
+ branchTabContent: byRole('tabpanel', { name: 'project_branch_pull_request.tabs.branches' }),
+ branchTabBtn: byRole('tab', { name: 'project_branch_pull_request.tabs.branches' }),
+ linkForAdmin: byRole('link', { name: 'settings.page' }),
+ renameBranchBtn: byRole('button', { name: 'project_branch_pull_request.branch.rename' }),
+ deleteBranchBtn: byRole('button', { name: 'project_branch_pull_request.branch.delete' }),
+ deletePullRequestBtn: byRole('button', {
+ name: 'project_branch_pull_request.pull_request.delete',
+ }),
+ pullRequestTabContent: byRole('tabpanel', {
+ name: 'project_branch_pull_request.tabs.pull_requests',
+ }),
+ pullRequestTabBtn: byRole('tab', {
+ name: 'project_branch_pull_request.tabs.pull_requests',
+ }),
+ renameBranchDialog: byRole('dialog', { name: 'project_branch_pull_request.branch.rename' }),
+ deleteBranchDialog: byRole('dialog', { name: 'project_branch_pull_request.branch.delete' }),
+ deletePullRequestDialog: byRole('dialog', {
+ name: 'project_branch_pull_request.pull_request.delete',
+ }),
+ updateMasterBtn: byRole('button', {
+ name: 'project_branch_pull_request.branch.actions_label.master',
+ }),
+ updateSecondBranchBtn: byRole('button', {
+ name: 'project_branch_pull_request.branch.actions_label.delete-branch',
+ }),
+ updateFirstPRBtn: byRole('button', {
+ name: 'project_branch_pull_request.branch.actions_label.01 – TEST-191 update master',
+ }),
+ getBranchRow: () => within(ui.branchTabContent.get()).getAllByRole('row'),
+ getPullRequestRow: () => within(ui.pullRequestTabContent.get()).getAllByRole('row'),
+};
+
+beforeAll(() => {
+ jest.useFakeTimers({
+ advanceTimers: true,
+ now: new Date('2018-02-01T07:08:59Z'),
+ });
+});
+
+beforeEach(() => {
+ handler.reset();
+ settingsHandler.reset();
+});
+
+it('should show all branches', async () => {
+ renderProjectBranchesApp();
+ expect(await ui.branchTabContent.find()).toBeInTheDocument();
+ expect(ui.pullRequestTabContent.query()).not.toBeInTheDocument();
+ expect(ui.linkForAdmin.query()).not.toBeInTheDocument();
+ expect(ui.getBranchRow()).toHaveLength(4);
+ expect(ui.getBranchRow()[1]).toHaveTextContent('masterbranches.main_branchOK1 month ago');
+ expect(within(ui.getBranchRow()[1]).getByRole('switch')).toBeDisabled();
+ expect(within(ui.getBranchRow()[1]).getByRole('switch')).toBeChecked();
+ expect(ui.getBranchRow()[2]).toHaveTextContent('delete-branchERROR2 days ago');
+ expect(within(ui.getBranchRow()[2]).getByRole('switch')).toBeEnabled();
+ expect(within(ui.getBranchRow()[2]).getByRole('switch')).not.toBeChecked();
+});
+
+it('should show link to change purge options for admin', async () => {
+ settingsHandler.set(SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs, '3');
+ renderProjectBranchesApp({ canAdmin: true });
+ expect(await ui.linkForAdmin.find()).toBeInTheDocument();
+});
+
+it('should be able to rename main branch, but not others', async () => {
+ const user = userEvent.setup();
+ renderProjectBranchesApp();
+ await user.click(await ui.updateMasterBtn.find());
+ expect(ui.renameBranchBtn.get()).toBeInTheDocument();
+ await user.click(ui.renameBranchBtn.get());
+ expect(ui.renameBranchDialog.get()).toBeInTheDocument();
+ expect(within(ui.renameBranchDialog.get()).getByRole('textbox')).toHaveValue('master');
+ expect(
+ within(ui.renameBranchDialog.get()).getByRole('button', { name: 'rename' })
+ ).toBeDisabled();
+ await user.clear(within(ui.renameBranchDialog.get()).getByRole('textbox'));
+ expect(
+ within(ui.renameBranchDialog.get()).getByRole('button', { name: 'rename' })
+ ).toBeDisabled();
+ await user.type(within(ui.renameBranchDialog.get()).getByRole('textbox'), 'main');
+ expect(within(ui.renameBranchDialog.get()).getByRole('button', { name: 'rename' })).toBeEnabled();
+ await act(() =>
+ user.click(within(ui.renameBranchDialog.get()).getByRole('button', { name: 'rename' }))
+ );
+ expect(ui.getBranchRow()[1]).toHaveTextContent('mainbranches.main_branchOK1 month ago');
+
+ await user.click(await ui.updateSecondBranchBtn.find());
+ expect(ui.renameBranchBtn.query()).not.toBeInTheDocument();
+});
+
+it('should be able to delete branch, but not main', async () => {
+ const user = userEvent.setup();
+ renderProjectBranchesApp();
+ await user.click(await ui.updateSecondBranchBtn.find());
+ expect(ui.deleteBranchBtn.get()).toBeInTheDocument();
+ await user.click(ui.deleteBranchBtn.get());
+ expect(ui.deleteBranchDialog.get()).toBeInTheDocument();
+ expect(ui.deleteBranchDialog.get()).toHaveTextContent('delete-branch');
+ await act(() =>
+ user.click(within(ui.deleteBranchDialog.get()).getByRole('button', { name: 'delete' }))
+ );
+ expect(ui.getBranchRow()).toHaveLength(3);
+
+ await user.click(await ui.updateMasterBtn.find());
+ expect(ui.deleteBranchBtn.query()).not.toBeInTheDocument();
+});
+
+it('should exclude from purge', async () => {
+ const user = userEvent.setup();
+ renderProjectBranchesApp();
+ expect(await ui.branchTabContent.find()).toBeInTheDocument();
+ expect(within(ui.getBranchRow()[2]).getByRole('switch')).not.toBeChecked();
+ await act(() => user.click(within(ui.getBranchRow()[2]).getByRole('switch')));
+ expect(within(ui.getBranchRow()[2]).getByRole('switch')).toBeChecked();
+
+ expect(within(ui.getBranchRow()[3]).getByRole('switch')).toBeChecked();
+ await act(() => user.click(within(ui.getBranchRow()[3]).getByRole('switch')));
+ expect(within(ui.getBranchRow()[3]).getByRole('switch')).not.toBeChecked();
+
+ await user.click(ui.pullRequestTabBtn.get());
+ await user.click(ui.branchTabBtn.get());
+ expect(within(ui.getBranchRow()[2]).getByRole('switch')).toBeChecked();
+ expect(within(ui.getBranchRow()[3]).getByRole('switch')).not.toBeChecked();
+});
+
+it('should show all pull requests', async () => {
+ const user = userEvent.setup();
+ renderProjectBranchesApp();
+ await user.click(await ui.pullRequestTabBtn.find());
+ expect(await ui.pullRequestTabContent.find()).toBeInTheDocument();
+ expect(ui.branchTabContent.query()).not.toBeInTheDocument();
+ expect(ui.getPullRequestRow()).toHaveLength(4);
+ expect(ui.getPullRequestRow()[1]).toHaveTextContent('01 – TEST-191 update masterOK1 month ago');
+ expect(ui.getPullRequestRow()[2]).toHaveTextContent(
+ '02 – TEST-192 update normal-branchERROR2 days ago'
+ );
+});
+
+it('should delete pull requests', async () => {
+ const user = userEvent.setup();
+ renderProjectBranchesApp();
+ await user.click(await ui.pullRequestTabBtn.find());
+ expect(ui.getPullRequestRow()).toHaveLength(4);
+ await user.click(ui.updateFirstPRBtn.get());
+ await user.click(ui.deletePullRequestBtn.get());
+ expect(await ui.deletePullRequestDialog.find()).toBeInTheDocument();
+ expect(ui.deletePullRequestDialog.get()).toHaveTextContent('01 – TEST-191 update master');
+ await act(() =>
+ user.click(within(ui.deletePullRequestDialog.get()).getByRole('button', { name: 'delete' }))
+ );
+ expect(ui.getPullRequestRow()).toHaveLength(3);
+});
+
+function renderProjectBranchesApp(overrides?: Partial<AppState>) {
+ function TestWrapper(props: any) {
+ const [init, setInit] = useState<boolean>(false);
+ const [branches, setBranches] = useState<BranchLike[]>([
+ ...handler.branches,
+ ...handler.pullRequests,
+ ]);
+
+ const updateBranches = (branches: BranchLike[]) => {
+ branches.forEach((item) => {
+ props.updateBranchStatus(item, 'my-project', item.status?.qualityGateStatus);
+ });
+ };
+
+ useEffect(() => {
+ updateBranches(branches);
+ setInit(true);
+ }, []);
+
+ const onBranchesChange = () => {
+ const changedBranches = [...handler.branches, ...handler.pullRequests];
+ updateBranches(changedBranches);
+ setBranches(changedBranches);
+ };
+
+ return init ? (
+ <ComponentContext.Provider
+ value={{
+ branchLikes: branches,
+ onBranchesChange,
+ onComponentChange: jest.fn(),
+ component: mockComponent(),
+ }}
+ >
+ {props.children}
+ </ComponentContext.Provider>
+ ) : null;
+ }
+
+ const Wrapper = withBranchStatusActions(TestWrapper);
+
+ return renderComponent(
+ <BranchStatusContextProvider>
+ <Wrapper>
+ <ProjectBranchesApp />
+ </Wrapper>
+ </BranchStatusContextProvider>,
+ '/',
+ { appState: mockAppState(overrides) }
+ );
+}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
index 567e4c1f494..35d510b0e69 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx
@@ -28,7 +28,7 @@ import {
isMainBranch,
isPullRequest,
} from '../../../helpers/branch-like';
-import { translate } from '../../../helpers/l10n';
+import { translate, translateWithParameters } from '../../../helpers/l10n';
import { BranchLike } from '../../../types/branch-like';
import { Component } from '../../../types/types';
import BranchPurgeSetting from './BranchPurgeSetting';
@@ -42,7 +42,7 @@ export interface BranchLikeRowProps {
onUpdatePurgeSetting: () => void;
}
-export function BranchLikeRow(props: BranchLikeRowProps) {
+function BranchLikeRow(props: BranchLikeRowProps) {
const { branchLike, component, displayPurgeSetting } = props;
const branchLikeDisplayName = getBranchLikeDisplayName(branchLike);
@@ -71,7 +71,12 @@ export function BranchLikeRow(props: BranchLikeRowProps) {
</td>
)}
<td className="nowrap">
- <ActionsDropdown>
+ <ActionsDropdown
+ label={translateWithParameters(
+ 'project_branch_pull_request.branch.actions_label',
+ getBranchLikeDisplayName(branchLike)
+ )}
+ >
{isMainBranch(branchLike) ? (
<ActionsDropdownItem className="js-rename" onClick={props.onRename}>
{translate('project_branch_pull_request.branch.rename')}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
index a44371244be..6cde13e2517 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx
@@ -35,7 +35,7 @@ export interface BranchLikeTableProps {
title: string;
}
-export function BranchLikeTable(props: BranchLikeTableProps) {
+function BranchLikeTable(props: BranchLikeTableProps) {
const { branchLikes, component, displayPurgeSetting, title } = props;
return (
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx
index 64e6f192c02..16cb1d4e8fc 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformation.tsx
@@ -33,7 +33,7 @@ interface State {
loading: boolean;
}
-export class LifetimeInformation extends React.PureComponent<Props, State> {
+class LifetimeInformation extends React.PureComponent<Props, State> {
mounted = false;
state: State = { loading: true };
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformationRenderer.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformationRenderer.tsx
index 52dc436c055..edb949f5f50 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformationRenderer.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LifetimeInformationRenderer.tsx
@@ -30,7 +30,7 @@ export interface LifetimeInformationRendererProps {
loading: boolean;
}
-export function LifetimeInformationRenderer(props: LifetimeInformationRendererProps) {
+function LifetimeInformationRenderer(props: LifetimeInformationRendererProps) {
const { branchAndPullRequestLifeTimeInDays, canAdmin, loading } = props;
return (
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx
deleted file mode 100644
index 2dfb749a3ba..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeRow-test.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 { mockBranch, mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { BranchLikeRow, BranchLikeRowProps } from '../BranchLikeRow';
-
-it('should render correctly for pull request', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render correctly for branch', () => {
- const wrapper = shallowRender({ branchLike: mockBranch(), displayPurgeSetting: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render correctly for main branch', () => {
- const wrapper = shallowRender({ branchLike: mockMainBranch(), displayPurgeSetting: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-function shallowRender(props?: Partial<BranchLikeRowProps>) {
- return shallow(
- <BranchLikeRow
- branchLike={mockPullRequest()}
- component={mockComponent()}
- onDelete={jest.fn()}
- onRename={jest.fn()}
- onUpdatePurgeSetting={jest.fn()}
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx
deleted file mode 100644
index c4492067c1e..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTable-test.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { BranchLikeRow } from '../BranchLikeRow';
-import { BranchLikeTable, BranchLikeTableProps } from '../BranchLikeTable';
-
-it('should render correctly', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render purge setting correctly', () => {
- const wrapper = shallowRender({ displayPurgeSetting: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should properly propagate delete event', () => {
- const onDelete = jest.fn();
- const wrapper = shallowRender({ onDelete });
-
- wrapper.find(BranchLikeRow).first().props().onDelete();
-
- expect(onDelete).toHaveBeenCalled();
-});
-
-it('should properly propagate rename event', () => {
- const onDelete = jest.fn();
- const onRename = jest.fn();
- const wrapper = shallowRender({ onDelete, onRename });
-
- wrapper.find(BranchLikeRow).first().props().onRename();
-
- expect(onRename).toHaveBeenCalled();
-});
-
-function shallowRender(props?: Partial<BranchLikeTableProps>) {
- return shallow(
- <BranchLikeTable
- branchLikes={mockSetOfBranchAndPullRequest()}
- component={mockComponent()}
- onDelete={jest.fn()}
- onRename={jest.fn()}
- onUpdatePurgeSetting={jest.fn()}
- title="title"
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx
deleted file mode 100644
index d4520944979..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchLikeTabs-test.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 BoxedTabs from '../../../../components/controls/BoxedTabs';
-import {
- mockMainBranch,
- mockPullRequest,
- mockSetOfBranchAndPullRequest,
-} from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { BranchLikeTable } from '../BranchLikeTable';
-import BranchLikeTabs, { Tabs } from '../BranchLikeTabs';
-import DeleteBranchModal from '../DeleteBranchModal';
-import RenameBranchModal from '../RenameBranchModal';
-
-it('should render all tabs correctly', () => {
- const wrapper = shallowRender();
-
- expect(wrapper.state().currentTab).toBe(Tabs.Branch);
- expect(wrapper).toMatchSnapshot();
-
- const onSelect = wrapper.find(BoxedTabs).prop('onSelect') as (currentTab: Tabs) => void;
- onSelect(Tabs.PullRequest);
-
- expect(wrapper.state().currentTab).toBe(Tabs.PullRequest);
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render deletion modal correctly', () => {
- const onBranchesChange = jest.fn();
- const wrapper = shallowRender({ onBranchesChange });
-
- wrapper.find(BranchLikeTable).props().onDelete(mockPullRequest());
- expect(wrapper.state().deleting).toBeDefined();
- expect(wrapper.find(DeleteBranchModal)).toMatchSnapshot();
-
- wrapper.find(DeleteBranchModal).props().onClose();
- expect(wrapper.state().deleting).toBeUndefined();
- expect(wrapper.find(DeleteBranchModal).exists()).toBe(false);
-
- wrapper.find(BranchLikeTable).props().onDelete(mockPullRequest());
- wrapper.find(DeleteBranchModal).props().onDelete();
- expect(wrapper.state().deleting).toBeUndefined();
- expect(wrapper.find(DeleteBranchModal).exists()).toBe(false);
- expect(onBranchesChange).toHaveBeenCalled();
-});
-
-it('should render renaming modal correctly', () => {
- const onBranchesChange = jest.fn();
- const wrapper = shallowRender({ onBranchesChange });
-
- wrapper.find(BranchLikeTable).props().onRename(mockMainBranch());
- expect(wrapper.state().renaming).toBeDefined();
- expect(wrapper.find(RenameBranchModal)).toMatchSnapshot();
-
- wrapper.find(RenameBranchModal).props().onClose();
- expect(wrapper.state().renaming).toBeUndefined();
- expect(wrapper.find(RenameBranchModal).exists()).toBe(false);
-
- wrapper.find(BranchLikeTable).props().onRename(mockMainBranch());
- wrapper.find(RenameBranchModal).props().onRename();
- expect(wrapper.state().renaming).toBeUndefined();
- expect(wrapper.find(RenameBranchModal).exists()).toBe(false);
- expect(onBranchesChange).toHaveBeenCalled();
-});
-
-it('should NOT render renaming modal for non-main branch', () => {
- const wrapper = shallowRender();
-
- wrapper.find(BranchLikeTable).props().onRename(mockPullRequest());
- expect(wrapper.state().renaming).toBeDefined();
- expect(wrapper.find(RenameBranchModal).exists()).toBe(false);
-});
-
-it('should correctly propagate an update of purge settings', () => {
- const onBranchesChange = jest.fn();
- const wrapper = shallowRender({ onBranchesChange });
-
- wrapper.find(BranchLikeTable).props().onUpdatePurgeSetting();
-
- expect(onBranchesChange).toHaveBeenCalled();
-});
-
-function shallowRender(props: Partial<BranchLikeTabs['props']> = {}) {
- return shallow<BranchLikeTabs>(
- <BranchLikeTabs
- branchLikes={mockSetOfBranchAndPullRequest()}
- component={mockComponent()}
- onBranchesChange={jest.fn()}
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx
deleted file mode 100644
index 1c5ea5a54f2..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchPurgeSetting-test.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 { excludeBranchFromPurge } from '../../../../api/branches';
-import Toggle from '../../../../components/controls/Toggle';
-import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { waitAndUpdate } from '../../../../helpers/testUtils';
-import BranchPurgeSetting from '../BranchPurgeSetting';
-
-jest.mock('../../../../api/branches', () => ({
- excludeBranchFromPurge: jest.fn().mockResolvedValue({}),
-}));
-
-beforeEach(() => jest.clearAllMocks());
-
-it('should render correctly for a non-main branch', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.state().excludedFromPurge).toBe(true);
-});
-
-it('should render correctly for a main branch', () => {
- const wrapper = shallowRender({ branch: mockMainBranch({ excludedFromPurge: true }) });
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.state().excludedFromPurge).toBe(true);
-});
-
-it('should correctly call the webservice if the user changes the value', async () => {
- const onUpdatePurgeSetting = jest.fn();
- const wrapper = shallowRender({ onUpdatePurgeSetting });
- expect(wrapper.state().excludedFromPurge).toBe(true);
-
- const { onChange } = wrapper.find(Toggle).props();
-
- onChange!(false);
- expect(excludeBranchFromPurge).toHaveBeenCalled();
- expect(wrapper.state().excludedFromPurge).toBe(true);
- await waitAndUpdate(wrapper);
- expect(onUpdatePurgeSetting).toHaveBeenCalled();
-});
-
-function shallowRender(props?: Partial<BranchPurgeSetting['props']>) {
- return shallow<BranchPurgeSetting>(
- <BranchPurgeSetting
- branch={mockBranch({ excludedFromPurge: true })}
- component={mockComponent()}
- onUpdatePurgeSetting={jest.fn()}
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx
deleted file mode 100644
index 0474e071626..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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, ShallowWrapper } from 'enzyme';
-import * as React from 'react';
-import { deleteBranch, deletePullRequest } from '../../../../api/branches';
-import { mockBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { click, doAsync, submit, waitAndUpdate } from '../../../../helpers/testUtils';
-import { BranchLike } from '../../../../types/branch-like';
-import DeleteBranchModal from '../DeleteBranchModal';
-
-jest.mock('../../../../api/branches', () => ({
- deleteBranch: jest.fn(),
- deletePullRequest: jest.fn(),
-}));
-
-const branch = mockBranch({ name: 'feature/foo' });
-
-beforeEach(() => {
- jest.clearAllMocks();
-});
-
-it('renders', () => {
- const wrapper = shallowRender(branch);
- expect(wrapper).toMatchSnapshot();
- wrapper.setState({ loading: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('deletes branch', async () => {
- (deleteBranch as jest.Mock).mockImplementationOnce(() => Promise.resolve());
- const onDelete = jest.fn();
- const wrapper = shallowRender(branch, onDelete);
-
- submitForm(wrapper);
-
- await waitAndUpdate(wrapper);
- expect(wrapper.state().loading).toBe(false);
- expect(onDelete).toHaveBeenCalled();
- expect(deleteBranch).toHaveBeenCalledWith({ branch: 'feature/foo', project: 'foo' });
-});
-
-it('deletes pull request', async () => {
- (deletePullRequest as jest.Mock).mockImplementationOnce(() => Promise.resolve());
- const pullRequest = mockPullRequest();
- const onDelete = jest.fn();
- const wrapper = shallowRender(pullRequest, onDelete);
-
- submitForm(wrapper);
-
- await waitAndUpdate(wrapper);
- expect(wrapper.state().loading).toBe(false);
- expect(onDelete).toHaveBeenCalled();
- expect(deletePullRequest).toHaveBeenCalledWith({ project: 'foo', pullRequest: '1001' });
-});
-
-it('cancels', () => {
- const onClose = jest.fn();
- const wrapper = shallowRender(branch, jest.fn(), onClose);
-
- click(wrapper.find('ResetButtonLink'));
-
- return doAsync().then(() => {
- expect(onClose).toHaveBeenCalled();
- });
-});
-
-it('stops loading on WS error', async () => {
- (deleteBranch as jest.Mock).mockImplementationOnce(() => Promise.reject(null));
- const onDelete = jest.fn();
- const wrapper = shallowRender(branch, onDelete);
-
- submitForm(wrapper);
-
- await waitAndUpdate(wrapper);
- expect(wrapper.state().loading).toBe(false);
- expect(onDelete).not.toHaveBeenCalled();
- expect(deleteBranch).toHaveBeenCalledWith({ branch: 'feature/foo', project: 'foo' });
-});
-
-function shallowRender(
- branchLike: BranchLike,
- onDelete: () => void = jest.fn(),
- onClose: () => void = jest.fn()
-) {
- const wrapper = shallow<DeleteBranchModal>(
- <DeleteBranchModal
- branchLike={branchLike}
- component={mockComponent({ key: 'foo' })}
- onClose={onClose}
- onDelete={onDelete}
- />
- );
- wrapper.instance().mounted = true;
- return wrapper;
-}
-
-function submitForm(wrapper: ShallowWrapper<any, any>) {
- submit(wrapper.find('form'));
- expect(wrapper.state().loading).toBe(true);
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx
deleted file mode 100644
index 8bbbb0389a0..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformation-test.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 { getValue } from '../../../../api/settings';
-import { mockAppState } from '../../../../helpers/testMocks';
-import { waitAndUpdate } from '../../../../helpers/testUtils';
-import { SettingsKey } from '../../../../types/settings';
-import { LifetimeInformation } from '../LifetimeInformation';
-
-jest.mock('../../../../api/settings', () => ({
- getValue: jest.fn().mockResolvedValue({ value: '45' }),
-}));
-
-it('should render correctly', async () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot('initial_state');
-
- await waitAndUpdate(wrapper);
-
- expect(getValue).toHaveBeenCalledWith({
- key: SettingsKey.DaysBeforeDeletingInactiveBranchesAndPRs,
- });
- expect(wrapper).toMatchSnapshot('after_fetching_data');
-});
-
-function shallowRender(props: Partial<LifetimeInformation['props']> = {}) {
- return shallow<LifetimeInformation>(
- <LifetimeInformation appState={mockAppState({ canAdmin: true })} {...props} />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformationRenderer-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformationRenderer-test.tsx
deleted file mode 100644
index 8b55a1e8b9f..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LifetimeInformationRenderer-test.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 {
- LifetimeInformationRenderer,
- LifetimeInformationRendererProps,
-} from '../LifetimeInformationRenderer';
-
-it('should render correctly', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render correctly when user is admin', () => {
- const wrapper = shallowRender({ canAdmin: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should render correctly if not lifetime has been fetch', () => {
- const wrapper = shallowRender({ branchAndPullRequestLifeTimeInDays: undefined });
- expect(wrapper).toMatchSnapshot();
-});
-
-function shallowRender(props?: Partial<LifetimeInformationRendererProps>) {
- return shallow(
- <LifetimeInformationRenderer branchAndPullRequestLifeTimeInDays="30" loading {...props} />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/ProjectBranchesApp-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/ProjectBranchesApp-test.tsx
deleted file mode 100644
index f40f77a293c..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/ProjectBranchesApp-test.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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 { mockSetOfBranchAndPullRequest } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import BranchLikeTabs from '../BranchLikeTabs';
-import { ProjectBranchesApp, ProjectBranchesAppProps } from '../ProjectBranchesApp';
-
-it('should render correctly', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should properly notify that a branch or a pr has been changed/deleted', () => {
- const onBranchesChange = jest.fn();
- const wrapper = shallowRender({ onBranchesChange });
-
- wrapper.find(BranchLikeTabs).props().onBranchesChange();
-
- expect(onBranchesChange).toHaveBeenCalled();
-});
-
-function shallowRender(props?: Partial<ProjectBranchesAppProps>) {
- return shallow(
- <ProjectBranchesApp
- branchLikes={mockSetOfBranchAndPullRequest()}
- component={mockComponent()}
- onBranchesChange={jest.fn()}
- {...props}
- />
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx
deleted file mode 100644
index 89dcb640df2..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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, ShallowWrapper } from 'enzyme';
-import * as React from 'react';
-import { renameBranch } from '../../../../api/branches';
-import { mockMainBranch } from '../../../../helpers/mocks/branch-like';
-import { mockComponent } from '../../../../helpers/mocks/component';
-import { change, click, doAsync, submit, waitAndUpdate } from '../../../../helpers/testUtils';
-import RenameBranchModal from '../RenameBranchModal';
-
-jest.mock('../../../../api/branches', () => ({ renameBranch: jest.fn() }));
-
-beforeEach(() => {
- (renameBranch as jest.Mock<any>).mockClear();
-});
-
-it('renders', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
- wrapper.setState({ name: 'dev' });
- expect(wrapper).toMatchSnapshot();
- wrapper.setState({ loading: true });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('renames branch', async () => {
- (renameBranch as jest.Mock<any>).mockImplementation(() => Promise.resolve());
- const onRename = jest.fn();
- const wrapper = shallowRender(onRename);
-
- fillAndSubmit(wrapper);
-
- await waitAndUpdate(wrapper);
- expect(wrapper.state().loading).toBe(false);
- expect(onRename).toHaveBeenCalled();
- expect(renameBranch).toHaveBeenCalledWith('foo', 'dev');
-});
-
-it('cancels', () => {
- const onClose = jest.fn();
- const wrapper = shallowRender(jest.fn(), onClose);
-
- click(wrapper.find('ResetButtonLink'));
-
- return doAsync().then(() => {
- expect(onClose).toHaveBeenCalled();
- });
-});
-
-it('stops loading on WS error', async () => {
- (renameBranch as jest.Mock<any>).mockImplementation(() => Promise.reject(null));
- const onRename = jest.fn();
- const wrapper = shallowRender(onRename);
-
- fillAndSubmit(wrapper);
-
- await waitAndUpdate(wrapper);
- expect(wrapper.state().loading).toBe(false);
- expect(onRename).not.toHaveBeenCalled();
-});
-
-function shallowRender(onRename: () => void = jest.fn(), onClose: () => void = jest.fn()) {
- const branch = mockMainBranch();
- const wrapper = shallow<RenameBranchModal>(
- <RenameBranchModal
- branch={branch}
- component={mockComponent({ key: 'foo' })}
- onClose={onClose}
- onRename={onRename}
- />
- );
- wrapper.instance().mounted = true;
- return wrapper;
-}
-
-function fillAndSubmit(wrapper: ShallowWrapper<any, any>) {
- change(wrapper.find('input'), 'dev');
- submit(wrapper.find('form'));
- expect(wrapper.state().loading).toBe(true);
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap
deleted file mode 100644
index cbebf013b8d..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeRow-test.tsx.snap
+++ /dev/null
@@ -1,330 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly for branch 1`] = `
-<tr>
- <td
- className="nowrap hide-overflow"
- >
- <BranchLikeIcon
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-6.7",
- }
- }
- className="little-spacer-right"
- />
- <span
- title="branch-6.7"
- >
- branch-6.7
- </span>
- <span />
- </td>
- <td
- className="nowrap"
- >
- <withBranchStatus(BranchStatus)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-6.7",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- />
- </td>
- <td
- className="nowrap"
- >
- <DateFromNow
- date="2018-01-01"
- />
- </td>
- <td
- className="nowrap js-test-purge-toggle-container"
- >
- <BranchPurgeSetting
- branch={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-6.7",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- onUpdatePurgeSetting={[MockFunction]}
- />
- </td>
- <td
- className="nowrap"
- >
- <ActionsDropdown>
- <ActionsDropdownItem
- className="js-delete"
- destructive={true}
- onClick={[MockFunction]}
- >
- project_branch_pull_request.branch.delete
- </ActionsDropdownItem>
- </ActionsDropdown>
- </td>
-</tr>
-`;
-
-exports[`should render correctly for main branch 1`] = `
-<tr>
- <td
- className="nowrap hide-overflow"
- >
- <BranchLikeIcon
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- className="little-spacer-right"
- />
- <span
- title="master"
- >
- master
- </span>
- <span>
- <div
- className="badge spacer-left"
- >
- branches.main_branch
- </div>
- </span>
- </td>
- <td
- className="nowrap"
- >
- <withBranchStatus(BranchStatus)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- />
- </td>
- <td
- className="nowrap"
- >
- <DateFromNow
- date="2018-01-01"
- />
- </td>
- <td
- className="nowrap js-test-purge-toggle-container"
- >
- <BranchPurgeSetting
- branch={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- onUpdatePurgeSetting={[MockFunction]}
- />
- </td>
- <td
- className="nowrap"
- >
- <ActionsDropdown>
- <ActionsDropdownItem
- className="js-rename"
- onClick={[MockFunction]}
- >
- project_branch_pull_request.branch.rename
- </ActionsDropdownItem>
- </ActionsDropdown>
- </td>
-</tr>
-`;
-
-exports[`should render correctly for pull request 1`] = `
-<tr>
- <td
- className="nowrap hide-overflow"
- >
- <BranchLikeIcon
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1001",
- "target": "master",
- "title": "Foo Bar feature",
- }
- }
- className="little-spacer-right"
- />
- <span
- title="1001 – Foo Bar feature"
- >
- 1001 – Foo Bar feature
- </span>
- <span />
- </td>
- <td
- className="nowrap"
- >
- <withBranchStatus(BranchStatus)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1001",
- "target": "master",
- "title": "Foo Bar feature",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- />
- </td>
- <td
- className="nowrap"
- >
- <DateFromNow
- date="2018-01-01"
- />
- </td>
- <td
- className="nowrap"
- >
- <ActionsDropdown>
- <ActionsDropdownItem
- className="js-delete"
- destructive={true}
- onClick={[MockFunction]}
- >
- project_branch_pull_request.pull_request.delete
- </ActionsDropdownItem>
- </ActionsDropdown>
- </td>
-</tr>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap
deleted file mode 100644
index 4e6508c8157..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTable-test.tsx.snap
+++ /dev/null
@@ -1,796 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<div
- className="boxed-group boxed-group-inner"
->
- <table
- className="data zebra zebra-hover fixed"
- >
- <thead>
- <tr>
- <th
- className="nowrap"
- >
- title
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "80px",
- }
- }
- >
- status
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "140px",
- }
- }
- >
- project_branch_pull_request.last_analysis_date
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "50px",
- }
- }
- >
- actions
- </th>
- </tr>
- </thead>
- <tbody>
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-11",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-branch-11"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-1",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-branch-1"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-master"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1",
- "target": "master",
- "title": "PR-1",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="pull-request-1"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-12",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-branch-12"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "2",
- "target": "master",
- "title": "PR-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="pull-request-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-3",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-branch-3"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="branch-branch-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "isOrphan": true,
- "key": "2",
- "target": "llb-100",
- "title": "PR-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- key="pull-request-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- </tbody>
- </table>
-</div>
-`;
-
-exports[`should render purge setting correctly 1`] = `
-<div
- className="boxed-group boxed-group-inner"
->
- <table
- className="data zebra zebra-hover fixed"
- >
- <thead>
- <tr>
- <th
- className="nowrap"
- >
- title
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "80px",
- }
- }
- >
- status
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "140px",
- }
- }
- >
- project_branch_pull_request.last_analysis_date
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "150px",
- }
- }
- >
- <div
- className="display-flex-center"
- >
- <span>
- project_branch_pull_request.branch.auto_deletion.keep_when_inactive
- </span>
- <HelpTooltip
- className="little-spacer-left"
- overlay="project_branch_pull_request.branch.auto_deletion.keep_when_inactive.tooltip"
- />
- </div>
- </th>
- <th
- className="nowrap"
- style={
- {
- "width": "50px",
- }
- }
- >
- actions
- </th>
- </tr>
- </thead>
- <tbody>
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-11",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-branch-11"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-1",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-branch-1"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-master"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1",
- "target": "master",
- "title": "PR-1",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="pull-request-1"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-12",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-branch-12"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "2",
- "target": "master",
- "title": "PR-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="pull-request-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-3",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-branch-3"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="branch-branch-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- <Memo(BranchLikeRow)
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "isOrphan": true,
- "key": "2",
- "target": "llb-100",
- "title": "PR-2",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- key="pull-request-2"
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[MockFunction]}
- />
- </tbody>
- </table>
-</div>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap
deleted file mode 100644
index 389f07bf460..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchLikeTabs-test.tsx.snap
+++ /dev/null
@@ -1,288 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render all tabs correctly 1`] = `
-<Fragment>
- <BoxedTabs
- className="branch-like-tabs"
- onSelect={[Function]}
- selected={0}
- tabs={
- [
- {
- "key": 0,
- "label": <React.Fragment>
- <BranchIcon />
- <span
- className="spacer-left"
- >
- project_branch_pull_request.tabs.branches
- </span>
- </React.Fragment>,
- },
- {
- "key": 1,
- "label": <React.Fragment>
- <PullRequestIcon />
- <span
- className="spacer-left"
- >
- project_branch_pull_request.tabs.pull_requests
- </span>
- </React.Fragment>,
- },
- ]
- }
- />
- <div
- aria-labelledby="tab-0"
- id="tabpanel-0"
- role="tabpanel"
- >
- <Memo(BranchLikeTable)
- branchLikes={
- [
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-1",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-11",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-12",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-2",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-3",
- },
- ]
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={true}
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[Function]}
- title="project_branch_pull_request.table.branch"
- />
- </div>
-</Fragment>
-`;
-
-exports[`should render all tabs correctly 2`] = `
-<Fragment>
- <BoxedTabs
- className="branch-like-tabs"
- onSelect={[Function]}
- selected={1}
- tabs={
- [
- {
- "key": 0,
- "label": <React.Fragment>
- <BranchIcon />
- <span
- className="spacer-left"
- >
- project_branch_pull_request.tabs.branches
- </span>
- </React.Fragment>,
- },
- {
- "key": 1,
- "label": <React.Fragment>
- <PullRequestIcon />
- <span
- className="spacer-left"
- >
- project_branch_pull_request.tabs.pull_requests
- </span>
- </React.Fragment>,
- },
- ]
- }
- />
- <div
- aria-labelledby="tab-1"
- id="tabpanel-1"
- role="tabpanel"
- >
- <Memo(BranchLikeTable)
- branchLikes={
- [
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1",
- "target": "master",
- "title": "PR-1",
- },
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "2",
- "target": "master",
- "title": "PR-2",
- },
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "isOrphan": true,
- "key": "2",
- "target": "llb-100",
- "title": "PR-2",
- },
- ]
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- displayPurgeSetting={false}
- onDelete={[Function]}
- onRename={[Function]}
- onUpdatePurgeSetting={[Function]}
- title="project_branch_pull_request.table.pull_request"
- />
- </div>
-</Fragment>
-`;
-
-exports[`should render deletion modal correctly 1`] = `
-<DeleteBranchModal
- branchLike={
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1001",
- "target": "master",
- "title": "Foo Bar feature",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- onClose={[Function]}
- onDelete={[Function]}
-/>
-`;
-
-exports[`should render renaming modal correctly 1`] = `
-<RenameBranchModal
- branch={
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- }
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- onClose={[Function]}
- onRename={[Function]}
-/>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap
deleted file mode 100644
index 8912079bca2..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/BranchPurgeSetting-test.tsx.snap
+++ /dev/null
@@ -1,38 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly for a main branch 1`] = `
-<Fragment>
- <Toggle
- disabled={true}
- onChange={[Function]}
- value={true}
- />
- <span
- className="spacer-left"
- >
- <DeferredSpinner
- loading={false}
- />
- </span>
- <HelpTooltip
- overlay="project_branch_pull_request.branch.auto_deletion.main_branch_tooltip"
- />
-</Fragment>
-`;
-
-exports[`should render correctly for a non-main branch 1`] = `
-<Fragment>
- <Toggle
- disabled={false}
- onChange={[Function]}
- value={true}
- />
- <span
- className="spacer-left"
- >
- <DeferredSpinner
- loading={false}
- />
- </span>
-</Fragment>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/DeleteBranchModal-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/DeleteBranchModal-test.tsx.snap
deleted file mode 100644
index 4d589683f44..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/DeleteBranchModal-test.tsx.snap
+++ /dev/null
@@ -1,82 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<Modal
- contentLabel="project_branch_pull_request.branch.delete"
- onRequestClose={[MockFunction]}
->
- <header
- className="modal-head"
- >
- <h2>
- project_branch_pull_request.branch.delete
- </h2>
- </header>
- <form
- onSubmit={[Function]}
- >
- <div
- className="modal-body"
- >
- project_branch_pull_request.branch.delete.are_you_sure.feature/foo
- </div>
- <footer
- className="modal-foot"
- >
- <SubmitButton
- className="button-red"
- disabled={false}
- >
- delete
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
- </form>
-</Modal>
-`;
-
-exports[`renders 2`] = `
-<Modal
- contentLabel="project_branch_pull_request.branch.delete"
- onRequestClose={[MockFunction]}
->
- <header
- className="modal-head"
- >
- <h2>
- project_branch_pull_request.branch.delete
- </h2>
- </header>
- <form
- onSubmit={[Function]}
- >
- <div
- className="modal-body"
- >
- project_branch_pull_request.branch.delete.are_you_sure.feature/foo
- </div>
- <footer
- className="modal-foot"
- >
- <i
- className="spinner spacer-right"
- />
- <SubmitButton
- className="button-red"
- disabled={true}
- >
- delete
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
- </form>
-</Modal>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformation-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformation-test.tsx.snap
deleted file mode 100644
index a3c4c319c6e..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformation-test.tsx.snap
+++ /dev/null
@@ -1,16 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly: after_fetching_data 1`] = `
-<Memo(LifetimeInformationRenderer)
- branchAndPullRequestLifeTimeInDays="45"
- canAdmin={true}
- loading={false}
-/>
-`;
-
-exports[`should render correctly: initial_state 1`] = `
-<Memo(LifetimeInformationRenderer)
- canAdmin={true}
- loading={true}
-/>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformationRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformationRenderer-test.tsx.snap
deleted file mode 100644
index 7937edd9c15..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LifetimeInformationRenderer-test.tsx.snap
+++ /dev/null
@@ -1,60 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<DeferredSpinner
- loading={true}
->
- <p
- className="page-description"
- >
- <FormattedMessage
- defaultMessage="project_branch_pull_request.lifetime_information"
- id="project_branch_pull_request.lifetime_information"
- values={
- {
- "days": "30",
- }
- }
- />
- </p>
-</DeferredSpinner>
-`;
-
-exports[`should render correctly if not lifetime has been fetch 1`] = `
-<DeferredSpinner
- loading={true}
-/>
-`;
-
-exports[`should render correctly when user is admin 1`] = `
-<DeferredSpinner
- loading={true}
->
- <p
- className="page-description"
- >
- <FormattedMessage
- defaultMessage="project_branch_pull_request.lifetime_information"
- id="project_branch_pull_request.lifetime_information"
- values={
- {
- "days": "30",
- }
- }
- />
- <FormattedMessage
- defaultMessage="project_branch_pull_request.lifetime_information.admin"
- id="project_branch_pull_request.lifetime_information.admin"
- values={
- {
- "settings": <ForwardRef(Link)
- to="/admin/settings"
- >
- settings.page
- </ForwardRef(Link)>,
- }
- }
- />
- </p>
-</DeferredSpinner>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/ProjectBranchesApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/ProjectBranchesApp-test.tsx.snap
deleted file mode 100644
index 3d61a39aba6..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/ProjectBranchesApp-test.tsx.snap
+++ /dev/null
@@ -1,113 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<div
- className="page page-limited"
- id="project-branch-like"
->
- <header
- className="page-header"
- >
- <Helmet
- defer={false}
- encodeSpecialCharacters={true}
- prioritizeSeoTags={false}
- title="project_branch_pull_request.page"
- />
- <h1>
- project_branch_pull_request.page
- </h1>
- <withAppStateContext(LifetimeInformation) />
- </header>
- <BranchLikeTabs
- branchLikes={
- [
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-11",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-1",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": true,
- "name": "master",
- },
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "1",
- "target": "master",
- "title": "PR-1",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-12",
- },
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "key": "2",
- "target": "master",
- "title": "PR-2",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-3",
- },
- {
- "analysisDate": "2018-01-01",
- "excludedFromPurge": true,
- "isMain": false,
- "name": "branch-2",
- },
- {
- "analysisDate": "2018-01-01",
- "base": "master",
- "branch": "feature/foo/bar",
- "isOrphan": true,
- "key": "2",
- "target": "llb-100",
- "title": "PR-2",
- },
- ]
- }
- component={
- {
- "breadcrumbs": [],
- "key": "my-project",
- "name": "MyProject",
- "qualifier": "TRK",
- "qualityGate": {
- "isDefault": true,
- "key": "30",
- "name": "Sonar way",
- },
- "qualityProfiles": [
- {
- "deleted": false,
- "key": "my-qp",
- "language": "ts",
- "name": "Sonar way",
- },
- ],
- "tags": [],
- }
- }
- onBranchesChange={[MockFunction]}
- />
-</div>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/RenameBranchModal-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/RenameBranchModal-test.tsx.snap
deleted file mode 100644
index d86464ad074..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/RenameBranchModal-test.tsx.snap
+++ /dev/null
@@ -1,190 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<Modal
- contentLabel="project_branch_pull_request.branch.rename"
- onRequestClose={[MockFunction]}
- size="small"
->
- <header
- className="modal-head"
- >
- <h2>
- project_branch_pull_request.branch.rename
- </h2>
- </header>
- <form
- onSubmit={[Function]}
- >
- <div
- className="modal-body"
- >
- <MandatoryFieldsExplanation
- className="modal-field"
- />
- <div
- className="modal-field"
- >
- <label
- htmlFor="rename-branch-name"
- >
- new_name
- <MandatoryFieldMarker />
- </label>
- <input
- autoFocus={true}
- id="rename-branch-name"
- maxLength={100}
- name="name"
- onChange={[Function]}
- required={true}
- size={50}
- type="text"
- value="master"
- />
- </div>
- </div>
- <footer
- className="modal-foot"
- >
- <SubmitButton
- disabled={true}
- >
- rename
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
- </form>
-</Modal>
-`;
-
-exports[`renders 2`] = `
-<Modal
- contentLabel="project_branch_pull_request.branch.rename"
- onRequestClose={[MockFunction]}
- size="small"
->
- <header
- className="modal-head"
- >
- <h2>
- project_branch_pull_request.branch.rename
- </h2>
- </header>
- <form
- onSubmit={[Function]}
- >
- <div
- className="modal-body"
- >
- <MandatoryFieldsExplanation
- className="modal-field"
- />
- <div
- className="modal-field"
- >
- <label
- htmlFor="rename-branch-name"
- >
- new_name
- <MandatoryFieldMarker />
- </label>
- <input
- autoFocus={true}
- id="rename-branch-name"
- maxLength={100}
- name="name"
- onChange={[Function]}
- required={true}
- size={50}
- type="text"
- value="dev"
- />
- </div>
- </div>
- <footer
- className="modal-foot"
- >
- <SubmitButton
- disabled={false}
- >
- rename
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
- </form>
-</Modal>
-`;
-
-exports[`renders 3`] = `
-<Modal
- contentLabel="project_branch_pull_request.branch.rename"
- onRequestClose={[MockFunction]}
- size="small"
->
- <header
- className="modal-head"
- >
- <h2>
- project_branch_pull_request.branch.rename
- </h2>
- </header>
- <form
- onSubmit={[Function]}
- >
- <div
- className="modal-body"
- >
- <MandatoryFieldsExplanation
- className="modal-field"
- />
- <div
- className="modal-field"
- >
- <label
- htmlFor="rename-branch-name"
- >
- new_name
- <MandatoryFieldMarker />
- </label>
- <input
- autoFocus={true}
- id="rename-branch-name"
- maxLength={100}
- name="name"
- onChange={[Function]}
- required={true}
- size={50}
- type="text"
- value="dev"
- />
- </div>
- </div>
- <footer
- className="modal-foot"
- >
- <i
- className="spinner spacer-right"
- />
- <SubmitButton
- disabled={true}
- >
- rename
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
- </form>
-</Modal>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/routes.tsx b/server/sonar-web/src/main/js/apps/projectBranches/routes.tsx
index f56c0111e96..b97bc5b95ba 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/routes.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/routes.tsx
@@ -19,7 +19,7 @@
*/
import React from 'react';
import { Route } from 'react-router-dom';
-import ProjectBranchesApp from './components/ProjectBranchesApp';
+import ProjectBranchesApp from './ProjectBranchesApp';
const routes = () => <Route path="branches" element={<ProjectBranchesApp />} />;
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx
index a6df6000d50..c3ca56437c3 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/AnalysisScope-test.tsx
@@ -20,16 +20,25 @@
import { uniq } from 'lodash';
import * as React from 'react';
import { byRole, byText } from 'testing-library-selector';
-import { DEFAULT_DEFINITIONS_MOCK } from '../../../../api/mocks/SettingsServiceMock';
+import SettingsServiceMock, {
+ DEFAULT_DEFINITIONS_MOCK,
+} from '../../../../api/mocks/SettingsServiceMock';
import { mockComponent } from '../../../../helpers/mocks/component';
import { renderComponent } from '../../../../helpers/testReactTestingUtils';
-import { AdditionalCategoryComponentProps, ADDITIONAL_CATEGORIES } from '../AdditionalCategories';
+import { AdditionalCategoryComponentProps } from '../AdditionalCategories';
+import { AnalysisScope } from '../AnalysisScope';
+
+const handler = new SettingsServiceMock();
const ui = {
introduction: byText('settings.analysis_scope.wildcards.introduction'),
docLink: byRole('link', { name: /learn_more/ }),
};
+beforeEach(() => {
+ handler.reset();
+});
+
it('renders correctly', async () => {
renderAnalysisScope();
@@ -45,5 +54,5 @@ function renderAnalysisScope(overrides: Partial<AdditionalCategoryComponentProps
component: mockComponent(),
...overrides,
};
- return renderComponent(<>{ADDITIONAL_CATEGORIES[2].renderComponent(props)}</>);
+ return renderComponent(<AnalysisScope {...props} />);
}
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx
index c762837b87c..6abf3403c8a 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Definition-it.tsx
@@ -33,8 +33,6 @@ import { ExtendedSettingDefinition, SettingType, SettingValue } from '../../../.
import { Component } from '../../../../types/types';
import Definition from '../Definition';
-jest.mock('../../../../api/settings');
-
let settingsMock: SettingsServiceMock;
beforeAll(() => {
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx
index 9e0868ebbf4..a2dbdd092f9 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/Languages-it.tsx
@@ -30,8 +30,6 @@ import { renderApp } from '../../../../helpers/testReactTestingUtils';
import { AdditionalCategoryComponentProps } from '../AdditionalCategories';
import Languages from '../Languages';
-jest.mock('../../../../api/settings');
-
let settingsMock: SettingsServiceMock;
beforeAll(() => {
diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx
index aba19dae895..d86504bdef6 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/SettingsApp-it.tsx
@@ -35,8 +35,6 @@ import { Feature } from '../../../../types/features';
import { Component } from '../../../../types/types';
import routes from '../../routes';
-jest.mock('../../../../api/settings');
-
let settingsMock: SettingsServiceMock;
beforeAll(() => {
diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx
index 7e6e00010bd..a3b51f575eb 100644
--- a/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/__tests__/Authentication-it.tsx
@@ -34,7 +34,6 @@ import { GitHubProvisioningStatus } from '../../../../../types/provisioning';
import { TaskStatuses } from '../../../../../types/tasks';
import Authentication from '../Authentication';
-jest.mock('../../../../../api/settings');
jest.mock('../../../../../api/system');
let handler: AuthenticationServiceMock;
diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx
index 40fad0bf432..8cec5e46fa3 100644
--- a/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx
+++ b/server/sonar-web/src/main/js/apps/settings/encryption/__tests__/EncryptionApp-it.tsx
@@ -24,8 +24,6 @@ import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock';
import { renderComponent } from '../../../../helpers/testReactTestingUtils';
import EncryptionApp from '../EncryptionApp';
-jest.mock('../../../../api/settings');
-
let settingsMock: SettingsServiceMock;
beforeAll(() => {
diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx
index 98595918047..2ffddececf8 100644
--- a/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx
+++ b/server/sonar-web/src/main/js/apps/tutorials/components/__tests__/TutorialsApp-test.tsx
@@ -26,7 +26,6 @@ import { renderAppRoutes } from '../../../../helpers/testReactTestingUtils';
import { Permissions } from '../../../../types/permissions';
import routes from '../../routes';
-jest.mock('../../../../api/settings');
jest.mock('../../../../api/user-tokens');
jest.mock('../../../../helpers/handleRequiredAuthentication', () => jest.fn());
diff --git a/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx b/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx
index 2b4850a13b4..20043e921b4 100644
--- a/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx
+++ b/server/sonar-web/src/main/js/apps/users/__tests__/UsersApp-it.tsx
@@ -36,7 +36,6 @@ import { ChangePasswordResults, CurrentUser } from '../../../types/users';
import UsersApp from '../UsersApp';
jest.mock('../../../api/user-tokens');
-jest.mock('../../../api/settings');
const userHandler = new UsersServiceMock();
const tokenHandler = new UserTokensMock();
diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx
index 89cfc0bcee5..bc2e9c8b811 100644
--- a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx
@@ -41,7 +41,6 @@ import { withRouter } from '../../hoc/withRouter';
import { TutorialSelection } from '../TutorialSelection';
import { TutorialModes } from '../types';
-jest.mock('../../../api/settings');
jest.mock('../../../api/user-tokens');
jest.mock('../../../helpers/urls', () => ({
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 33576fdad2b..f90095377ee 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -616,6 +616,7 @@ project_branch_pull_request.lifetime_information=Branches and Pull Requests are
project_branch_pull_request.lifetime_information.admin=You can adjust this value globally in {settings}.
project_branch_pull_request.branch.rename=Rename branch
project_branch_pull_request.branch.delete=Delete branch
+project_branch_pull_request.branch.actions_label=Update {0}
project_branch_pull_request.branch.delete.are_you_sure=Are you sure you want to delete branch "{0}"?
project_branch_pull_request.branch.auto_deletion.keep_when_inactive=Keep when inactive
project_branch_pull_request.branch.auto_deletion.keep_when_inactive.tooltip=When turned on, the branch will not be automatically deleted when inactive.