From: Wouter Admiraal Date: Mon, 30 Dec 2019 09:16:58 +0000 (+0100) Subject: Move tests of projectBaseline X-Git-Tag: 8.2.0.32929~239 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e5d9b437e9ba5bbe933ee068dd31d7c716824428;p=sonarqube.git Move tests of projectBaseline --- diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/App-test.tsx deleted file mode 100644 index 1e1b5faf34f..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/App-test.tsx +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; -import { getNewCodePeriod, resetNewCodePeriod, setNewCodePeriod } from '../../../api/newCodePeriod'; -import { mockComponent, mockEvent } from '../../../helpers/testMocks'; -import App from '../components/App'; - -jest.mock('../../../api/newCodePeriod', () => ({ - getNewCodePeriod: jest.fn().mockResolvedValue({}), - resetNewCodePeriod: jest.fn().mockResolvedValue({}), - setNewCodePeriod: jest.fn().mockResolvedValue({}) -})); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should not display reset button if project setting is not set', () => { - const wrapper = shallowRender(); - - expect(wrapper.find('Button')).toHaveLength(0); -}); - -it('should reset the setting correctly', async () => { - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - wrapper.instance().resetSetting(); - await waitAndUpdate(wrapper); - expect(wrapper.state('currentSetting')).toBeUndefined(); - expect(wrapper.state('selected')).toBeUndefined(); -}); - -it('should save correctly', async () => { - const component = mockComponent(); - const wrapper = shallowRender({ component }); - await waitAndUpdate(wrapper); - wrapper.setState({ selected: 'NUMBER_OF_DAYS', days: '23' }); - wrapper.instance().handleSubmit(mockEvent()); - await waitAndUpdate(wrapper); - expect(setNewCodePeriod).toHaveBeenCalledWith({ - project: component.key, - type: 'NUMBER_OF_DAYS', - value: '23' - }); - expect(wrapper.state('currentSetting')).toEqual(wrapper.state('selected')); -}); - -it('should handle errors gracefully', async () => { - (getNewCodePeriod as jest.Mock).mockRejectedValue('error'); - (setNewCodePeriod as jest.Mock).mockRejectedValue('error'); - (resetNewCodePeriod as jest.Mock).mockRejectedValue('error'); - - const wrapper = shallowRender(); - wrapper.setState({ selected: 'PREVIOUS_VERSION' }); - await waitAndUpdate(wrapper); - - expect(wrapper.state('loading')).toBe(false); - wrapper.instance().resetSetting(); - await waitAndUpdate(wrapper); - expect(wrapper.state('saving')).toBe(false); - wrapper.instance().handleSubmit(mockEvent()); - await waitAndUpdate(wrapper); - expect(wrapper.state('saving')).toBe(false); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingAnalysis-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingAnalysis-test.tsx deleted file mode 100644 index 384ba11b597..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingAnalysis-test.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 BaselineSettingAnalysis, { Props } from '../components/BaselineSettingAnalysis'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should callback when clicked', () => { - const onSelect = jest.fn(); - const wrapper = shallowRender({ onSelect, selected: false }); - - wrapper - .find('RadioCard') - .first() - .simulate('click'); - expect(onSelect).toHaveBeenCalledWith('SPECIFIC_ANALYSIS'); -}); - -function shallowRender(props: Partial = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingDays-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingDays-test.tsx deleted file mode 100644 index f8cd5d968e3..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingDays-test.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 BaselineSettingDays, { Props } from '../components/BaselineSettingDays'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ isChanged: true })).toMatchSnapshot(); - expect(shallowRender({ isChanged: true, isValid: false })).toMatchSnapshot(); -}); - -it('should not display input when not selected', () => { - const wrapper = shallowRender({ selected: false }); - expect(wrapper.find('ValidationInput')).toHaveLength(0); -}); - -it('should callback when clicked', () => { - const onSelect = jest.fn(); - const wrapper = shallowRender({ onSelect, selected: false }); - - wrapper - .find('RadioCard') - .first() - .simulate('click'); - expect(onSelect).toHaveBeenCalledWith('NUMBER_OF_DAYS'); -}); - -it('should callback when changing days', () => { - const onChangeDays = jest.fn(); - const wrapper = shallowRender({ onChangeDays }); - - wrapper - .find('input') - .first() - .simulate('change', { currentTarget: { value: '23' } }); - expect(onChangeDays).toHaveBeenCalledWith('23'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingPreviousVersion-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingPreviousVersion-test.tsx deleted file mode 100644 index e38e179b85d..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BaselineSettingPreviousVersion-test.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 BaselineSettingPreviousVersion, { - Props -} from '../components/BaselineSettingPreviousVersion'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ isDefault: true })).toMatchSnapshot(); -}); - -it('should callback when clicked', () => { - const onSelect = jest.fn(); - const wrapper = shallowRender({ onSelect, selected: false }); - - wrapper - .find('RadioCard') - .first() - .simulate('click'); - expect(onSelect).toHaveBeenCalledWith('PREVIOUS_VERSION'); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchAnalysisList-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchAnalysisList-test.tsx deleted file mode 100644 index 992853b7ec9..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchAnalysisList-test.tsx +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 { subDays } from 'date-fns'; -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { toShortNotSoISOString } from 'sonar-ui-common/helpers/dates'; -import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; -import { getProjectActivity } from '../../../api/projectActivity'; -import { mockAnalysis, mockAnalysisEvent } from '../../../helpers/testMocks'; -import BranchAnalysisList from '../components/BranchAnalysisList'; - -jest.mock('../../../api/projectActivity', () => ({ - getProjectActivity: jest.fn().mockResolvedValue({ - analyses: [] - }) -})); - -beforeEach(() => { - jest.clearAllMocks(); -}); - -it('should render correctly', async () => { - (getProjectActivity as jest.Mock).mockResolvedValueOnce({ - analyses: [ - mockAnalysis({ - key: '4', - date: '2017-03-02T10:36:01+0100', - projectVersion: '4.2' - }), - mockAnalysis({ - key: '3', - date: '2017-03-02T09:36:01+0100', - events: [mockAnalysisEvent()], - projectVersion: '4.2' - }), - mockAnalysis({ - key: '2', - events: [ - mockAnalysisEvent(), - mockAnalysisEvent({ category: 'VERSION', qualityGate: undefined }) - ], - projectVersion: '4.1' - }), - mockAnalysis({ key: '1', projectVersion: '4.1' }) - ] - }); - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); - -it('should reload analyses after range change', () => { - const wrapper = shallowRender(); - - wrapper.instance().handleRangeChange({ value: 20 }); - - expect(getProjectActivity).toBeCalledWith({ - branch: 'master', - project: 'project1', - from: toShortNotSoISOString(subDays(new Date(), 20)) - }); -}); - -it('should register the badge nodes', () => { - const wrapper = shallowRender(); - - const element = document.createElement('div'); - - wrapper.instance().registerBadgeNode('4.3')(element); - - expect(element.getAttribute('originOffsetTop')).not.toBeNull(); -}); - -it('should handle scroll', () => { - const wrapper = shallowRender(); - - wrapper.instance().handleScroll({ currentTarget: { scrollTop: 12 } } as any); - - expect(wrapper.state('scroll')).toBe(12); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx deleted file mode 100644 index cbae7bcc0a5..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchBaselineSettingModal-test.tsx +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 { mockEvent, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; -import { setNewCodePeriod } from '../../../api/newCodePeriod'; -import { mockMainBranch } from '../../../helpers/mocks/branch-like'; -import BranchBaselineSettingModal from '../components/BranchBaselineSettingModal'; - -jest.mock('../../../api/newCodePeriod', () => ({ - setNewCodePeriod: jest.fn().mockResolvedValue({}) -})); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should display the branch analysis list when necessary', () => { - const wrapper = shallowRender(); - - wrapper.setState({ selected: 'SPECIFIC_ANALYSIS' }); - - expect(wrapper.find('BranchAnalysisList')).toHaveLength(1); -}); - -it('should save correctly', async () => { - const branch = mockMainBranch({ name: 'branchname' }); - const component = 'compKey'; - const wrapper = shallowRender({ - branch, - component - }); - - wrapper.setState({ analysis: 'analysis572893', selected: 'SPECIFIC_ANALYSIS' }); - await waitAndUpdate(wrapper); - - wrapper.instance().handleSubmit(mockEvent()); - await new Promise(setImmediate); - - expect(setNewCodePeriod).toHaveBeenCalledWith({ - project: component, - type: 'SPECIFIC_ANALYSIS', - value: 'analysis572893', - branch: 'branchname' - }); -}); - -it('should disable the save button when saving', () => { - const wrapper = shallowRender(); - - wrapper.setState({ saving: true }); - - expect( - wrapper - .find('SubmitButton') - .first() - .prop('disabled') - ).toBe(true); -}); - -it('should disable the save button when date is invalid', () => { - const wrapper = shallowRender(); - - wrapper.setState({ days: 'asdf' }); - - expect( - wrapper - .find('SubmitButton') - .first() - .prop('disabled') - ).toBe(true); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx deleted file mode 100644 index 9bf67e0519e..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/BranchList-test.tsx +++ /dev/null @@ -1,130 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; -import { listBranchesNewCodePeriod, resetNewCodePeriod } from '../../../api/newCodePeriod'; -import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; -import { mockComponent } from '../../../helpers/testMocks'; -import BranchBaselineSettingModal from '../components/BranchBaselineSettingModal'; -import BranchList from '../components/BranchList'; - -jest.mock('../../../api/newCodePeriod', () => ({ - listBranchesNewCodePeriod: jest.fn().mockResolvedValue({ newCodePeriods: [] }), - resetNewCodePeriod: jest.fn().mockResolvedValue(null) -})); - -it('should render correctly', async () => { - (listBranchesNewCodePeriod as jest.Mock).mockResolvedValueOnce({ - newCodePeriods: [ - { - projectKey: '', - branchKey: 'master', - type: 'NUMBER_OF_DAYS', - value: '27' - } - ] - }); - const wrapper = shallowRender({ - branchLikes: [ - mockMainBranch(), - mockBranch(), - mockBranch({ name: 'branch-7.0' }), - mockPullRequest() - ] - }); - await waitAndUpdate(wrapper); - expect(wrapper.state().branches).toHaveLength(3); - expect(wrapper).toMatchSnapshot(); -}); - -it('should handle reset', () => { - const component = mockComponent(); - const wrapper = shallowRender({ component }); - - wrapper.instance().resetToDefault('master'); - - expect(resetNewCodePeriod).toBeCalledWith({ - project: component.key, - branch: 'master' - }); -}); - -it('should toggle popup', async () => { - const wrapper = shallowRender({ branchLikes: [mockMainBranch(), mockBranch()] }); - - wrapper.setState({ editedBranch: mockMainBranch() }); - - await waitAndUpdate(wrapper); - - const nodes = wrapper.find(BranchBaselineSettingModal); - expect(nodes).toHaveLength(1); - expect(nodes.first().props().branch).toEqual(mockMainBranch()); - - wrapper.instance().closeEditModal('master', { type: 'NUMBER_OF_DAYS', value: '23' }); - - expect(wrapper.find('BranchBaselineSettingModal')).toHaveLength(0); - expect(wrapper.state().branches.find(b => b.name === 'master')).toEqual({ - analysisDate: '2018-01-01', - excludedFromPurge: true, - isMain: true, - name: 'master', - newCodePeriod: { - type: 'NUMBER_OF_DAYS', - value: '23' - } - }); -}); - -it('should render the right setting label', () => { - const wrapper = shallowRender(); - - expect( - wrapper.instance().renderNewCodePeriodSetting({ type: 'NUMBER_OF_DAYS', value: '21' }) - ).toBe('baseline.number_days: 21'); - expect(wrapper.instance().renderNewCodePeriodSetting({ type: 'PREVIOUS_VERSION' })).toBe( - 'baseline.previous_version' - ); - expect( - wrapper.instance().renderNewCodePeriodSetting({ - type: 'SPECIFIC_ANALYSIS', - value: 'A85835', - effectiveValue: '2018-12-02T13:01:12' - }) - ).toMatchInlineSnapshot(` - - baseline.specific_analysis: - - - `); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/ProjectBaselineSelector-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/ProjectBaselineSelector-test.tsx deleted file mode 100644 index ddaf4522f07..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/ProjectBaselineSelector-test.tsx +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 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 ProjectBaselineSelector, { - ProjectBaselineSelectorProps -} from '../components/ProjectBaselineSelector'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect( - shallowRender({ - branchesEnabled: false, - generalSetting: { type: 'NUMBER_OF_DAYS', value: '23' } - }) - ).toMatchSnapshot(); - expect( - shallowRender({ branchesEnabled: false, generalSetting: { type: 'NUMBER_OF_DAYS', value: '' } }) - ).toMatchSnapshot(); -}); - -it('should not show save button when unchanged', () => { - const wrapper = shallowRender({ - currentSetting: 'PREVIOUS_VERSION', - selected: 'PREVIOUS_VERSION', - overrideGeneralSetting: true - }); - expect( - wrapper - .find('SubmitButton') - .parent() - .hasClass('invisible') - ).toBe(true); -}); - -it('should show save button when changed', () => { - const wrapper = shallowRender({ - currentSetting: 'PREVIOUS_VERSION', - selected: 'NUMBER_OF_DAYS', - overrideGeneralSetting: true - }); - expect(wrapper.find('SubmitButton')).toHaveLength(1); -}); - -it('should show save button when value changed', () => { - const wrapper = shallowRender({ - currentSetting: 'NUMBER_OF_DAYS', - currentSettingValue: '23', - days: '25', - selected: 'NUMBER_OF_DAYS', - overrideGeneralSetting: true - }); - expect(wrapper.find('SubmitButton')).toHaveLength(1); -}); - -it('should disable the save button when saving', () => { - const wrapper = shallowRender({ - currentSetting: 'NUMBER_OF_DAYS', - currentSettingValue: '25', - saving: true, - selected: 'PREVIOUS_VERSION', - overrideGeneralSetting: true - }); - - expect( - wrapper - .find('SubmitButton') - .first() - .prop('disabled') - ).toBe(true); -}); - -it('should disable the save button when date is invalid', () => { - const wrapper = shallowRender({ - currentSetting: 'PREVIOUS_VERSION', - days: 'hello', - selected: 'NUMBER_OF_DAYS', - overrideGeneralSetting: true - }); - - expect( - wrapper - .find('SubmitButton') - .first() - .prop('disabled') - ).toBe(true); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/App-test.tsx.snap deleted file mode 100644 index d23ae1223a0..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/App-test.tsx.snap +++ /dev/null @@ -1,60 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - -
-
-

- project_baseline.page -

-

- - project_baseline.page.description.link - , - } - } - /> -
- - project_baseline.page.description2.link - , - } - } - /> -

-
- -
-
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingAnalysis-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingAnalysis-test.tsx.snap deleted file mode 100644 index a5dc6125502..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingAnalysis-test.tsx.snap +++ /dev/null @@ -1,15 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -

- baseline.specific_analysis.description -

-
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingDays-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingDays-test.tsx.snap deleted file mode 100644 index aabe88a94a8..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingDays-test.tsx.snap +++ /dev/null @@ -1,82 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -

- baseline.number_days.description -

- - - -
-`; - -exports[`should render correctly 2`] = ` - -

- baseline.number_days.description -

- - - -
-`; - -exports[`should render correctly 3`] = ` - -

- baseline.number_days.description -

- - - -
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap deleted file mode 100644 index cb4acd788cb..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -

- baseline.previous_version.description -

-
-`; - -exports[`should render correctly 2`] = ` - -

- baseline.previous_version.description -

-
-`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap deleted file mode 100644 index e215412fa0a..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBaseline/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap +++ /dev/null @@ -1,45 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - -
- baseline.analysis_from - + + +`; + +exports[`should render correctly 2`] = ` + +

+ baseline.number_days.description +

+ + + +
+`; + +exports[`should render correctly 3`] = ` + +

+ baseline.number_days.description +

+ + + +
+`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap new file mode 100644 index 00000000000..cb4acd788cb --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BaselineSettingPreviousVersion-test.tsx.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +

+ baseline.previous_version.description +

+
+`; + +exports[`should render correctly 2`] = ` + +

+ baseline.previous_version.description +

+
+`; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap new file mode 100644 index 00000000000..46a6219e94d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/__snapshots__/BranchAnalysisList-test.tsx.snap @@ -0,0 +1,271 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +
+ baseline.analysis_from +