Skip to content

Commit

Permalink
[JENKINS-42581] Introduce method to trigger a re-index. Also contempl…
Browse files Browse the repository at this point in the history
…ate that a folder might not have a new view tab.
  • Loading branch information
Evaristo Gutiérrez committed Mar 8, 2017
1 parent 5260eb9 commit 2756ba7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/org/jenkinsci/test/acceptance/po/Folder.java
Expand Up @@ -39,8 +39,6 @@
@Describable("com.cloudbees.hudson.plugins.folder.Folder")
public class Folder extends TopLevelItem implements Container {

private static final String ALL_VIEW = "All";

private final JobsMixIn jobs;
private final ViewsMixIn views;
private final Control properties = control("/com-cloudbees-hudson-plugins-folder-properties-EnvVarsFolderProperty/properties");
Expand Down Expand Up @@ -106,25 +104,33 @@ public String getActiveViewName() {

public <T extends View> T selectView(final Class<T> type, final String viewName) {
final List<WebElement> viewTabs = this.getViewTabs();
int i = 0;

for (final WebElement tab : viewTabs) {
if (tab.getText().equals(viewName)) {
tab.click();

if (ALL_VIEW.equals(viewName)) {
if (i == 0) {
return null;
} else {
return newInstance(type, injector, url("view/%s/", viewName));
}
}

i++;
}

throw new NoSuchElementException(String.format("There is no view with name [%s]", viewName));
}

private List<WebElement> getViewTabs() {
final List<WebElement> viewTabs = driver.findElements(viewTab);
viewTabs.remove(viewTabs.size() - 1); // add new view tab

final int lastViewIndex = viewTabs.size() - 1;

if ("+".equals(viewTabs.get(lastViewIndex).getText())) {
viewTabs.remove(lastViewIndex);
}

return viewTabs;
}
Expand Down
Expand Up @@ -58,4 +58,9 @@ public WorkflowJob getJob(final String name) {
return this.getJobs().get(WorkflowJob.class, name);
}

public void reIndex() {
driver.findElement(by.xpath("//div[@class=\"task\"]//*[text()=\"Scan Repository\" or text()=\"Branch Indexing\"]")).click();
driver.findElement(by.xpath("//div[@class=\"subtasks\"]//*[text()=\"Run Now\"]")).click();
}

}
7 changes: 7 additions & 0 deletions src/test/java/plugins/WorkflowMultibranchTest.java
Expand Up @@ -46,6 +46,13 @@ public void testMultibranchPipeline() throws IOException, MessagingException {
final WorkflowJob failureJob = multibranchJob.getJob("jenkinsfile_failure");
this.assertExistAndRun(successJob, true);
this.assertExistAndRun(failureJob, false);

multibranchJob.open();
multibranchJob.reIndex();
multibranchJob.waitForBranchIndexingFinished(20);

this.assertExistAndRun(successJob, true);
this.assertExistAndRun(failureJob, false);
}

private void configureJobWithGithubBranchSource(final WorkflowMultiBranchJob job) {
Expand Down

0 comments on commit 2756ba7

Please sign in to comment.