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
f7173bf1
Commit
f7173bf1
authored
Jul 05, 2021
by
Thomas Randolph
Committed by
Brandon Labuschagne
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't display the collapsed files warning banner when there is only one file
parent
ef1f30a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
35 deletions
+65
-35
app/assets/javascripts/diffs/components/collapsed_files_warning.vue
.../javascripts/diffs/components/collapsed_files_warning.vue
+6
-1
spec/frontend/diffs/components/collapsed_files_warning_spec.js
...frontend/diffs/components/collapsed_files_warning_spec.js
+59
-34
No files found.
app/assets/javascripts/diffs/components/collapsed_files_warning.vue
View file @
f7173bf1
<
script
>
<
script
>
import
{
GlAlert
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
mapState
}
from
'
vuex
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
,
EVT_EXPAND_ALL_FILES
}
from
'
../constants
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
,
EVT_EXPAND_ALL_FILES
}
from
'
../constants
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
...
@@ -27,11 +28,15 @@ export default {
...
@@ -27,11 +28,15 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapState
(
'
diffs
'
,
[
'
diffFiles
'
]),
containerClasses
()
{
containerClasses
()
{
return
{
return
{
[
CENTERED_LIMITED_CONTAINER_CLASSES
]:
this
.
limited
,
[
CENTERED_LIMITED_CONTAINER_CLASSES
]:
this
.
limited
,
};
};
},
},
shouldDisplay
()
{
return
!
this
.
isDismissed
&&
this
.
diffFiles
.
length
>
1
;
},
},
},
methods
:
{
methods
:
{
...
@@ -48,7 +53,7 @@ export default {
...
@@ -48,7 +53,7 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
v-if=
"
!isDismissed
"
data-testid=
"root"
:class=
"containerClasses"
class=
"col-12"
>
<div
v-if=
"
shouldDisplay
"
data-testid=
"root"
:class=
"containerClasses"
class=
"col-12"
>
<gl-alert
<gl-alert
:dismissible=
"true"
:dismissible=
"true"
:title=
"__('Some changes are not shown')"
:title=
"__('Some changes are not shown')"
...
...
spec/frontend/diffs/components/collapsed_files_warning_spec.js
View file @
f7173bf1
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
CollapsedFilesWarning
from
'
~/diffs/components/collapsed_files_warning.vue
'
;
import
CollapsedFilesWarning
from
'
~/diffs/components/collapsed_files_warning.vue
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
,
EVT_EXPAND_ALL_FILES
}
from
'
~/diffs/constants
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
,
EVT_EXPAND_ALL_FILES
}
from
'
~/diffs/constants
'
;
import
eventHub
from
'
~/diffs/event_hub
'
;
import
eventHub
from
'
~/diffs/event_hub
'
;
import
createStore
from
'
~/diffs/store/modules
'
;
import
createStore
from
'
~/diffs/store/modules
'
;
import
file
from
'
../mock_data/diff_file
'
;
const
propsData
=
{
const
propsData
=
{
limited
:
true
,
limited
:
true
,
mergeable
:
true
,
mergeable
:
true
,
...
@@ -12,6 +15,13 @@ const propsData = {
...
@@ -12,6 +15,13 @@ const propsData = {
};
};
const
limitedClasses
=
CENTERED_LIMITED_CONTAINER_CLASSES
.
split
(
'
'
);
const
limitedClasses
=
CENTERED_LIMITED_CONTAINER_CLASSES
.
split
(
'
'
);
async
function
files
(
store
,
count
)
{
const
copies
=
Array
(
count
).
fill
(
file
);
store
.
state
.
diffs
.
diffFiles
.
push
(...
copies
);
return
nextTick
();
}
describe
(
'
CollapsedFilesWarning
'
,
()
=>
{
describe
(
'
CollapsedFilesWarning
'
,
()
=>
{
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
let
store
;
let
store
;
...
@@ -42,48 +52,63 @@ describe('CollapsedFilesWarning', () => {
...
@@ -42,48 +52,63 @@ describe('CollapsedFilesWarning', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
.
each
`
describe
(
'
when there is more than one file
'
,
()
=>
{
limited | containerClasses
it
.
each
`
${
true
}
|
${
limitedClasses
}
limited | containerClasses
${
false
}
|
${[]}
${
true
}
|
${
limitedClasses
}
`
(
${
false
}
|
${[]}
'
has the correct container classes when limited is $limited
'
,
`
(
({
limited
,
containerClasses
})
=>
{
'
has the correct container classes when limited is $limited
'
,
createComponent
({
limited
});
async
({
limited
,
containerClasses
})
=>
{
createComponent
({
limited
});
expect
(
wrapper
.
classes
()).
toEqual
([
'
col-12
'
].
concat
(
containerClasses
));
await
files
(
store
,
2
);
},
);
expect
(
wrapper
.
classes
()).
toEqual
([
'
col-12
'
].
concat
(
containerClasses
));
},
it
.
each
`
);
present | dismissed
${
false
}
|
${
true
}
${
true
}
|
${
false
}
`
(
'
toggles the alert when dismissed is $dismissed
'
,
({
present
,
dismissed
})
=>
{
createComponent
({
dismissed
});
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
present
);
});
it
(
'
dismisses the component when the alert "x" is clicked
'
,
async
()
=>
{
it
.
each
`
createComponent
({},
{
full
:
true
});
present | dismissed
${
false
}
|
${
true
}
${
true
}
|
${
false
}
`
(
'
toggles the alert when dismissed is $dismissed
'
,
async
({
present
,
dismissed
})
=>
{
createComponent
({
dismissed
});
await
files
(
store
,
2
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
present
);
});
getAlertCloseButton
().
element
.
click
();
it
(
'
dismisses the component when the alert "x" is clicked
'
,
async
()
=>
{
createComponent
({},
{
full
:
true
});
await
files
(
store
,
2
);
await
wrapper
.
vm
.
$nextTick
(
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
false
);
getAlertCloseButton
().
element
.
click
();
});
it
(
`emits the \`
${
EVT_EXPAND_ALL_FILES
}
\` event when the alert action button is clicked`
,
()
=>
{
await
wrapper
.
vm
.
$nextTick
();
createComponent
({},
{
full
:
true
});
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
false
);
});
getAlertActionButton
().
vm
.
$emit
(
'
click
'
);
it
(
`emits the \`
${
EVT_EXPAND_ALL_FILES
}
\` event when the alert action button is clicked`
,
async
()
=>
{
createComponent
({},
{
full
:
true
});
await
files
(
store
,
2
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
EVT_EXPAND_ALL_FILES
);
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
getAlertActionButton
().
vm
.
$emit
(
'
click
'
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
EVT_EXPAND_ALL_FILES
);
});
});
describe
(
'
when there is a single file
'
,
()
=>
{
it
(
'
should not display
'
,
async
()
=>
{
createComponent
();
await
files
(
store
,
1
);
expect
(
wrapper
.
find
(
'
[data-testid="root"]
'
).
exists
()).
toBe
(
false
);
});
});
});
});
});
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