Skip to content

Commit 7b8c430

Browse files
authored
Test 'Refine the 'New Item' screen' (#2572)
1 parent 51be5ec commit 7b8c430

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public void copy(Job from, String to) {
9797

9898
public void copy(String from, String to) {
9999
visit("newJob");
100+
101+
// Newer versions of Jenkins have an additional radio before the 'from' input is available, so click it
102+
all(by.radioButton("Duplicate an existing item")).forEach(WebElement::click);
103+
100104
fillIn("from", from);
101105
// There is a javascript magic bound to loss of focus on 'from' field that is a pain to duplicate through
102106
// selenium
@@ -109,7 +113,7 @@ public void copy(String from, String to) {
109113
@Override
110114
protected WebElement find(String caption) {
111115
String normalizedCaption = caption.replace('.', '_');
112-
return outer.find(by.css("li." + normalizedCaption));
116+
return outer.find(by.css("." + normalizedCaption));
113117
}
114118
};
115119

src/test/java/core/CreateItemTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package core;
22

3+
import static org.hamcrest.CoreMatchers.not;
34
import static org.hamcrest.MatcherAssert.assertThat;
45
import static org.jenkinsci.test.acceptance.Matchers.hasContent;
56
import static org.junit.Assert.assertFalse;
6-
import static org.junit.Assert.assertTrue;
77

88
import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
99
import org.jenkinsci.test.acceptance.junit.Since;
@@ -17,9 +17,9 @@ public class CreateItemTest extends AbstractJUnitTest {
1717
private static final String JOB_NAME = "asdf";
1818
private static final String NAME_FIELD = "name";
1919
private static final String JOB_CREATION_ERROR_MSG = "A job already exists";
20+
private static final String NAME_NOT_EMPTY_MSG = "This field cannot be empty, please enter a valid name";
21+
private static final String EXISTING_NAME_MSG = "A job already exists with the name ‘asdf’";
2022

21-
private static final By NAME_NOT_EMPTY_MSG = by.id("itemname-required");
22-
private static final By EXISTING_NAME_MSG = by.id("itemname-invalid");
2323
private static final By OK_BUTTON = by.id("ok-button");
2424

2525
@Test
@@ -33,20 +33,17 @@ public void duplicate_item_name_displays_error() {
3333
fillIn(NAME_FIELD, JOB_NAME);
3434
blur(find(by.name(NAME_FIELD)));
3535

36-
assertFalse(findIfNotVisible(NAME_NOT_EMPTY_MSG).isDisplayed());
37-
assertTrue(find(EXISTING_NAME_MSG).isDisplayed());
36+
assertThat(driver, not(hasContent(NAME_NOT_EMPTY_MSG)));
37+
assertThat(driver, hasContent(EXISTING_NAME_MSG));
3838
assertFalse(find(OK_BUTTON).isEnabled());
3939

4040
// select type of job
4141
jenkins.jobs.findTypeCaption(FreeStyleJob.class).click();
4242

43-
assertFalse(findIfNotVisible(NAME_NOT_EMPTY_MSG).isDisplayed());
44-
assertTrue(find(EXISTING_NAME_MSG).isDisplayed());
43+
assertThat(driver, not(hasContent(NAME_NOT_EMPTY_MSG)));
44+
assertThat(driver, hasContent(EXISTING_NAME_MSG));
4545

4646
final WebElement okButtonElement = find(OK_BUTTON);
47-
// TODO JENKINS-73034
48-
// assertTrue(okButtonElement.isEnabled());
49-
5047
okButtonElement.click();
5148
assertThat(driver, hasContent(JOB_CREATION_ERROR_MSG));
5249
}

0 commit comments

Comments
 (0)