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
b96db550
Commit
b96db550
authored
Mar 31, 2021
by
pburdette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more coverage
Add a bit more test coverage to ensure the button is tested properly.
parent
87ae36b1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
59 deletions
+94
-59
changelogs/unreleased/pb-disable-trigger-manual-action.yml
changelogs/unreleased/pb-disable-trigger-manual-action.yml
+5
-0
spec/frontend/jobs/components/manual_variables_form_spec.js
spec/frontend/jobs/components/manual_variables_form_spec.js
+89
-59
No files found.
changelogs/unreleased/pb-disable-trigger-manual-action.yml
0 → 100644
View file @
b96db550
---
title
:
Disable trigger manual job button after click
merge_request
:
57885
author
:
type
:
fixed
spec/frontend/jobs/components/manual_variables_form_spec.js
View file @
b96db550
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Form
from
'
~/jobs/components/manual_variables_form.vue
'
;
import
Form
from
'
~/jobs/components/manual_variables_form.vue
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
Vue
.
use
(
Vuex
);
describe
(
'
Manual Variables Form
'
,
()
=>
{
describe
(
'
Manual Variables Form
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
store
;
const
requiredProps
=
{
const
requiredProps
=
{
action
:
{
action
:
{
...
@@ -16,19 +21,22 @@ describe('Manual Variables Form', () => {
...
@@ -16,19 +21,22 @@ describe('Manual Variables Form', () => {
variablesSettingsUrl
:
'
/settings
'
,
variablesSettingsUrl
:
'
/settings
'
,
};
};
const
factory
=
(
props
=
{})
=>
{
const
createComponent
=
(
props
=
{},
mountFn
=
shallowMount
)
=>
{
wrapper
=
shallowMount
(
localVue
.
extend
(
Form
),
{
store
=
new
Vuex
.
Store
({
actions
:
{
triggerManualJob
:
jest
.
fn
(),
},
});
wrapper
=
mountFn
(
localVue
.
extend
(
Form
),
{
propsData
:
props
,
propsData
:
props
,
localVue
,
localVue
,
store
,
});
});
};
};
const
findTriggerBtn
=
()
=>
wrapper
.
find
(
'
[data-testid="trigger-manual-job-btn"]
'
);
const
findTriggerBtn
=
()
=>
wrapper
.
find
(
'
[data-testid="trigger-manual-job-btn"]
'
);
beforeEach
(()
=>
{
factory
(
requiredProps
);
});
afterEach
((
done
)
=>
{
afterEach
((
done
)
=>
{
// The component has a `nextTick` callback after some events so we need
// The component has a `nextTick` callback after some events so we need
// to wait for those to finish before destroying.
// to wait for those to finish before destroying.
...
@@ -40,8 +48,15 @@ describe('Manual Variables Form', () => {
...
@@ -40,8 +48,15 @@ describe('Manual Variables Form', () => {
});
});
});
});
describe
(
'
shallowMount
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
requiredProps
);
});
it
(
'
renders empty form with correct placeholders
'
,
()
=>
{
it
(
'
renders empty form with correct placeholders
'
,
()
=>
{
expect
(
wrapper
.
find
({
ref
:
'
inputKey
'
}).
attributes
(
'
placeholder
'
)).
toBe
(
'
Input variable key
'
);
expect
(
wrapper
.
find
({
ref
:
'
inputKey
'
}).
attributes
(
'
placeholder
'
)).
toBe
(
'
Input variable key
'
,
);
expect
(
wrapper
.
find
({
ref
:
'
inputSecretValue
'
}).
attributes
(
'
placeholder
'
)).
toBe
(
expect
(
wrapper
.
find
({
ref
:
'
inputSecretValue
'
}).
attributes
(
'
placeholder
'
)).
toBe
(
'
Input variable value
'
,
'
Input variable value
'
,
);
);
...
@@ -55,10 +70,6 @@ describe('Manual Variables Form', () => {
...
@@ -55,10 +70,6 @@ describe('Manual Variables Form', () => {
expect
(
wrapper
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toBe
(
requiredProps
.
variablesSettingsUrl
);
expect
(
wrapper
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toBe
(
requiredProps
.
variablesSettingsUrl
);
});
});
it
(
'
trigger button is not disabled on mount
'
,
()
=>
{
expect
(
findTriggerBtn
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
describe
(
'
when adding a new variable
'
,
()
=>
{
describe
(
'
when adding a new variable
'
,
()
=>
{
it
(
'
creates a new variable when user types a new key and resets the form
'
,
(
done
)
=>
{
it
(
'
creates a new variable when user types a new key and resets the form
'
,
(
done
)
=>
{
wrapper
.
vm
wrapper
.
vm
...
@@ -106,4 +117,23 @@ describe('Manual Variables Form', () => {
...
@@ -106,4 +117,23 @@ describe('Manual Variables Form', () => {
expect
(
wrapper
.
vm
.
variables
.
length
).
toBe
(
0
);
expect
(
wrapper
.
vm
.
variables
.
length
).
toBe
(
0
);
});
});
});
});
});
describe
(
'
mount
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
requiredProps
,
mount
);
});
it
(
'
trigger button is not disabled on mount
'
,
()
=>
{
expect
(
findTriggerBtn
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
it
(
'
trigger button is disabled after trigger action
'
,
async
()
=>
{
expect
(
findTriggerBtn
().
props
(
'
disabled
'
)).
toBe
(
false
);
await
findTriggerBtn
().
trigger
(
'
click
'
);
expect
(
findTriggerBtn
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
});
});
});
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