Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-37523 - wrong message displayed for duplicate item name
  • Loading branch information
kzantow committed Aug 19, 2016
1 parent 0732769 commit fc1c995
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Expand Up @@ -15,12 +15,16 @@ public class JobsMixIn extends MixIn {
public JobsMixIn(ContainerPageObject context) {
super(context);
}

public WebElement findTypeCaption(Class<?> type) {
return findCaption(type, getFinder());
}

public <T extends TopLevelItem> T create(Class<T> type, String name) {
visit("newJob");
fillIn("name", name);

findCaption(type, getFinder()).click();
findTypeCaption(type).click();

// since 2.7, a bug in Firefox webdriver may prevent the blur event from triggering
// properly, so we manually execute a blur event here, see: JENKINS-37232
Expand Down
37 changes: 37 additions & 0 deletions src/test/java/core/CreateItemTest.java
@@ -0,0 +1,37 @@
package core;

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
import org.junit.Test;
import org.openqa.selenium.By;

public class CreateItemTest extends AbstractJUnitTest {
@Test
public void duplicate_item_name_displays_error() {
// create a job with a known name
jenkins.jobs.create(FreeStyleJob.class, "asdf");

// go try to create one with the same name
jenkins.jobs.visit("newJob");

fillIn("name", "asdf");

blur(find(By.name("name")));

// the 'name cannot be empty' message:
assert(!findIfNotVisible(By.id("itemname-required")).isDisplayed());
// the 'real' message:
assert(findIfNotVisible(By.id("itemname-invalid")).isDisplayed());

assert(!findIfNotVisible(By.id("ok-button")).isEnabled());

jenkins.jobs.findTypeCaption(FreeStyleJob.class).click();

// the 'name cannot be empty' message:
assert(!findIfNotVisible(By.id("itemname-required")).isDisplayed());
// the 'real' message:
assert(findIfNotVisible(By.id("itemname-invalid")).isDisplayed());

assert(!findIfNotVisible(By.id("ok-button")).isEnabled());
}
}

0 comments on commit fc1c995

Please sign in to comment.