Skip to content

Commit

Permalink
Added a test case that checks trend configuration via cookie.
Browse files Browse the repository at this point in the history
Basically a test the checks that [JENKINS-25917] and [JENKINS-32377] are resolved in Jenkins 2.1.
  • Loading branch information
uhafner committed May 4, 2016
1 parent 450e857 commit b369132
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
Expand Up @@ -18,6 +18,10 @@ public class GraphConfigurationView extends ContainerPageObject {
private final Control parameterValue = control("/parameterValue");
private final Control useBuildDateAsDomain = control("/useBuildDateAsDomain");
private final Control fixed = control("/graphType[FIXED]");
private final Control priority = control("/graphType[PRIORITY]");
private final Control totals = control("/graphType[TOTALS]");
private final Control difference = control("/graphType[DIFFERENCE]");
private final Control none = control("/graphType[NONE]");

public GraphConfigurationView(final ContainerPageObject parent, final String plugin) {
super(parent, parent.url("%s/configure/", plugin));
Expand All @@ -37,4 +41,8 @@ public WebDriver open() {
elasticSleep(1000); // trend graphs take some time to compute...
return open;
}

public void deactivateTrend() {
none.click();
}
}
53 changes: 48 additions & 5 deletions src/test/java/plugins/AbstractAnalysisTest.java
Expand Up @@ -23,6 +23,7 @@
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisConfigurator;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisMavenSettings;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisSettings;
import org.jenkinsci.test.acceptance.plugins.analysis_core.GraphConfigurationView;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.plugins.email_ext.EmailExtPublisher;
Expand Down Expand Up @@ -154,13 +155,9 @@ public void should_navigate_to_result_action_from_job() {
@Test
@Issue({"JENKINS-21723", "JENKINS-29900"})
public void should_have_trend_graph_with_relative_links() {
FreeStyleJob job = createFreeStyleJob();
buildJobAndWait(job);
buildSuccessfulJob(job);
FreeStyleJob job = buildJobTwoTimesInARow();

AnalysisAction action = createProjectAction(job);
job.open();

verifyTrendGraphOverview(job, action);
verifyTrendGraphDetails(job, action);
}
Expand Down Expand Up @@ -198,6 +195,52 @@ protected void assertThatProjectPageTrendIsCorrect(final FreeStyleJob job, final
}
}

/**
* Runs the test case {@link #should_have_trend_graph_with_relative_links} with a job that contains a space in the
* name. Then the trend is deactivated in the trend configuration view: now the trend should be replaced with a link
* to re-enable the trend. Finally, this link is clicked in order open the trend configuration again.
*/
@Test
@Issue({"JENKINS-25917", "JENKINS-32377"})
public void should_store_trend_selection_in_cookie() {
FreeStyleJob job = buildJobTwoTimesInARow();

// FIXME: renaming of a job does change the name but not the URL
// job.configure();
// job.setName(job.name.replace("_", " "));
// job.save();
// clickButton("Yes");

AnalysisAction action = createProjectAction(job);
verifyTrendGraphOverview(job, action);

deactivateTrendGraph(job, action);
}

private FreeStyleJob buildJobTwoTimesInARow() {
FreeStyleJob job = createFreeStyleJob();
buildJobAndWait(job);
buildSuccessfulJob(job);
job.open();
return job;
}

private void deactivateTrendGraph(final FreeStyleJob job, final AnalysisAction action) {
GraphConfigurationView view = action.configureTrendGraphForUser();

view.open();
view.deactivateTrend();
view.save();

List<WebElement> enableLinks = job.all(By.partialLinkText("Enable"));
assertThat(enableLinks.size(), is(1));

enableLinks.get(0).click();
elasticSleep(500);

assertThat(getCurrentUrl(), endsWith(action.getUrl() + "/configure/"));
}

/**
* Creates a specific project action of the plug-in under test.
*
Expand Down

0 comments on commit b369132

Please sign in to comment.