import ProjectBaselineSelector from './ProjectBaselineSelector';
interface Props {
+ branchLike: Branch;
branchLikes: BranchLike[];
branchesEnabled?: boolean;
canAdmin?: boolean;
}
fetchLeakPeriodSetting() {
+ const { branchLike, branchesEnabled, component } = this.props;
+
this.setState({ loading: true });
Promise.all([
getNewCodePeriod(),
getNewCodePeriod({
- branch: !this.props.branchesEnabled ? 'master' : undefined,
- project: this.props.component.key
+ branch: branchesEnabled ? undefined : branchLike.name,
+ project: component.key
})
]).then(
([generalSetting, setting]) => {
};
render() {
- const { branchesEnabled, canAdmin, component } = this.props;
+ const { branchesEnabled, canAdmin, component, branchLike } = this.props;
const {
analysis,
branchList,
{generalSetting && overrideGeneralSetting !== undefined && (
<ProjectBaselineSelector
analysis={analysis}
+ branch={branchLike}
branchList={branchList}
branchesEnabled={branchesEnabled}
component={component.key}
setNewCodePeriod: jest.fn().mockResolvedValue({})
}));
-it('should render correctly', () => {
- expect(shallowRender()).toMatchSnapshot();
+it('should render correctly', async () => {
+ let wrapper = shallowRender();
+ await waitAndUpdate(wrapper);
+ expect(wrapper).toMatchSnapshot();
+
+ wrapper = shallowRender({ branchesEnabled: false });
+ await waitAndUpdate(wrapper);
+ expect(wrapper).toMatchSnapshot('without branch support');
});
it('should initialize correctly', async () => {
function shallowRender(props: Partial<App['props']> = {}) {
return shallow<App>(
<App
+ branchLike={mockBranch()}
branchLikes={[mockMainBranch()]}
branchesEnabled={true}
canAdmin={true}
<AppHeader
canAdmin={true}
/>
- <DeferredSpinner />
+ <div
+ className="panel-white project-baseline"
+ >
+ <h2>
+ project_baseline.default_setting
+ </h2>
+ <ProjectBaselineSelector
+ analysis=""
+ branch={
+ Object {
+ "analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
+ "isMain": false,
+ "name": "branch-6.7",
+ }
+ }
+ branchList={
+ Array [
+ Object {
+ "analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
+ "isMain": true,
+ "name": "master",
+ },
+ ]
+ }
+ branchesEnabled={true}
+ component="my-project"
+ currentSetting="PREVIOUS_VERSION"
+ days="30"
+ generalSetting={
+ Object {
+ "type": "PREVIOUS_VERSION",
+ }
+ }
+ onCancel={[Function]}
+ onSelectAnalysis={[Function]}
+ onSelectDays={[Function]}
+ onSelectReferenceBranch={[Function]}
+ onSelectSetting={[Function]}
+ onSubmit={[Function]}
+ onToggleSpecificSetting={[Function]}
+ overrideGeneralSetting={true}
+ referenceBranch="master"
+ saving={false}
+ selected="PREVIOUS_VERSION"
+ />
+ <div
+ className="spacer-top invisible"
+ >
+ <span
+ className="text-success"
+ >
+ <AlertSuccessIcon
+ className="spacer-right"
+ />
+ settings.state.saved
+ </span>
+ </div>
+ <div
+ className="huge-spacer-top branch-baseline-selector"
+ >
+ <hr />
+ <h2>
+ project_baseline.configure_branches
+ </h2>
+ <BranchList
+ branchList={
+ Array [
+ Object {
+ "analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
+ "isMain": true,
+ "name": "master",
+ },
+ ]
+ }
+ component={
+ Object {
+ "breadcrumbs": Array [],
+ "key": "my-project",
+ "name": "MyProject",
+ "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 [],
+ }
+ }
+ inheritedSetting={
+ Object {
+ "type": "PREVIOUS_VERSION",
+ "value": undefined,
+ }
+ }
+ />
+ </div>
+ </div>
+ </div>
+</Fragment>
+`;
+
+exports[`should render correctly: without branch support 1`] = `
+<Fragment>
+ <Suggestions
+ suggestions="project_baseline"
+ />
+ <div
+ className="page page-limited"
+ >
+ <AppHeader
+ canAdmin={true}
+ />
+ <div
+ className="panel-white project-baseline"
+ >
+ <ProjectBaselineSelector
+ analysis=""
+ branch={
+ Object {
+ "analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
+ "isMain": false,
+ "name": "branch-6.7",
+ }
+ }
+ branchList={
+ Array [
+ Object {
+ "analysisDate": "2018-01-01",
+ "excludedFromPurge": true,
+ "isMain": true,
+ "name": "master",
+ },
+ ]
+ }
+ branchesEnabled={false}
+ component="my-project"
+ currentSetting="PREVIOUS_VERSION"
+ days="30"
+ generalSetting={
+ Object {
+ "type": "PREVIOUS_VERSION",
+ }
+ }
+ onCancel={[Function]}
+ onSelectAnalysis={[Function]}
+ onSelectDays={[Function]}
+ onSelectReferenceBranch={[Function]}
+ onSelectSetting={[Function]}
+ onSubmit={[Function]}
+ onToggleSpecificSetting={[Function]}
+ overrideGeneralSetting={true}
+ referenceBranch="master"
+ saving={false}
+ selected="PREVIOUS_VERSION"
+ />
+ <div
+ className="spacer-top invisible"
+ >
+ <span
+ className="text-success"
+ >
+ <AlertSuccessIcon
+ className="spacer-right"
+ />
+ settings.state.saved
+ </span>
+ </div>
+ </div>
</div>
</Fragment>
`;