-
-
Notifications
You must be signed in to change notification settings - Fork 295
fix: styling of select boxes for issue and version parameter #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 8 additions & 22 deletions
30
...resources/hudson/plugins/jira/versionparameter/JiraVersionParameterDefinition/index.jelly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,12 @@ | ||
| <!-- this is the page fragment displayed when triggering a new build --> | ||
| <?jelly escape-by-default='true'?> | ||
| <j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
| <j:set var="escapeEntryTitleAndDescription" value="false"/> | ||
| <f:entry title="${h.escape(it.name)}" description="${it.formattedDescription}"> | ||
| <!-- this div is required because of ParametersDefinitionProperty.java#117 --> | ||
| <div name="parameter"> | ||
rantoniuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <input type="hidden" name="name" value="${it.name}"/> | ||
| <j:choose> | ||
| <j:when test="${it.versions == null or it.versions.size() == 0}"> | ||
| <!-- no tags at all --> | ||
| ${%No versions found meeting your filter criteria.}<br/> | ||
| ${%If you trigger the build, it will likely fail.} | ||
| </j:when> | ||
| <j:otherwise> | ||
| <!-- everything is fine, we can display the drop-down list to the user --> | ||
| <select name="version"> | ||
| <j:forEach var="version" items="${it.versions}"> | ||
| <option value="${version.name}">${version.name}</option> | ||
| </j:forEach> | ||
| </select> | ||
| </j:otherwise> | ||
| </j:choose> | ||
| </div> | ||
| </f:entry> | ||
| <j:set var="escapeEntryTitleAndDescription" value="false"/> | ||
| <j:set var="descriptor" value="${it.descriptor}"/> | ||
| <f:entry field="version" title="${h.escape(it.name)}" description="${it.formattedDescription}"> | ||
| <div name="parameter"> | ||
| <input type="hidden" name="name" value="${it.name}"/> | ||
| <f:select/> | ||
| </div> | ||
| </f:entry> | ||
| </j:jelly> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/test/java/hudson/plugins/jira/listissuesparameter/JiraIssueParameterDefinitionTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| package hudson.plugins.jira.listissuesparameter; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.hasSize; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import com.atlassian.jira.rest.client.api.domain.Issue; | ||
| import hudson.model.Item; | ||
| import hudson.model.Job; | ||
| import hudson.model.ParameterValue; | ||
| import hudson.model.ParametersDefinitionProperty; | ||
| import hudson.plugins.jira.Messages; | ||
| import hudson.util.ListBoxModel; | ||
| import java.util.List; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.api.Nested; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import org.junit.jupiter.params.provider.NullSource; | ||
| import org.kohsuke.stapler.StaplerRequest2; | ||
| import org.mockito.Mock; | ||
| import org.mockito.junit.jupiter.MockitoExtension; | ||
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| class JiraIssueParameterDefinitionTest { | ||
|
|
||
| private JiraIssueParameterDefinition definition = | ||
| new JiraIssueParameterDefinition("PARAM_NAME", "desc", "jqlQuery"); | ||
|
|
||
| static Stream<Arguments> createValueInvalidParameters() { | ||
| return Stream.of( | ||
| Arguments.of((Object) new String[] {}), | ||
| Arguments.of((Object) new String[] {"a", "b"}), | ||
| Arguments.of((Object) new String[] {""})); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @NullSource | ||
| @MethodSource("createValueInvalidParameters") | ||
| void shouldCreateNullParameterForInvalidValues(String[] values, @Mock StaplerRequest2 req) { | ||
| when(req.getParameterValues(any())).thenReturn(values); | ||
|
|
||
| ParameterValue result = definition.createValue(req); | ||
|
|
||
| assertNull(result); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldCreateValue(@Mock StaplerRequest2 req) { | ||
| when(req.getParameterValues(any())).thenReturn(new String[] {"value"}); | ||
|
|
||
| ParameterValue result = definition.createValue(req); | ||
|
|
||
| assertNotNull(result); | ||
| assertEquals("PARAM_NAME", result.getName()); | ||
| assertEquals("value", result.getValue()); | ||
| } | ||
|
|
||
| @Nested | ||
| class DescriptorImplTest { | ||
|
|
||
| private JiraIssueParameterDefinition.DescriptorImpl uut = new JiraIssueParameterDefinition.DescriptorImpl(); | ||
|
|
||
| @Test | ||
| void shouldFillValueItems( | ||
| @Mock Job<?, ?> job, | ||
| @Mock ParametersDefinitionProperty propertyDef, | ||
| @Mock JiraIssueParameterDefinition paramDef, | ||
| @Mock Issue issue) { | ||
| when(job.hasPermission(Item.BUILD)).thenReturn(true); | ||
| when(job.getProperty(ParametersDefinitionProperty.class)).thenReturn(propertyDef); | ||
| when(propertyDef.getParameterDefinition("PARAM_NAME")).thenReturn(paramDef); | ||
| when(issue.getKey()).thenReturn("JIRA-1234"); | ||
| when(issue.getSummary()).thenReturn("Summary"); | ||
| JiraIssueParameterDefinition.Result item = new JiraIssueParameterDefinition.Result(issue, null); | ||
| when(paramDef.getIssues(any())).thenReturn(List.of(item)); | ||
|
|
||
| ListBoxModel result = uut.doFillValueItems(job, "PARAM_NAME"); | ||
|
|
||
| assertThat(result, hasSize(1)); | ||
| ListBoxModel.Option option = result.get(0); | ||
| assertEquals("JIRA-1234", option.value); | ||
| assertEquals("JIRA-1234: Summary", option.name); | ||
| verify(job).hasPermission(Item.BUILD); | ||
|
||
| } | ||
|
|
||
| @Test | ||
| void shouldNotFillValueItemsIfPermissionMissing(@Mock Job<?, ?> job) { | ||
| ListBoxModel result = uut.doFillValueItems(job, "PARAM_NAME"); | ||
|
|
||
| assertThat(result, hasSize(1)); | ||
| ListBoxModel.Option option = result.get(0); | ||
| assertEquals("", option.value); | ||
| assertEquals(Messages.JiraIssueParameterDefinition_NoIssueMatchedSearch(), option.name); | ||
| verify(job).hasPermission(Item.BUILD); | ||
|
||
| } | ||
|
|
||
| @Test | ||
| void shouldHaveNoSearchMatchesItemIfSearchMatchesNoItem( | ||
| @Mock Job<?, ?> job, | ||
| @Mock ParametersDefinitionProperty propertyDef, | ||
| @Mock JiraIssueParameterDefinition paramDef, | ||
| @Mock Issue issue) { | ||
| when(job.hasPermission(Item.BUILD)).thenReturn(true); | ||
| when(job.getProperty(ParametersDefinitionProperty.class)).thenReturn(propertyDef); | ||
| when(propertyDef.getParameterDefinition("PARAM_NAME")).thenReturn(paramDef); | ||
|
|
||
| ListBoxModel result = uut.doFillValueItems(job, "PARAM_NAME"); | ||
|
|
||
| assertThat(result, hasSize(1)); | ||
| ListBoxModel.Option option = result.get(0); | ||
| assertEquals("", option.value); | ||
| assertEquals(Messages.JiraIssueParameterDefinition_NoIssueMatchedSearch(), option.name); | ||
| verify(job).hasPermission(Item.BUILD); | ||
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.