Search in sources :

Example 16 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class BuildHistoryTest method view_build_history.

@Test
public void view_build_history() {
    ListView view = jenkins.views.create(ListView.class, "a_view");
    FreeStyleJob inViewJob = view.jobs.create(FreeStyleJob.class, "in_view");
    Build inViewBuild = inViewJob.startBuild().waitUntilFinished();
    FreeStyleJob outOfViewJob = jenkins.jobs.create(FreeStyleJob.class, "not_in_view");
    Build outOfViewBuild = outOfViewJob.startBuild().waitUntilFinished();
    Set<Build> history = view.getBuildHistory().getBuilds();
    assertThat(history, contains(inViewBuild));
    assertThat(history, not(contains(outOfViewBuild)));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 17 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class FreestyleJobTest method scheduleFromView.

@Test
public void scheduleFromView() throws Exception {
    FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class);
    ListView view = jenkins.views.create(ListView.class, "AView");
    view.configure();
    view.addJob(j);
    view.save();
    view.scheduleJob(j.name);
    j.build(1).waitUntilStarted().shouldSucceed();
    j.configure();
    StringParameter p = j.addParameter(StringParameter.class);
    p.setName("foo");
    j.save();
    view.scheduleJob(j.name);
    BuildWithParameters paramPage = new BuildWithParameters(j, new URL(driver.getCurrentUrl()));
    paramPage.enter(Collections.singletonList(p), Collections.singletonMap("foo", "bar"));
    paramPage.start();
    j.build(2).waitUntilStarted().shouldSucceed();
}
Also used : StringParameter(org.jenkinsci.test.acceptance.po.StringParameter) ListView(org.jenkinsci.test.acceptance.po.ListView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) BuildWithParameters(org.jenkinsci.test.acceptance.po.BuildWithParameters) URL(java.net.URL) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) SmokeTest(org.jenkinsci.test.acceptance.junit.SmokeTest) Test(org.junit.Test)

Example 18 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_include_failed_jobs_built_at_least_once.

/**
 * This test creates 3 jobs and builds 3 of them immediately. One of the fails. A list view is created with its job filter set to only
 * include jobs that failed.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_include_failed_jobs_built_at_least_once() {
    List<Job> jobs = createAmountOfJobs(2, true);
    Job job3 = createJobThatFails();
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "    buildTrend {\n" + "      matchType(MatchType.INCLUDE_MATCHED)\n" + "      buildCountType(BuildCountType.AT_LEAST_ONE)\n" + "      status(BuildStatusType.FAILED)\n" + "    }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(jobs.get(0))));
    assertThat(view, not(containsJob(jobs.get(1))));
    assertThat(view, containsJob(job3));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 19 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method status_filter_only_shows_enabled_jobs.

/**
 * Test if the created jobs are correctly added to the ListView and if the status filter works correctly.
 * In this case only enabled jobs shall be shown.
 */
@Test
public void status_filter_only_shows_enabled_jobs() {
    List<Job> jobs = createAmountOfJobs(3, false);
    Job jobDisabled = createDisabledJob();
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  statusFilter(StatusFilter.ENABLED)\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs {\n" + "    names('" + jobs.get(0).name + "', '" + jobs.get(1).name + "', '" + jobs.get(2).name + "', '" + jobDisabled.name + "')\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(jobDisabled)));
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
    assertThat(view, containsJob(jobs.get(2)));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 20 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method are_columns_created.

/**
 * Test if all native columns of a ListView are created and shown correctly.
 */
@Test
public void are_columns_created() {
    Job job1 = createJobAndBuild();
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    status()\n" + "    weather()\n" + "    name()\n" + "    lastSuccess()\n" + "    lastFailure()\n" + "    lastDuration()\n" + "    buildButton()\n" + "  }\n" + "  jobs{\n" + "    name('" + job1.name + "')\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsColumnHeaderTooltip("Status of the last build"));
    assertThat(view, containsColumnHeaderTooltip("Weather report showing aggregated status of recent builds"));
    assertThat(view, containsColumnHeader("Name"));
    assertThat(view, containsColumnHeader("Last Success"));
    assertThat(view, containsColumnHeader("Last Failure"));
    assertThat(view, containsColumnHeader("Last Duration"));
    String searchText = "Schedule a Build for " + job1.name;
    // behaviour change in https://github.com/jenkinsci/jenkins/pull/6084
    WebElement webElement = view.getElement(By.cssSelector(String.format("a[tooltip='%s']", searchText)));
    if (webElement != null) {
        assertThat(view, containsLinkWithTooltip(searchText));
    } else {
        assertThat(view, containsSvgWithText(searchText));
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WebElement(org.openqa.selenium.WebElement) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

ListView (org.jenkinsci.test.acceptance.po.ListView)31 Test (org.junit.Test)28 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)27 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)26 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 View (org.jenkinsci.test.acceptance.po.View)20 Job (org.jenkinsci.test.acceptance.po.Job)18 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)13 Build (org.jenkinsci.test.acceptance.po.Build)4 Pattern (java.util.regex.Pattern)3 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)3 Category (org.junit.experimental.categories.Category)2 WebElement (org.openqa.selenium.WebElement)2 URL (java.net.URL)1 AnalysisCollectorColumn (org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorColumn)1 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)1 BuildWithParameters (org.jenkinsci.test.acceptance.po.BuildWithParameters)1 MatrixProject (org.jenkinsci.test.acceptance.po.MatrixProject)1 StringParameter (org.jenkinsci.test.acceptance.po.StringParameter)1 Issue (org.jvnet.hudson.test.Issue)1