Skip to content

Commit

Permalink
[JENKINS-14632] Use a more specific selector so we don't risk matchin… (
Browse files Browse the repository at this point in the history
#3467)

* [JENKINS-14632] Use a more specific selector so we don't risk matching an element we are not expecting

* [JENKINS-14632] Annotate test with issue number
  • Loading branch information
Vlatombe authored and oleg-nenashev committed Jun 1, 2018
1 parent d7da517 commit 7619aed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/lib/form/advanced/advanced.js
Expand Up @@ -3,7 +3,7 @@ Behaviour.specify("INPUT.advanced-button", 'advanced', 0, function(e) {
var link = $(e.target).up(".advancedLink");
link.style.display = "none"; // hide the button

var container = link.next().down(); // TABLE -> TBODY
var container = link.next("table.advancedBody").down(); // TABLE -> TBODY

var tr = link.up("TR");

Expand All @@ -25,4 +25,4 @@ Behaviour.specify("INPUT.advanced-button", 'advanced', 0, function(e) {
layoutUpdateCallback.call();
});
e = null; // avoid memory leak
});
});
12 changes: 11 additions & 1 deletion test/src/test/java/lib/form/AdvancedButtonTest.java
Expand Up @@ -6,6 +6,7 @@
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.Issue;
import org.kohsuke.stapler.StaplerRequest;


Expand All @@ -32,4 +33,13 @@ public FormValidation doSubmitNestedOptionalBlock(StaplerRequest req) throws Exc
assertEquals("dvalue",c.getString("d"));
return FormValidation.ok();
}
}

@Issue("JENKINS-14632")
public void testSectionInsideOfAdvanced() throws Exception {
HtmlPage p = createWebClient().goTo("self/testSectionInsideOfAdvanced");
HtmlForm f = p.getFormByName("config");
assertFalse(f.getInputByName("b").isDisplayed());
HtmlFormUtil.getButtonByCaption(f, "Advanced...").click();
assertTrue(f.getInputByName("b").isDisplayed());
}
}
@@ -0,0 +1,20 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout title="Testing the effect of validateButton">
<l:main-panel>
<f:form method="post" name="config" action="">
<f:entry title="a">
<f:textbox name="a" value="avalue" />
</f:entry>
<f:advanced>
<f:section title="foo">
<f:entry title="b">
<f:textbox name="b" value="bvalue" />
</f:entry>
</f:section>
</f:advanced>
<f:submit value="submit" />
</f:form>
</l:main-panel>
</l:layout>
</j:jelly>

0 comments on commit 7619aed

Please sign in to comment.