Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
469676b5
Commit
469676b5
authored
Feb 10, 2022
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer feedback
- expand test coverage in new branch form spec - fix type
parent
0e18d47c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
11 deletions
+51
-11
app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue
...ipts/jira_connect/branches/components/new_branch_form.vue
+9
-2
spec/features/jira_connect/branches_spec.rb
spec/features/jira_connect/branches_spec.rb
+1
-1
spec/frontend/jira_connect/branches/components/new_branch_form_spec.js
.../jira_connect/branches/components/new_branch_form_spec.js
+41
-8
No files found.
app/assets/javascripts/jira_connect/branches/components/new_branch_form.vue
View file @
469676b5
...
...
@@ -36,7 +36,11 @@ export default {
ProjectDropdown
,
SourceBranchDropdown
,
},
inject
:
[
'
initialBranchName
'
],
inject
:
{
initialBranchName
:
{
default
:
''
,
},
},
data
()
{
return
{
selectedProject
:
null
,
...
...
@@ -56,8 +60,11 @@ export default {
showAlert
()
{
return
Boolean
(
this
.
alertParams
?.
message
);
},
isBranchNameValid
()
{
return
(
this
.
branchName
??
''
).
trim
().
length
>
0
;
},
disableSubmitButton
()
{
return
!
(
this
.
selectedProject
&&
this
.
selectedSourceBranchName
&&
this
.
branchName
);
return
!
(
this
.
selectedProject
&&
this
.
selectedSourceBranchName
&&
this
.
isBranchNameValid
);
},
},
methods
:
{
...
...
spec/features/jira_connect/branches_spec.rb
View file @
469676b5
...
...
@@ -26,7 +26,7 @@ RSpec.describe 'Create GitLab branches from Jira', :js do
visit
new_jira_connect_branch_path
(
issue_key:
'ACME-123'
,
issue_summary:
'My issue !@#$% title'
)
expect
(
page
).
to
have_button
(
'Create branch'
,
disabled:
true
)
# in
ti
ially, branch field should be hidden.
# in
it
ially, branch field should be hidden.
expect
(
page
).
not_to
have_field
(
'Branch name'
)
# Select project1
...
...
spec/frontend/jira_connect/branches/components/new_branch_form_spec.js
View file @
469676b5
...
...
@@ -54,8 +54,8 @@ describe('NewBranchForm', () => {
const
completeForm
=
async
()
=>
{
await
findProjectDropdown
().
vm
.
$emit
(
'
change
'
,
mockProject
);
await
findInput
().
vm
.
$emit
(
'
input
'
,
'
cool-branch-name
'
);
await
findSourceBranchDropdown
().
vm
.
$emit
(
'
change
'
,
'
source-branch
'
);
await
findInput
().
vm
.
$emit
(
'
input
'
,
'
cool-branch-name
'
);
};
function
createMockApolloProvider
({
...
...
@@ -84,23 +84,40 @@ describe('NewBranchForm', () => {
describe
(
'
when selecting items from dropdowns
'
,
()
=>
{
describe
(
'
when no project selected
'
,
()
=>
{
it
(
'
hides source branch selection and branch name input
'
,
()
=>
{
beforeEach
(
()
=>
{
createComponent
();
});
it
(
'
hides source branch selection and branch name input
'
,
()
=>
{
expect
(
findSourceBranchDropdown
().
exists
()).
toBe
(
false
);
expect
(
findInput
().
exists
()).
toBe
(
false
);
});
it
(
'
disables the submit button
'
,
()
=>
{
expect
(
findButton
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
});
describe
(
'
when a valid project is selected
'
,
()
=>
{
it
(
'
sets the `selectedProject` prop for ProjectDropdown and SourceBranchDropdown
'
,
async
()
=>
{
createComponent
();
describe
(
"
when a source branch isn't selected
"
,
()
=>
{
beforeEach
(
async
()
=>
{
createComponent
();
await
findProjectDropdown
().
vm
.
$emit
(
'
change
'
,
mockProject
);
});
const
projectDropdown
=
findProjectDropdown
();
await
projectDropdown
.
vm
.
$emit
(
'
change
'
,
mockProject
);
it
(
'
sets the `selectedProject` prop for ProjectDropdown and SourceBranchDropdown
'
,
()
=>
{
expect
(
findProjectDropdown
().
props
(
'
selectedProject
'
)).
toEqual
(
mockProject
);
expect
(
findSourceBranchDropdown
().
exists
()).
toBe
(
true
);
expect
(
findSourceBranchDropdown
().
props
(
'
selectedProject
'
)).
toEqual
(
mockProject
);
});
it
(
'
disables the submit button
'
,
()
=>
{
expect
(
findButton
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
expect
(
projectDropdown
.
props
(
'
selectedProject
'
)).
toEqual
(
mockProject
);
expect
(
findSourceBranchDropdown
().
props
(
'
selectedProject
'
)).
toEqual
(
mockProject
);
it
(
'
renders branch input field
'
,
()
=>
{
expect
(
findInput
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
when `initialBranchName` is provided
'
,
()
=>
{
...
...
@@ -125,6 +142,22 @@ describe('NewBranchForm', () => {
expect
(
sourceBranchDropdown
.
props
(
'
selectedBranchName
'
)).
toBe
(
mockBranchName
);
});
describe
.
each
`
branchName | submitButtonDisabled
${
undefined
}
|
${
true
}
${
''
}
|
${
true
}
${
'
'
}
|
${
true
}
${
'
test-branch
'
}
|
${
false
}
`
(
'
when branch name is $branchName
'
,
({
branchName
,
submitButtonDisabled
})
=>
{
it
(
`sets submit button 'disabled' prop to
${
submitButtonDisabled
}
`
,
async
()
=>
{
createComponent
();
await
completeForm
();
await
findInput
().
vm
.
$emit
(
'
input
'
,
branchName
);
expect
(
findButton
().
props
(
'
disabled
'
)).
toBe
(
submitButtonDisabled
);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment