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
f87ba792
Commit
f87ba792
authored
Feb 12, 2021
by
Paul Gascou-Vaillancourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write specs for cancel behavior
parent
a4832983
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
...d/on_demand_scans/components/on_demand_scans_form_spec.js
+30
-5
No files found.
ee/spec/frontend/on_demand_scans/components/on_demand_scans_form_spec.js
View file @
f87ba792
...
...
@@ -22,6 +22,7 @@ const URL_HOST = 'https://localhost/';
const
helpPagePath
=
'
/application_security/dast/index#on-demand-scans
'
;
const
projectPath
=
'
group/project
'
;
const
defaultBranch
=
'
master
'
;
const
profilesLibraryPath
=
'
/security/configuration/dast_profiles
'
;
const
scannerProfilesLibraryPath
=
'
/security/configuration/dast_profiles#scanner-profiles
'
;
const
siteProfilesLibraryPath
=
'
/security/configuration/dast_profiles#site-profiles
'
;
const
newScannerProfilePath
=
'
/security/configuration/dast_profiles/dast_scanner_profile/new
'
;
...
...
@@ -74,6 +75,7 @@ describe('OnDemandScansForm', () => {
const
findProfilesConflictAlert
=
()
=>
findByTestId
(
'
on-demand-scans-profiles-conflict-alert
'
);
const
findSubmitButton
=
()
=>
findByTestId
(
'
on-demand-scan-submit-button
'
);
const
findSaveButton
=
()
=>
findByTestId
(
'
on-demand-scan-save-button
'
);
const
findCancelButton
=
()
=>
findByTestId
(
'
on-demand-scan-cancel-button
'
);
const
setValidFormData
=
()
=>
{
findNameInput
().
vm
.
$emit
(
'
input
'
,
'
My daily scan
'
);
...
...
@@ -137,6 +139,7 @@ describe('OnDemandScansForm', () => {
propsData
:
defaultProps
,
mocks
:
defaultMocks
,
provide
:
{
profilesLibraryPath
,
scannerProfilesLibraryPath
,
siteProfilesLibraryPath
,
newScannerProfilePath
,
...
...
@@ -167,6 +170,12 @@ describe('OnDemandScansForm', () => {
const
mountSubject
=
subjectMounterFactory
(
mount
);
const
mountShallowSubject
=
subjectMounterFactory
();
const
itClearsLocalStorage
=
()
=>
{
it
(
'
clears local storage
'
,
()
=>
{
expect
(
localStorage
.
removeItem
.
mock
.
calls
).
toEqual
([[
LOCAL_STORAGE_KEY
]]);
});
};
afterEach
(()
=>
{
subject
.
destroy
();
subject
=
null
;
...
...
@@ -302,13 +311,18 @@ describe('OnDemandScansForm', () => {
actionFunction
();
});
it
(
'
sets loading state on correct button
'
,
async
()
=>
{
const
[
submitButton
,
saveButton
]
=
[
findSubmitButton
(),
findSaveButton
()];
it
(
'
sets correct button states
'
,
async
()
=>
{
const
[
submitButton
,
saveButton
,
cancelButton
]
=
[
findSubmitButton
(),
findSaveButton
(),
findCancelButton
(),
];
expect
(
submitButton
.
props
(
'
loading
'
)).
toBe
(
submitButtonLoading
);
expect
(
submitButton
.
props
(
'
disabled
'
)).
toBe
(
!
submitButtonLoading
);
expect
(
saveButton
.
props
(
'
loading
'
)).
toBe
(
saveButtonLoading
);
expect
(
saveButton
.
props
(
'
disabled
'
)).
toBe
(
!
saveButtonLoading
);
expect
(
cancelButton
.
props
(
'
disabled
'
)).
toBe
(
true
);
});
it
(
`triggers dastProfileCreateMutation mutation with runAfterCreate set to
${
runAfterCreate
}
`
,
()
=>
{
...
...
@@ -334,9 +348,7 @@ describe('OnDemandScansForm', () => {
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
it
(
'
clears local storage
'
,
()
=>
{
expect
(
localStorage
.
removeItem
.
mock
.
calls
).
toEqual
([[
LOCAL_STORAGE_KEY
]]);
});
itClearsLocalStorage
();
});
describe
(
'
when editing an existing scan
'
,
()
=>
{
...
...
@@ -425,6 +437,19 @@ describe('OnDemandScansForm', () => {
});
});
describe
(
'
cancellation
'
,
()
=>
{
beforeEach
(()
=>
{
mountShallowSubject
();
findCancelButton
().
vm
.
$emit
(
'
click
'
);
});
itClearsLocalStorage
();
it
(
'
redirects to profiles library
'
,
()
=>
{
expect
(
redirectTo
).
toHaveBeenCalledWith
(
profilesLibraryPath
);
});
});
describe
(
'
dastSavedScans feature flag disabled
'
,
()
=>
{
beforeEach
(
async
()
=>
{
mountShallowSubject
({
...
...
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