import { STATUSES } from '../../../apps/background-tasks/constants';
import { waitAndUpdate } from '../../../helpers/testUtils';
import { isSonarCloud } from '../../../helpers/system';
-import { mockLocation, mockRouter, mockComponent } from '../../../helpers/testMocks';
-
-jest.mock('../../../api/branches', () => ({
- getBranches: jest.fn().mockResolvedValue([
- {
- isMain: true,
- name: 'master',
- type: 'LONG',
- status: { qualityGateStatus: 'OK' }
- }
- ]),
- getPullRequests: jest.fn().mockResolvedValue([
- {
- base: 'feature',
- branch: 'feature',
- key: 'pr-89',
- title: 'PR Feature',
- status: { qualityGateStatus: 'ERROR' }
- },
- {
- base: 'feature',
- branch: 'feature',
- key: 'pr-90',
- title: 'PR Feature 2'
- }
- ])
-}));
+import {
+ mockLocation,
+ mockRouter,
+ mockComponent,
+ mockPullRequest,
+ mockLongLivingBranch,
+ mockShortLivingBranch,
+ mockMainBranch
+} from '../../../helpers/testMocks';
+
+jest.mock('../../../api/branches', () => {
+ const { mockMainBranch, mockPullRequest } = require.requireActual('../../../helpers/testMocks');
+ return {
+ getBranches: jest
+ .fn()
+ .mockResolvedValue([mockMainBranch({ status: { qualityGateStatus: 'OK' } })]),
+ getPullRequests: jest
+ .fn()
+ .mockResolvedValue([
+ mockPullRequest({ key: 'pr-89', status: { qualityGateStatus: 'ERROR' } }),
+ mockPullRequest({ key: 'pr-90', title: 'PR Feature 2' })
+ ])
+ };
+});
jest.mock('../../../api/ce', () => ({
getAnalysisStatus: jest.fn().mockResolvedValue({ component: { warnings: [] } }),
it('filters correctly the pending tasks for a main branch', () => {
const wrapper = shallowRender();
const component = wrapper.instance();
- const mainBranch: T.MainBranch = { isMain: true, name: 'master' };
- const shortBranch: T.ShortLivingBranch = {
- isMain: false,
- mergeBranch: 'master',
- name: 'feature',
- type: 'SHORT'
- };
- const longBranch: T.LongLivingBranch = {
- isMain: false,
- name: 'branch-7.2',
- type: 'LONG'
- };
- const pullRequest: T.PullRequest = {
- base: 'feature',
- branch: 'feature',
- key: 'pr-89',
- title: 'PR Feature'
- };
+ const mainBranch = mockMainBranch();
+ const shortBranch = mockShortLivingBranch();
+ const longBranch = mockLongLivingBranch();
+ const pullRequest = mockPullRequest();
expect(component.isSameBranch({}, undefined)).toBeTruthy();
expect(component.isSameBranch({}, mainBranch)).toBeTruthy();
expect(component.isSameBranch({}, shortBranch)).toBeFalsy();
expect(
- component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, shortBranch)
+ component.isSameBranch({ branch: shortBranch.name, branchType: 'SHORT' }, shortBranch)
).toBeTruthy();
expect(
component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch)
component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch)
).toBeFalsy();
expect(
- component.isSameBranch({ branch: 'branch-7.1', branchType: 'LONG' }, longBranch)
+ component.isSameBranch({ branch: 'branch-6.6', branchType: 'LONG' }, longBranch)
).toBeFalsy();
expect(
- component.isSameBranch({ branch: 'branch-7.2', branchType: 'LONG' }, pullRequest)
+ component.isSameBranch({ branch: longBranch.name, branchType: 'LONG' }, longBranch)
+ ).toBeTruthy();
+ expect(
+ component.isSameBranch({ branch: 'branch-6.7', branchType: 'LONG' }, pullRequest)
).toBeFalsy();
- expect(component.isSameBranch({ pullRequest: 'pr-89' }, pullRequest)).toBeTruthy();
+ expect(component.isSameBranch({ pullRequest: pullRequest.key }, pullRequest)).toBeTruthy();
- const currentTask = { pullRequest: 'pr-89', status: STATUSES.IN_PROGRESS } as T.Task;
+ const currentTask = { pullRequest: pullRequest.key, status: STATUSES.IN_PROGRESS } as T.Task;
const failedTask = { ...currentTask, status: STATUSES.FAILED };
const pendingTasks = [
currentTask,
- { branch: 'feature', branchType: 'SHORT' } as T.Task,
+ { branch: shortBranch.name, branchType: 'SHORT' } as T.Task,
{} as T.Task
];
expect(component.getCurrentTask(currentTask, undefined)).toBe(undefined);
defaultMessage={translate('branches.pull_request.for_merge_into_x_from_y')}
id="branches.pull_request.for_merge_into_x_from_y"
values={{
- base: <strong>{currentBranchLike.base}</strong>,
+ target: <strong>{currentBranchLike.target}</strong>,
branch: <strong>{currentBranchLike.branch}</strong>
}}
/>
import { ComponentNavBranch } from '../ComponentNavBranch';
import { click } from '../../../../../helpers/testUtils';
import { isSonarCloud } from '../../../../../helpers/system';
+import {
+ mockPullRequest,
+ mockShortLivingBranch,
+ mockMainBranch,
+ mockLongLivingBranch
+} from '../../../../../helpers/testMocks';
jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() }));
-const mainBranch: T.MainBranch = { isMain: true, name: 'master' };
-const fooBranch: T.LongLivingBranch = { isMain: false, name: 'foo', type: 'LONG' };
+const mainBranch = mockMainBranch();
+const fooBranch = mockLongLivingBranch();
beforeEach(() => {
(isSonarCloud as jest.Mock).mockImplementation(() => false);
});
it('renders short-living branch', () => {
- const branch: T.ShortLivingBranch = {
- isMain: false,
- mergeBranch: 'master',
- name: 'foo',
- status: { qualityGateStatus: 'OK' },
- type: 'SHORT'
- };
+ const branch: T.ShortLivingBranch = mockShortLivingBranch({
+ status: { qualityGateStatus: 'OK' }
+ });
const component = {} as T.Component;
expect(
shallow(
});
it('renders pull request', () => {
- const pullRequest: T.PullRequest = {
- base: 'master',
- branch: 'feature',
- key: '1234',
- title: 'Feature PR',
+ const pullRequest = mockPullRequest({
+ target: 'feature/foo',
url: 'https://example.com/pull/1234'
- };
+ });
const component = {} as T.Component;
expect(
shallow(
import { shallow } from 'enzyme';
import { ComponentNavBranchesMenu } from '../ComponentNavBranchesMenu';
import { elementKeydown } from '../../../../../helpers/testUtils';
+import {
+ mockPullRequest,
+ mockShortLivingBranch,
+ mockLongLivingBranch,
+ mockMainBranch
+} from '../../../../../helpers/testMocks';
const component = { key: 'component' } as T.Component;
shallow(
<ComponentNavBranchesMenu
branchLikes={[
- mainBranch(),
+ mockMainBranch(),
shortBranch('foo'),
- longBranch('bar'),
+ mockLongLivingBranch({ name: 'bar' }),
shortBranch('baz', true),
- pullRequest('qux')
+ mockPullRequest({ status: { qualityGateStatus: 'OK' }, title: 'qux' })
]}
component={component}
- currentBranchLike={mainBranch()}
+ currentBranchLike={mockMainBranch()}
onClose={jest.fn()}
router={{ push: jest.fn() }}
/>
const wrapper = shallow(
<ComponentNavBranchesMenu
branchLikes={[
- mainBranch(),
+ mockMainBranch(),
shortBranch('foo'),
shortBranch('foobar'),
- longBranch('bar'),
- longBranch('BARBAZ')
+ mockLongLivingBranch({ name: 'bar' }),
+ mockLongLivingBranch({ name: 'BARBAZ' })
]}
component={component}
- currentBranchLike={mainBranch()}
+ currentBranchLike={mockMainBranch()}
onClose={jest.fn()}
router={{ push: jest.fn() }}
/>
it('selects next & previous', () => {
const wrapper = shallow<ComponentNavBranchesMenu>(
<ComponentNavBranchesMenu
- branchLikes={[mainBranch(), shortBranch('foo'), shortBranch('foobar'), longBranch('bar')]}
+ branchLikes={[
+ mockMainBranch(),
+ shortBranch('foo'),
+ shortBranch('foobar'),
+ mockLongLivingBranch({ name: 'bar' })
+ ]}
component={component}
- currentBranchLike={mainBranch()}
+ currentBranchLike={mockMainBranch()}
onClose={jest.fn()}
router={{ push: jest.fn() }}
/>
expect(wrapper.state().selected).toEqual(shortBranch('foo'));
});
-function mainBranch(): T.MainBranch {
- return { isMain: true, name: 'master' };
-}
-
-function shortBranch(name: string, isOrphan?: true): T.ShortLivingBranch {
- return {
- isMain: false,
- isOrphan,
- mergeBranch: 'master',
- name,
- status: { qualityGateStatus: 'OK' },
- type: 'SHORT'
- };
-}
-
-function longBranch(name: string): T.LongLivingBranch {
- return { isMain: false, name, type: 'LONG' };
-}
-
-function pullRequest(title: string): T.PullRequest {
- return {
- base: 'master',
- branch: 'feature',
- key: '1234',
- status: { qualityGateStatus: 'OK' },
- title
- };
+function shortBranch(name: string, isOrphan?: true) {
+ return mockShortLivingBranch({ name, isOrphan, status: { qualityGateStatus: 'OK' } });
}
branchLikes={
Array [
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
},
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
- "name": "foo",
+ "name": "branch-6.7",
"type": "LONG",
},
]
component={Object {}}
currentBranchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
}
<BranchIcon
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
}
branchLikes={
Array [
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "feature/foo",
+ "title": "Foo Bar feature",
"url": "https://example.com/pull/1234",
},
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
- "name": "foo",
+ "name": "branch-6.7",
"type": "LONG",
},
]
component={Object {}}
currentBranchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "feature/foo",
+ "title": "Foo Bar feature",
"url": "https://example.com/pull/1234",
}
}
<BranchIcon
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "feature/foo",
+ "title": "Foo Bar feature",
"url": "https://example.com/pull/1234",
}
}
/>
<span
className="text-limited text-top"
- title="1234 – Feature PR"
+ title="1001 – Foo Bar feature"
>
- 1234 – Feature PR
+ 1001 – Foo Bar feature
</span>
<DropdownIcon
className="little-spacer-left"
id="branches.pull_request.for_merge_into_x_from_y"
values={
Object {
- "base": <strong>
- master
- </strong>,
"branch": <strong>
- feature
+ feature/foo/bar
+ </strong>,
+ "target": <strong>
+ feature/foo
</strong>,
}
}
branchLikes={
Array [
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "foo",
+ "name": "feature/foo",
"status": Object {
"qualityGateStatus": "OK",
},
"type": "SHORT",
},
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
- "name": "foo",
+ "name": "branch-6.7",
"type": "LONG",
},
]
component={Object {}}
currentBranchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "foo",
+ "name": "feature/foo",
"status": Object {
"qualityGateStatus": "OK",
},
<BranchIcon
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "foo",
+ "name": "feature/foo",
"status": Object {
"qualityGateStatus": "OK",
},
/>
<span
className="text-limited text-top"
- title="foo"
+ title="feature/foo"
>
- foo
+ feature/foo
</span>
<DropdownIcon
className="little-spacer-left"
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
}
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
+ "branch": "feature/foo/bar",
+ "key": "1001",
"status": Object {
"qualityGateStatus": "OK",
},
+ "target": "master",
"title": "qux",
}
}
}
}
innerRef={[Function]}
- key="pull-request-1234"
+ key="pull-request-1001"
onSelect={[Function]}
selected={false}
/>
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"isOrphan": true,
"mergeBranch": "master",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"isOrphan": undefined,
"mergeBranch": "master",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"name": "bar",
"type": "LONG",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"isOrphan": true,
"mergeBranch": "master",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"isOrphan": undefined,
"mergeBranch": "master",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"name": "BARBAZ",
"type": "LONG",
<ComponentNavBranchesMenuItem
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"name": "bar",
"type": "LONG",
className="spacer-left"
currentPage={
Object {
- "branch": "master",
+ "branch": "branch-6.7",
"component": "my-project",
"type": "PROJECT",
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
"url": "https://example.com/pull/1234",
}
"analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "release-1.0",
+ "name": "feature/foo",
"type": "SHORT",
}
}
key: string;
isOrphan?: true;
status?: { qualityGateStatus: Status };
+ target: string;
title: string;
url?: string;
}
import { App } from '../App';
import { waitAndUpdate } from '../../../../helpers/testUtils';
import { getMeasuresAndMeta } from '../../../../api/measures';
+import { mockPullRequest, mockMainBranch } from '../../../../helpers/testMocks';
jest.mock('../../../../api/metrics', () => ({
getAllMetrics: jest.fn().mockResolvedValue([
const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' };
const PROPS: App['props'] = {
- branchLike: { isMain: true, name: 'master' },
+ branchLike: mockMainBranch(),
component: COMPONENT,
location: { pathname: '/component_measures', query: { metric: 'coverage' } } as Location,
params: {},
});
it('should not render drilldown for estimated duplications', async () => {
- const pullRequest = { base: 'master', branch: 'feature-x', key: '5', title: '' };
- const wrapper = shallow(<App {...PROPS} branchLike={pullRequest} />);
+ const wrapper = shallow(<App {...PROPS} branchLike={mockPullRequest({ title: '' })} />);
await waitAndUpdate(wrapper);
expect(wrapper).toMatchSnapshot();
});
<MeasureContent
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
}
import * as React from 'react';
import { shallow } from 'enzyme';
import { EmptyOverview, WarningMessage } from '../EmptyOverview';
+import {
+ mockPullRequest,
+ mockLoggedInUser,
+ mockMainBranch,
+ mockComponent
+} from '../../../../helpers/testMocks';
-const branch = { isMain: true, name: 'b', type: 'LONG' };
-
-const component = {
- key: 'foo',
- analysisDate: '2016-01-01',
- breadcrumbs: [],
- name: 'Foo',
- organization: 'org',
- qualifier: 'TRK',
- version: '0.0.1'
-};
-
-const LoggedInUser = {
- isLoggedIn: true,
- login: 'luke',
- name: 'Skywalker'
-};
+const branch = mockMainBranch();
+const component = mockComponent({ version: '0.0.1' });
+const LoggedInUser = mockLoggedInUser();
it('renders correctly', () => {
expect(
it('should not render warning message', () => {
expect(
- shallow(
- <WarningMessage
- branchLike={{
- base: 'foo',
- branch: 'bar',
- key: '1',
- title: 'PR bar'
- }}
- message="foo"
- />
- )
+ shallow(<WarningMessage branchLike={mockPullRequest()} message="foo" />)
.find('FormattedMessage')
.exists()
).toBeFalsy();
<AnalyzeTutorial
component={
Object {
- "analysisDate": "2016-01-01",
"breadcrumbs": Array [],
- "key": "foo",
- "name": "Foo",
- "organization": "org",
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
"qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
"version": "0.0.1",
}
}
currentUser={
Object {
+ "groups": Array [],
"isLoggedIn": true,
"login": "luke",
"name": "Skywalker",
+ "scmAccounts": Array [],
}
}
/>
<Connect(Meta)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
component={
Object {
- "analysisDate": "2016-01-01",
"breadcrumbs": Array [],
- "key": "foo",
- "name": "Foo",
- "organization": "org",
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
"qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
"version": "0.0.1",
}
}
<Connect(Meta)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
component={
Object {
- "analysisDate": "2016-01-01",
"breadcrumbs": Array [],
- "key": "foo",
- "name": "Foo",
- "organization": "org",
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
"qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
"version": "0.0.1",
}
}
<WarningMessage
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
message="provisioning.no_analysis_on_main_branch"
<Connect(Meta)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
component={
Object {
- "analysisDate": "2016-01-01",
"breadcrumbs": Array [],
- "key": "foo",
- "name": "Foo",
- "organization": "org",
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
"qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
"version": "0.0.1",
}
}
<WarningMessage
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
message="provisioning.no_analysis_on_main_branch.bad_configuration"
<Connect(Meta)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
- "name": "b",
- "type": "LONG",
+ "name": "master",
}
}
component={
Object {
- "analysisDate": "2016-01-01",
"breadcrumbs": Array [],
- "key": "foo",
- "name": "Foo",
- "organization": "org",
+ "key": "my-project",
+ "name": "MyProject",
+ "organization": "foo",
"qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
"version": "0.0.1",
}
}
id="foo"
values={
Object {
- "branchName": "b",
+ "branchName": "master",
"branchType": <div
className="outline-badge text-baseline"
>
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "release-1.0",
+ "name": "feature/foo",
"type": "SHORT",
}
}
"analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "release-1.0",
+ "name": "feature/foo",
"type": "SHORT",
}
}
"analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "release-1.0",
+ "name": "feature/foo",
"type": "SHORT",
}
}
"analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "release-1.0",
+ "name": "feature/foo",
"type": "SHORT",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
"base": "master",
"branch": "feature/foo/bar",
"key": "1001",
+ "target": "master",
"title": "Foo Bar feature",
}
}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable import/first, import/order */
-jest.mock('../../../../api/settings', () => ({
- getValues: jest.fn(() => Promise.resolve([]))
-}));
-
import * as React from 'react';
import { mount, shallow } from 'enzyme';
import App from '../App';
+import { getValues } from '../../../../api/settings';
+import {
+ mockMainBranch,
+ mockLongLivingBranch,
+ mockShortLivingBranch,
+ mockPullRequest
+} from '../../../../helpers/testMocks';
-const getValues = require('../../../../api/settings').getValues as jest.Mock<any>;
+jest.mock('../../../../api/settings', () => ({
+ getValues: jest.fn(() => Promise.resolve([]))
+}));
beforeEach(() => {
- getValues.mockClear();
+ jest.clearAllMocks();
});
it('renders sorted list of branches', () => {
- const branchLikes: [
- T.MainBranch,
- T.LongLivingBranch,
- T.ShortLivingBranch,
- T.PullRequest,
- T.ShortLivingBranch
- ] = [
- { isMain: true, name: 'master' },
- { isMain: false, name: 'branch-1.0', type: 'LONG' },
- { isMain: false, mergeBranch: 'master', name: 'feature', type: 'SHORT' },
- { base: 'master', branch: 'feature', key: '1234', title: 'Feature PR' },
- {
- isMain: false,
- mergeBranch: 'foobar',
- isOrphan: true,
- name: 'feature',
- type: 'SHORT'
- }
+ const branchLikes = [
+ mockMainBranch(),
+ mockLongLivingBranch(),
+ mockShortLivingBranch(),
+ mockPullRequest(),
+ mockShortLivingBranch({ mergeBranch: 'foobar', name: 'feature', isOrphan: true })
];
const wrapper = shallow(
<App
import { shallow } from 'enzyme';
import BranchRow from '../BranchRow';
import { click } from '../../../../helpers/testUtils';
+import { mockPullRequest, mockShortLivingBranch } from '../../../../helpers/testMocks';
const mainBranch: T.MainBranch = { isMain: true, name: 'master' };
-const shortBranch: T.ShortLivingBranch = {
- analysisDate: '2017-09-27T00:05:19+0000',
- isMain: false,
- name: 'feature',
- mergeBranch: 'foo',
- type: 'SHORT'
-};
+const shortBranch = mockShortLivingBranch();
-const pullRequest: T.PullRequest = {
- base: 'master',
- branch: 'feature',
- key: '1234',
- title: 'Feature PR'
-};
+const pullRequest = mockPullRequest();
it('renders main branch', () => {
expect(shallowRender(mainBranch)).toMatchSnapshot();
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* eslint-disable import/first */
-jest.mock('../../../../api/branches', () => ({
- deleteBranch: jest.fn(),
- deletePullRequest: jest.fn()
-}));
-
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import DeleteBranchModal from '../DeleteBranchModal';
import { submit, doAsync, click, waitAndUpdate } from '../../../../helpers/testUtils';
import { deleteBranch, deletePullRequest } from '../../../../api/branches';
+import { mockShortLivingBranch, mockPullRequest } from '../../../../helpers/testMocks';
+
+jest.mock('../../../../api/branches', () => ({
+ deleteBranch: jest.fn(),
+ deletePullRequest: jest.fn()
+}));
-const branch: T.ShortLivingBranch = {
- isMain: false,
- name: 'feature',
- mergeBranch: 'master',
- type: 'SHORT'
-};
+const branch = mockShortLivingBranch();
beforeEach(() => {
- (deleteBranch as jest.Mock).mockClear();
- (deletePullRequest as jest.Mock).mockClear();
+ jest.clearAllMocks();
});
it('renders', () => {
await waitAndUpdate(wrapper);
expect(wrapper.state().loading).toBe(false);
expect(onDelete).toBeCalled();
- expect(deleteBranch).toBeCalledWith({ branch: 'feature', project: 'foo' });
+ expect(deleteBranch).toBeCalledWith({ branch: 'feature/foo', project: 'foo' });
});
it('deletes pull request', async () => {
(deletePullRequest as jest.Mock).mockImplementationOnce(() => Promise.resolve());
- const pullRequest: T.PullRequest = {
- base: 'master',
- branch: 'feature',
- key: '1234',
- title: 'Feature PR'
- };
+ const pullRequest = mockPullRequest();
const onDelete = jest.fn();
const wrapper = shallowRender(pullRequest, onDelete);
await waitAndUpdate(wrapper);
expect(wrapper.state().loading).toBe(false);
expect(onDelete).toBeCalled();
- expect(deletePullRequest).toBeCalledWith({ project: 'foo', pullRequest: '1234' });
+ expect(deletePullRequest).toBeCalledWith({ project: 'foo', pullRequest: '1001' });
});
it('cancels', () => {
await waitAndUpdate(wrapper);
expect(wrapper.state().loading).toBe(false);
expect(onDelete).not.toBeCalled();
- expect(deleteBranch).toBeCalledWith({ branch: 'feature', project: 'foo' });
+ expect(deleteBranch).toBeCalledWith({ branch: 'feature/foo', project: 'foo' });
});
function shallowRender(
<BranchRow
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": true,
"name": "master",
}
<BranchRow
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "master",
+ "title": "Foo Bar feature",
}
}
component="foo"
<BranchRow
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"mergeBranch": "master",
- "name": "feature",
+ "name": "feature/foo",
"type": "SHORT",
}
}
<BranchRow
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
- "name": "branch-1.0",
+ "name": "branch-6.7",
"type": "LONG",
}
}
<BranchRow
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"isMain": false,
"isOrphan": true,
"mergeBranch": "foobar",
<BranchIcon
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "master",
+ "title": "Foo Bar feature",
}
}
className="little-spacer-right big-spacer-left"
/>
- 1234 – Feature PR
+ 1001 – Foo Bar feature
</td>
<td
className="thin nowrap"
<Connect(BranchStatus)
branchLike={
Object {
+ "analysisDate": "2018-01-01",
"base": "master",
- "branch": "feature",
- "key": "1234",
- "title": "Feature PR",
+ "branch": "feature/foo/bar",
+ "key": "1001",
+ "target": "master",
+ "title": "Foo Bar feature",
}
}
component="foo"
</td>
<td
className="thin nowrap text-right big-spacer-left"
- />
+ >
+ <DateFromNow
+ date="2018-01-01"
+ />
+ </td>
<td
className="thin nowrap text-right"
>
<BranchIcon
branchLike={
Object {
- "analysisDate": "2017-09-27T00:05:19+0000",
+ "analysisDate": "2018-01-01",
"isMain": false,
- "mergeBranch": "foo",
- "name": "feature",
+ "mergeBranch": "master",
+ "name": "feature/foo",
"type": "SHORT",
}
}
className="little-spacer-right big-spacer-left"
/>
- feature
+ feature/foo
</td>
<td
className="thin nowrap"
<Connect(BranchStatus)
branchLike={
Object {
- "analysisDate": "2017-09-27T00:05:19+0000",
+ "analysisDate": "2018-01-01",
"isMain": false,
- "mergeBranch": "foo",
- "name": "feature",
+ "mergeBranch": "master",
+ "name": "feature/foo",
"type": "SHORT",
}
}
className="thin nowrap text-right big-spacer-left"
>
<DateFromNow
- date="2017-09-27T00:05:19+0000"
+ date="2018-01-01"
/>
</td>
<td
<div
className="modal-body"
>
- branches.delete.are_you_sure.feature
+ branches.delete.are_you_sure.feature/foo
</div>
<footer
className="modal-foot"
<div
className="modal-body"
>
- branches.delete.are_you_sure.feature
+ branches.delete.are_you_sure.feature/foo
</div>
<footer
className="modal-foot"
base: 'master',
branch: 'feature/foo/bar',
key: '1001',
+ target: 'master',
title: 'Foo Bar feature',
...overrides
};
return {
analysisDate: '2018-01-01',
isMain: false,
- name: 'release-1.0',
+ name: 'feature/foo',
mergeBranch: 'master',
type: 'SHORT',
...overrides
return {
analysisDate: '2018-01-01',
isMain: false,
- name: 'master',
+ name: 'branch-6.7',
type: 'LONG',
...overrides
};
branches.pull_requests=Pull Requests
branches.short_lived.quality_gate.description=The branch status is passed because there are no open issue. The remaining {0} issue(s) have been confirmed.
branches.short_lived_branches=Short-lived branches
-branches.pull_request.for_merge_into_x_from_y=for merge into {base} from {branch}
+branches.pull_request.for_merge_into_x_from_y=for merge into {target} from {branch}
branches.see_the_pr=See the PR
branches.measures.new_coverage.help=Coverage on New Code. See {link} for details.
branches.measures.new_coverage.missing=No coverage data for new code.