}
fetchQualityGates() {
- Promise.all([fetchQualityGatesAppDetails(), fetchQualityGatesAPI()]).then(responses => {
- const [details, qualityGates] = responses;
- const { updateStore } = this.props;
-
+ Promise.all([
+ fetchQualityGatesAppDetails(),
+ fetchQualityGatesAPI()
+ ]).then(([details, qualityGates]) => {
+ const { organization, updateStore } = this.props;
updateStore({ ...details, qualityGates });
+ if (qualityGates && qualityGates.length === 1 && !details.edit) {
+ this.context.router.replace(
+ getQualityGateUrl(qualityGates[0].id, organization && organization.key)
+ );
+ }
});
}
const defaultTitle = translate('quality_gates.page');
const top = organization ? 95 : 30;
return (
- <div className="layout-page">
+ <div id="quality-gates-page" className="layout-page">
<Helmet defaultTitle={defaultTitle} titleTemplate={'%s - ' + defaultTitle} />
<div className="layout-page-side-outer">
}
public ProjectDashboardPage hasQualityGateLink(String name, String link) {
- SelenideElement elem = $(".overview-meta-header").should(exist)
- .parent().find(By.linkText(name)).should(exist);
+ SelenideElement elem = $$(".overview-meta-card")
+ .findBy(text("Quality Gate")).should(exist)
+ .find(By.linkText(name)).should(exist);
assertThat(elem.attr("href")).endsWith(link);
return this;
}
public class QualityGatePage {
public QualityGatePage() {
- $(".quality-gates-results").shouldBe(Condition.visible);
+ $("#quality-gates-page").shouldBe(Condition.visible);
}
public QualityGatePage countQualityGates(Integer count) {
- $$(".quality-gates-results .list-group-item").shouldHaveSize(count);
+ $$("#quality-gates-page .list-group-item").shouldHaveSize(count);
return this;
}
$("#quality-gate-add").shouldNot(Condition.exist);
return this;
}
+
+ public QualityGatePage displayIntro() {
+ $(".search-navigator-intro").should(Condition.exist).shouldBe(Condition.visible);
+ return this;
+ }
+
+ public QualityGatePage displayQualityGateDetail(String qualityGateName) {
+ $(".layout-page-main-header").shouldHave(Condition.text(qualityGateName));
+ return this;
+ }
}
return this;
}
+ public Organizations.Organization getDefaultOrganization() {
+ return service().search(SearchWsRequest.builder().build()).getOrganizationsList()
+ .stream()
+ .filter(o -> o.getKey().equals("default-organization"))
+ .findFirst().orElseThrow(() -> new IllegalStateException("Can't find default organization"));
+ }
+
public OrganizationTester assertThatOrganizationDoesNotExist(String organizationKey) {
SearchWsRequest request = new SearchWsRequest.Builder().setOrganizations(organizationKey).build();
Organizations.SearchWsResponse searchWsResponse = service().search(request);
private Organizations.Organization organization;
private WsUsers.CreateWsResponse.User user;
+ private WsUsers.CreateWsResponse.User gateAdmin;
@Before
public void setUp() throws Exception {
organization = tester.organizations().generate();
+ gateAdmin = tester.users().generate();
+ tester.organizations().addMember(tester.organizations().getDefaultOrganization(), gateAdmin);
+ tester.wsClient().permissions().addUser(new org.sonarqube.ws.client.permission.AddUserWsRequest().setLogin(gateAdmin.getLogin()).setPermission("gateadmin"));
user = tester.users().generate();
tester.organizations().addMember(organization, user);
restoreProfile(orchestrator, getClass().getResource("/issue/with-many-rules.xml"), organization.getKey());
.logIn().submitCredentials(user.getLogin())
.openQualityGates(organization.getKey());
- SelenideElement element = $(".navbar-context .navbar-nav")
+ SelenideElement element = $(".navbar-context .navbar-tabs")
.find(By.linkText("Quality Gates"))
.should(Condition.exist);
assertThat(element.attr("href")).endsWith("/organizations/" + organization.getKey() + "/quality_gates");
@Test
public void should_display_available_quality_gates() {
QualityGatePage page = tester.openBrowser()
- .logIn().submitCredentials(user.getLogin())
+ .logIn().submitCredentials(gateAdmin.getLogin())
.openQualityGates(organization.getKey());
- page.countQualityGates(1);
+ page.countQualityGates(1).displayIntro();
}
@Test
.openQualityGates(organization.getKey())
.canNotCreateQG();
tester.openBrowser()
- .logIn().submitCredentials("admin")
+ .logIn().submitCredentials(gateAdmin.getLogin())
.openQualityGates(organization.getKey())
.canCreateQG();
}
.openProjectDashboard(project);
page.hasQualityGateLink("SonarQube way", link);
}
+
+ @Test
+ public void should_redirect_to_display_quality_gate_detail() {
+ QualityGatePage page = tester.openBrowser()
+ .logIn().submitCredentials(user.getLogin())
+ .openQualityGates(organization.getKey());
+ page.countQualityGates(1).displayQualityGateDetail("SonarQube way");
+ }
}
import org.sonarqube.pageobjects.Navigation;
import org.sonarqube.pageobjects.ProjectActivityPage;
import org.sonarqube.tests.Tester;
+import org.sonarqube.ws.Organizations;
+import org.sonarqube.ws.WsUsers;
import static com.codeborne.selenide.Selenide.$;
import static org.apache.commons.lang.time.DateUtils.addDays;
.logIn().submitCredentials(login)
.openQualityGates();
- SelenideElement element = $(".navbar-global .navbar-nav")
+ SelenideElement element = $(".navbar-global .global-navbar-menu")
.find(By.linkText("Quality Gates"))
.should(Condition.exist);
assertThat(element.attr("href")).endsWith("/quality_gates");
@Test
public void should_not_allow_random_user_to_create() {
String login = tester.users().generate().getLogin();
+ String admin = tester.users().generateAdministrator().getLogin();
tester.openBrowser()
.logIn().submitCredentials(login)
.openQualityGates()
- .canNotCreateQG();
+ .canNotCreateQG()
+ .displayQualityGateDetail("SonarQube way");
tester.openBrowser()
- .logIn().submitCredentials("admin")
+ .logIn().submitCredentials(admin)
.openQualityGates()
- .canCreateQG();
+ .canCreateQG()
+ .displayIntro();
}
private void scanSampleWithDate(String date) {