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
1cc1efd4
Commit
1cc1efd4
authored
Aug 24, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the UI updates when the name is already taken
parent
f3ae8d53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
10 deletions
+66
-10
ee/spec/frontend/approvals/components/rule_form_spec.js
ee/spec/frontend/approvals/components/rule_form_spec.js
+66
-10
No files found.
ee/spec/frontend/approvals/components/rule_form_spec.js
View file @
1cc1efd4
...
...
@@ -28,6 +28,15 @@ const TEST_FALLBACK_RULE = {
isFallback
:
true
,
};
const
TEST_LOCKED_RULE_NAME
=
'
LOCKED_RULE
'
;
const
nameTakenError
=
{
response
:
{
data
:
{
message
:
{
name
:
[
'
has already been taken
'
],
},
},
},
};
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
...
...
@@ -242,7 +251,7 @@ describe('EE Approvals RuleForm', () => {
.
catch
(
done
.
fail
);
});
it
(
'
on submit with data, posts rule
'
,
()
=>
{
describe
(
'
with valid data
'
,
()
=>
{
const
users
=
[
1
,
2
];
const
groups
=
[
2
,
3
];
const
userRecords
=
users
.
map
(
id
=>
({
id
,
type
:
TYPE_USER
}));
...
...
@@ -260,14 +269,35 @@ describe('EE Approvals RuleForm', () => {
protectedBranchIds
:
branches
,
};
findNameInput
().
setValue
(
expected
.
name
);
findApprovalsRequiredInput
().
setValue
(
expected
.
approvalsRequired
);
wrapper
.
vm
.
approvers
=
groupRecords
.
concat
(
userRecords
);
wrapper
.
vm
.
branches
=
expected
.
protectedBranchIds
;
beforeEach
(()
=>
{
findNameInput
().
setValue
(
expected
.
name
);
findApprovalsRequiredInput
().
setValue
(
expected
.
approvalsRequired
);
wrapper
.
vm
.
approvers
=
groupRecords
.
concat
(
userRecords
);
wrapper
.
vm
.
branches
=
expected
.
protectedBranchIds
;
});
wrapper
.
vm
.
submit
();
it
(
'
on submit, posts rule
'
,
()
=>
{
wrapper
.
vm
.
submit
();
expect
(
actions
.
postRule
).
toHaveBeenCalledWith
(
expect
.
anything
(),
expected
,
undefined
);
});
it
(
'
when submitted with a duplicate name, shows the "taken name" validation
'
,
async
()
=>
{
store
.
state
.
settings
.
prefix
=
'
project-settings
'
;
jest
.
spyOn
(
wrapper
.
vm
,
'
postRule
'
).
mockRejectedValueOnce
(
nameTakenError
);
expect
(
actions
.
postRule
).
toHaveBeenCalledWith
(
expect
.
anything
(),
expected
,
undefined
);
wrapper
.
vm
.
submit
();
await
wrapper
.
vm
.
$nextTick
();
// We have to wait for two ticks because the promise needs to resolve
// AND the result has to update into the UI
await
wrapper
.
vm
.
$nextTick
();
expect
(
findNameValidation
()).
toEqual
({
isValid
:
false
,
feedback
:
'
Rule name is already taken.
'
,
});
});
});
it
(
'
adds selected approvers on selection
'
,
()
=>
{
...
...
@@ -302,7 +332,7 @@ describe('EE Approvals RuleForm', () => {
]);
});
it
(
'
on submit, puts rule
'
,
()
=>
{
describe
(
'
with valid data
'
,
()
=>
{
const
userRecords
=
TEST_RULE
.
users
.
map
(
x
=>
({
...
x
,
type
:
TYPE_USER
}));
const
groupRecords
=
TEST_RULE
.
groups
.
map
(
x
=>
({
...
x
,
type
:
TYPE_GROUP
}));
const
users
=
userRecords
.
map
(
x
=>
x
.
id
);
...
...
@@ -318,9 +348,35 @@ describe('EE Approvals RuleForm', () => {
protectedBranchIds
:
[],
};
wrapper
.
vm
.
submit
();
beforeEach
(()
=>
{
findNameInput
().
setValue
(
expected
.
name
);
findApprovalsRequiredInput
().
setValue
(
expected
.
approvalsRequired
);
wrapper
.
vm
.
approvers
=
groupRecords
.
concat
(
userRecords
);
wrapper
.
vm
.
branches
=
expected
.
protectedBranchIds
;
});
it
(
'
on submit, puts rule
'
,
()
=>
{
wrapper
.
vm
.
submit
();
expect
(
actions
.
putRule
).
toHaveBeenCalledWith
(
expect
.
anything
(),
expected
,
undefined
);
});
expect
(
actions
.
putRule
).
toHaveBeenCalledWith
(
expect
.
anything
(),
expected
,
undefined
);
it
(
'
when submitted with a duplicate name, shows the "taken name" validation
'
,
async
()
=>
{
store
.
state
.
settings
.
prefix
=
'
project-settings
'
;
jest
.
spyOn
(
wrapper
.
vm
,
'
putRule
'
).
mockRejectedValueOnce
(
nameTakenError
);
wrapper
.
vm
.
submit
();
await
wrapper
.
vm
.
$nextTick
();
// We have to wait for two ticks because the promise needs to resolve
// AND the result has to update into the UI
await
wrapper
.
vm
.
$nextTick
();
expect
(
findNameValidation
()).
toEqual
({
isValid
:
false
,
feedback
:
'
Rule name is already taken.
'
,
});
});
});
});
...
...
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