Search in sources :

Example 11 with View

use of org.jenkinsci.test.acceptance.po.View 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 12 with View

use of org.jenkinsci.test.acceptance.po.View 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)

Example 13 with View

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

the class JobDslPluginTest method job_filters_most_recent_3_jobs.

/**
 * This test creates 5 jobs and builds them immediately. A list view is created with its job filter set to show the
 * 3 jobs which were most recently built.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_most_recent_3_jobs() {
    List<Job> jobs = createAmountOfJobs(5, true);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs{\n" + "    names('" + jobs.get(0).name + "','" + jobs.get(1).name + "','" + jobs.get(2).name + "','" + jobs.get(3).name + "','" + jobs.get(4).name + "')\n" + "  }\n" + "  jobFilters {\n" + "    mostRecent {\n" + "      maxToInclude(3)\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(jobs.get(2)));
    assertThat(view, containsJob(jobs.get(3)));
    assertThat(view, containsJob(jobs.get(4)));
}
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 14 with View

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

the class JobDslPluginTest method job_filters_regex_name_exclude_matched.

/**
 * This test creates a listView and 4 jobs. The job filters are checking the name with a regex and
 * jobs matching the regex are excluded in the listView.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_regex_name_exclude_matched() {
    Job job1 = createJobWithName(EXAMPLE_DISABLED_NAME);
    Job job2 = createJobWithName(EXAMPLE_ENABLED_NAME);
    List<Job> jobs = createAmountOfJobs(2, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs{\n" + "    names('" + job1.name + "','" + job2.name + "','" + jobs.get(0).name + "','" + jobs.get(1).name + "')\n" + "  }\n" + "  jobFilters {\n" + "        regex {\n" + "            matchType(MatchType.EXCLUDE_MATCHED)\n" + "            matchValue(RegexMatchValue.NAME)\n" + "            regex('" + LIST_VIEW_REGEX + "')\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(job1)));
    assertThat(view, not(containsJob(job2)));
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
}
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 15 with View

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

the class JobDslPluginTest method status_filter_shows_all_jobs.

/**
 * Test if the created jobs are correctly added to the ListView and if the status filter works correctly.
 * In this case all jobs shall be shown.
 */
@Test
public void status_filter_shows_all_jobs() {
    List<Job> jobs = createAmountOfJobs(4, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  statusFilter(StatusFilter.ALL)\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs {\n" + "    names('" + jobs.get(0).name + "', '" + jobs.get(1).name + "', '" + jobs.get(2).name + "', '" + jobs.get(3).name + "')\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
    assertThat(view, containsJob(jobs.get(2)));
    assertThat(view, containsJob(jobs.get(3)));
}
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)

Aggregations

ListView (org.jenkinsci.test.acceptance.po.ListView)20 View (org.jenkinsci.test.acceptance.po.View)20 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)19 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)19 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)19 Test (org.junit.Test)19 Job (org.jenkinsci.test.acceptance.po.Job)18 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)13 WebElement (org.openqa.selenium.WebElement)1