return this;
}
- public QualityGatePage displayIntro() {
- $(".search-navigator-intro").should(exist).shouldBe(visible);
- return this;
- }
-
public QualityGatePage displayQualityGateDetail(String qualityGateName) {
$(".layout-page-main-header").shouldHave(text(qualityGateName));
return this;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { InjectedRouter } from 'react-router';
import { translate } from '../../../helpers/l10n';
+import { QualityGate } from '../../../app/types';
+import { getQualityGateUrl } from '../../../helpers/urls';
-export default function Intro() {
- return (
- <div className="layout-page-main">
- <div className="layout-page-main-inner">
- <div className="search-navigator-intro markdown">
- <p>{translate('quality_gates.intro.1')}</p>
- <p>{translate('quality_gates.intro.2')}</p>
+interface Props {
+ organization?: string;
+ qualityGates: QualityGate[];
+ router: InjectedRouter;
+}
+
+export default class Intro extends React.PureComponent<Props> {
+ componentDidMount() {
+ const defaultQualityGate = this.props.qualityGates.find(qualityGate =>
+ Boolean(qualityGate.isDefault)
+ );
+ if (defaultQualityGate) {
+ this.props.router.replace(
+ getQualityGateUrl(String(defaultQualityGate.id), this.props.organization)
+ );
+ }
+ }
+
+ render() {
+ return (
+ <div className="layout-page-main">
+ <div className="layout-page-main-inner">
+ <div className="search-navigator-intro markdown">
+ <p>{translate('quality_gates.intro.1')}</p>
+ <p>{translate('quality_gates.intro.2')}</p>
+ </div>
</div>
</div>
- </div>
- );
+ );
+ }
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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 * as React from 'react';
+import { shallow } from 'enzyme';
+import Intro from '../Intro';
+
+it('should redirect to detail of default quality gate', () => {
+ const replace = jest.fn();
+ shallow(
+ <Intro
+ organization="foo"
+ qualityGates={[{ id: 1, name: 'Bar', isDefault: true }]}
+ router={{ replace } as any}
+ />
+ );
+ expect(replace).toHaveBeenCalledWith({ pathname: '/organizations/foo/quality_gates/show/1' });
+});
+
+it('should display the intro', () => {
+ expect(
+ shallow(<Intro organization="foo" qualityGates={[]} router={{} as any} />)
+ ).toMatchSnapshot();
+});
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should display the intro 1`] = `
+<div
+ className="layout-page-main"
+>
+ <div
+ className="layout-page-main-inner"
+ >
+ <div
+ className="search-navigator-intro markdown"
+ >
+ <p>
+ quality_gates.intro.1
+ </p>
+ <p>
+ quality_gates.intro.2
+ </p>
+ </div>
+ </div>
+</div>
+`;
QualityGatePage page = tester.openBrowser()
.logIn().submitCredentials(gateAdmin.getLogin())
.openQualityGates(organization.getKey());
- page.countQualityGates(1).displayIntro();
+ page.countQualityGates(1).displayQualityGateDetail("Sonar way");
}
@Test
.logIn().submitCredentials(admin)
.openQualityGates()
.canCreateQG()
- .displayIntro();
+ .displayQualityGateDetail("Sonar way");
}
@Test