groupByDomains, | groupByDomains, | ||||
sortMeasures | sortMeasures | ||||
} from '../utils'; | } from '../utils'; | ||||
import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches'; | |||||
import { | |||||
isSameBranchLike, | |||||
getBranchLikeQuery, | |||||
isShortLivingBranch, | |||||
isPullRequest | |||||
} from '../../../helpers/branches'; | |||||
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; | import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; | ||||
import { | import { | ||||
getLocalizedMetricDomain, | getLocalizedMetricDomain, | ||||
return <MeasuresEmpty />; | return <MeasuresEmpty />; | ||||
} | } | ||||
const hideDrilldown = | |||||
(isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && | |||||
(metric.key === 'coverage' || metric.key === 'duplicated_lines_density'); | |||||
if (hideDrilldown) { | |||||
return ( | |||||
<div className="layout-page-main"> | |||||
<div className="layout-page-main-inner"> | |||||
<div className="note">{translate('component_measures.details_are_not_available')}</div> | |||||
</div> | |||||
</div> | |||||
); | |||||
} | |||||
return ( | return ( | ||||
<MeasureContentContainer | <MeasureContentContainer | ||||
branchLike={branchLike} | branchLike={branchLike} |
new_bugs: { id: '4', key: 'new_bugs', type: 'INT', name: 'New Bugs', domain: 'Reliability' } | new_bugs: { id: '4', key: 'new_bugs', type: 'INT', name: 'New Bugs', domain: 'Reliability' } | ||||
}; | }; | ||||
const PROPS = { | |||||
branch: { isMain: true, name: 'master' }, | |||||
const PROPS: App['props'] = { | |||||
branchLike: { isMain: true, name: 'master' }, | |||||
component: COMPONENT, | component: COMPONENT, | ||||
currentUser: { isLoggedIn: false }, | currentUser: { isLoggedIn: false }, | ||||
location: { pathname: '/component_measures', query: { metric: 'coverage' } }, | location: { pathname: '/component_measures', query: { metric: 'coverage' } }, | ||||
await waitAndUpdate(wrapper); | await waitAndUpdate(wrapper); | ||||
expect(wrapper).toMatchSnapshot(); | expect(wrapper).toMatchSnapshot(); | ||||
}); | }); | ||||
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} />); | |||||
await waitAndUpdate(wrapper); | |||||
expect(wrapper).toMatchSnapshot(); | |||||
}); |
// Jest Snapshot v1, https://goo.gl/fbAQLP | // Jest Snapshot v1, https://goo.gl/fbAQLP | ||||
exports[`should not render drilldown for estimated duplications 1`] = ` | |||||
<div | |||||
id="component-measures" | |||||
> | |||||
<Suggestions | |||||
suggestions="component_measures" | |||||
/> | |||||
<HelmetWrapper | |||||
defer={true} | |||||
encodeSpecialCharacters={true} | |||||
title="Coverage" | |||||
/> | |||||
<div | |||||
className="layout-page" | |||||
> | |||||
<ScreenPositionHelper | |||||
className="layout-page-side-outer" | |||||
/> | |||||
<div | |||||
className="layout-page-main" | |||||
> | |||||
<div | |||||
className="layout-page-main-inner" | |||||
> | |||||
<div | |||||
className="note" | |||||
> | |||||
component_measures.details_are_not_available | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
`; | |||||
exports[`should render a message when there are no measures 1`] = ` | exports[`should render a message when there are no measures 1`] = ` | ||||
<div | <div | ||||
id="component-measures" | id="component-measures" | ||||
<Component /> | <Component /> | ||||
</ScreenPositionHelper> | </ScreenPositionHelper> | ||||
<MeasureContentContainer | <MeasureContentContainer | ||||
branchLike={ | |||||
Object { | |||||
"isMain": true, | |||||
"name": "master", | |||||
} | |||||
} | |||||
className="layout-page-main" | className="layout-page-main" | ||||
currentUser={ | currentUser={ | ||||
Object { | Object { | ||||
"duplicated_lines_density", | "duplicated_lines_density", | ||||
"new_bugs", | "new_bugs", | ||||
], | ], | ||||
undefined, | |||||
Object { | |||||
"isMain": true, | |||||
"name": "master", | |||||
}, | |||||
], | ], | ||||
], | ], | ||||
"results": Array [ | "results": Array [ |
'new_uncovered_conditions', | 'new_uncovered_conditions', | ||||
'new_branch_coverage', | 'new_branch_coverage', | ||||
'duplicated_lines_density', | |||||
'new_duplicated_lines_density', | 'new_duplicated_lines_density', | ||||
'new_duplicated_lines', | 'new_duplicated_lines', | ||||
'new_duplicated_blocks' | 'new_duplicated_blocks' |
# COMPONENT MEASURES | # COMPONENT MEASURES | ||||
# | # | ||||
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ | ||||
component_measures.details_are_not_available=Details are not available for estimated measures. | |||||
component_measures.domain_x_overview={0} Overview | component_measures.domain_x_overview={0} Overview | ||||
component_measures.domain_overview=Overview | component_measures.domain_overview=Overview | ||||
component_measures.files=files | component_measures.files=files |