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
29e0f3bc
Commit
29e0f3bc
authored
Apr 13, 2020
by
Jackie Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply review feedback
parent
89d11eb6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
98 deletions
+56
-98
ee/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_container_spec.js
...mr_widget/components/mr_widget_pipeline_container_spec.js
+9
-11
ee/spec/frontend/vue_mr_widget/ee_mr_widget_options_spec.js
ee/spec/frontend/vue_mr_widget/ee_mr_widget_options_spec.js
+47
-87
No files found.
ee/spec/frontend/vue_mr_widget/components/mr_widget_pipeline_container_spec.js
View file @
29e0f3bc
import
{
mount
,
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
MergeTrainPositionIndicator
from
'
ee/vue_merge_request_widget/components/merge_train_position_indicator.vue
'
;
import
VisualReviewAppLink
from
'
ee/vue_merge_request_widget/components/visual_review_app_link.vue
'
;
import
{
mockStore
}
from
'
jest/vue_mr_widget/mock_data
'
;
...
...
@@ -11,23 +11,27 @@ describe('MrWidgetPipelineContainer', () => {
let
wrapper
;
let
mock
;
const
factory
=
(
method
=
shallowMount
,
mrUpdates
=
{},
provide
=
{})
=>
{
const
localVue
=
createLocalVue
();
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
().
reply
(
200
,
{});
});
wrapper
=
method
.
call
(
this
,
localVue
.
extend
(
MrWidgetPipelineContainer
),
{
const
factory
=
(
method
=
shallowMount
,
mrUpdates
=
{},
provide
=
{})
=>
{
wrapper
=
method
.
call
(
this
,
MrWidgetPipelineContainer
,
{
propsData
:
{
mr
:
Object
.
assign
({},
mockStore
,
mrUpdates
),
},
provide
:
{
...
provide
,
},
localVue
,
attachToDocument
:
true
,
});
};
afterEach
(()
=>
{
mock
.
restore
();
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
(
'
merge train indicator
'
,
()
=>
{
...
...
@@ -61,9 +65,6 @@ describe('MrWidgetPipelineContainer', () => {
describe
(
'
with anonymous visual review feedback feature flag enabled
'
,
()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
().
reply
(
200
,
{});
factory
(
mount
,
{
...
...
@@ -101,9 +102,6 @@ describe('MrWidgetPipelineContainer', () => {
describe
(
'
with anonymous visual review feedback feature flag disabled
'
,
()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
().
reply
(
200
,
{});
factory
(
mount
,
{
...
...
ee/spec/frontend/vue_mr_widget/ee_mr_widget_options_spec.js
View file @
29e0f3bc
...
...
@@ -6,6 +6,7 @@ import filterByKey from 'ee/vue_shared/security_reports/store/utils/filter_by_ke
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
mockData
,
{
baseIssues
,
...
...
@@ -39,13 +40,6 @@ describe('ee merge request widget options', () => {
let
mock
;
let
Component
;
function
removeBreakLine
(
data
)
{
return
data
.
replace
(
/
\r?\n
|
\r
/g
,
''
)
.
replace
(
/
\s\s
+/g
,
'
'
)
.
trim
();
}
beforeEach
(()
=>
{
delete
mrWidgetOptions
.
extends
.
el
;
// Prevent component mounting
...
...
@@ -114,7 +108,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
SAST_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -136,7 +130,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
SAST_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -157,9 +151,9 @@ describe('ee merge request widget options', () => {
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
findSecurityWidget
().
querySelector
(
SAST_SELECTOR
).
textContent
)
,
)
.
toContain
(
'
SAST: Loading resulted in an error
'
)
;
expect
(
trimText
(
findSecurityWidget
().
querySelector
(
SAST_SELECTOR
).
textContent
)).
toContain
(
'
SAST: Loading resulted in an error
'
,
);
done
();
});
});
...
...
@@ -188,9 +182,7 @@ describe('ee merge request widget options', () => {
vm
=
mountComponent
(
Component
,
{
mrData
:
gl
.
mrWidgetData
});
expect
(
removeBreakLine
(
findSecurityWidget
().
querySelector
(
DEPENDENCY_SCANNING_SELECTOR
).
textContent
,
),
trimText
(
findSecurityWidget
().
querySelector
(
DEPENDENCY_SCANNING_SELECTOR
).
textContent
),
).
toContain
(
'
Dependency scanning is loading
'
);
});
});
...
...
@@ -206,7 +198,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
DEPENDENCY_SCANNING_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -232,7 +224,7 @@ describe('ee merge request widget options', () => {
it
(
'
renders no new vulnerabilities message
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
DEPENDENCY_SCANNING_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -254,7 +246,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
DEPENDENCY_SCANNING_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -275,9 +267,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
findSecurityWidget
().
querySelector
(
DEPENDENCY_SCANNING_SELECTOR
).
textContent
,
),
trimText
(
findSecurityWidget
().
querySelector
(
DEPENDENCY_SCANNING_SELECTOR
).
textContent
),
).
toContain
(
'
Dependency scanning: Loading resulted in an error
'
);
done
();
});
...
...
@@ -305,9 +295,9 @@ describe('ee merge request widget options', () => {
};
vm
.
$nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget
'
).
textContent
)
,
)
.
toContain
(
'
Loading codeclimate report
'
)
;
expect
(
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget
'
).
textContent
)).
toContain
(
'
Loading codeclimate report
'
,
);
done
();
});
...
...
@@ -328,20 +318,16 @@ describe('ee merge request widget options', () => {
vm
.
mr
.
codeclimate
=
gl
.
mrWidgetData
.
codeclimate
;
// mock worker response
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
).
mockImplementation
(()
=>
Promise
.
resolve
({
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
).
mockResolvedValue
({
newIssues
:
filterByKey
(
parsedHeadIssues
,
parsedBaseIssues
,
'
fingerprint
'
),
resolvedIssues
:
filterByKey
(
parsedBaseIssues
,
parsedHeadIssues
,
'
fingerprint
'
),
}),
);
});
});
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Code quality improved on 1 point and degraded on 1 point
'
);
done
();
});
...
...
@@ -354,9 +340,7 @@ describe('ee merge request widget options', () => {
Vue
.
nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Code quality improved on 1 point
'
);
done
();
});
...
...
@@ -368,9 +352,7 @@ describe('ee merge request widget options', () => {
vm
.
mr
.
codeclimateMetrics
.
resolvedIssues
=
[];
Vue
.
nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Code quality degraded on 1 point
'
);
done
();
});
...
...
@@ -392,12 +374,10 @@ describe('ee merge request widget options', () => {
vm
.
mr
.
codeclimate
=
gl
.
mrWidgetData
.
codeclimate
;
// mock worker response
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
).
mockImplementation
(()
=>
Promise
.
resolve
({
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
).
mockResolvedValue
({
newIssues
:
filterByKey
([],
[],
'
fingerprint
'
),
resolvedIssues
:
filterByKey
([],
[],
'
fingerprint
'
),
}),
);
});
});
afterEach
(()
=>
{
...
...
@@ -407,9 +387,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
No changes to code quality
'
);
done
();
});
...
...
@@ -430,9 +408,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toContain
(
'
Failed to load codeclimate report
'
);
done
();
});
...
...
@@ -460,17 +436,13 @@ describe('ee merge request widget options', () => {
vm
.
mr
.
codeclimate
=
gl
.
mrWidgetData
.
codeclimate
;
// mock worker rejection
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
)
.
mockImplementation
(()
=>
Promise
.
reject
());
jest
.
spyOn
(
MRWidgetStore
,
'
doCodeClimateComparison
'
).
mockRejectedValue
();
});
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Failed to load codeclimate report
'
);
done
();
});
...
...
@@ -493,9 +465,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-codequality-widget .js-code-text
'
).
textContent
),
).
toContain
(
'
Failed to load codeclimate report
'
);
done
();
});
...
...
@@ -523,9 +493,9 @@ describe('ee merge request widget options', () => {
};
vm
.
$nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget
'
).
textContent
)
,
)
.
toContain
(
'
Loading performance report
'
)
;
expect
(
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget
'
).
textContent
)).
toContain
(
'
Loading performance report
'
,
);
done
();
});
...
...
@@ -548,9 +518,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Performance metrics improved on 2 points and degraded on 1 point
'
);
done
();
});
...
...
@@ -563,9 +531,7 @@ describe('ee merge request widget options', () => {
Vue
.
nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Performance metrics improved on 2 points
'
);
done
();
});
...
...
@@ -578,9 +544,7 @@ describe('ee merge request widget options', () => {
Vue
.
nextTick
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
Performance metrics degraded on 1 point
'
);
done
();
});
...
...
@@ -607,7 +571,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
).
toEqual
(
'
No changes to performance metrics
'
);
});
...
...
@@ -640,9 +604,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render error indicator
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
,
),
trimText
(
vm
.
$el
.
querySelector
(
'
.js-performance-widget .js-code-text
'
).
textContent
),
).
toContain
(
'
Failed to load performance report
'
);
done
();
});
...
...
@@ -672,9 +634,7 @@ describe('ee merge request widget options', () => {
vm
=
mountComponent
(
Component
,
{
mrData
:
gl
.
mrWidgetData
});
expect
(
removeBreakLine
(
findSecurityWidget
().
querySelector
(
CONTAINER_SCANNING_SELECTOR
).
textContent
,
),
trimText
(
findSecurityWidget
().
querySelector
(
CONTAINER_SCANNING_SELECTOR
).
textContent
),
).
toContain
(
'
Container scanning is loading
'
);
});
});
...
...
@@ -690,7 +650,7 @@ describe('ee merge request widget options', () => {
it
(
'
should render provided data
'
,
done
=>
{
setImmediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
CONTAINER_SCANNING_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
...
...
@@ -818,7 +778,7 @@ describe('ee merge request widget options', () => {
vm
=
mountComponent
(
Component
,
{
mrData
:
gl
.
mrWidgetData
});
expect
(
removeBreakLine
(
findSecurityWidget
().
querySelector
(
SECRET_SCANNING_SELECTOR
).
textContent
),
trimText
(
findSecurityWidget
().
querySelector
(
SECRET_SCANNING_SELECTOR
).
textContent
),
).
toContain
(
'
Secret scanning is loading
'
);
});
});
...
...
@@ -832,16 +792,16 @@ describe('ee merge request widget options', () => {
});
it
(
'
should render provided data
'
,
done
=>
{
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
removeBreakLine
(
trimText
(
findSecurityWidget
().
querySelector
(
`
${
SECRET_SCANNING_SELECTOR
}
.report-block-list-issue-description`
,
).
textContent
,
),
).
toEqual
(
'
Secret scanning detected 2 new, and 1 fixed vulnerabilities
'
);
done
();
}
,
0
);
});
});
});
...
...
@@ -854,14 +814,14 @@ describe('ee merge request widget options', () => {
});
it
(
'
should render error indicator
'
,
done
=>
{
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
findSecurityWidget
()
.
querySelector
(
SECRET_SCANNING_SELECTOR
)
.
textContent
.
trim
(),
).
toContain
(
'
Secret scanning: Loading resulted in an error
'
);
done
();
}
,
0
);
});
});
});
});
...
...
@@ -1173,7 +1133,7 @@ describe('ee merge request widget options', () => {
},
});
expect
(
vm
.
service
).
to
Equal
(
expect
.
objectContaining
(
convertObjectPropsToCamelCase
(
paths
)
));
expect
(
vm
.
service
).
to
MatchObject
(
convertObjectPropsToCamelCase
(
paths
));
});
});
...
...
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