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
dd066c10
Commit
dd066c10
authored
Sep 03, 2020
by
Thomas Randolph
Committed by
Himanshu Kapoor
Sep 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the diffs app showing collapsed files warning
parent
ea942625
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
16 deletions
+138
-16
spec/frontend/diffs/components/app_spec.js
spec/frontend/diffs/components/app_spec.js
+48
-16
spec/frontend/diffs/components/collapsed_files_warning_spec.js
...frontend/diffs/components/collapsed_files_warning_spec.js
+90
-0
No files found.
spec/frontend/diffs/components/app_spec.js
View file @
dd066c10
...
...
@@ -9,6 +9,7 @@ import NoChanges from '~/diffs/components/no_changes.vue';
import
DiffFile
from
'
~/diffs/components/diff_file.vue
'
;
import
CompareVersions
from
'
~/diffs/components/compare_versions.vue
'
;
import
HiddenFilesWarning
from
'
~/diffs/components/hidden_files_warning.vue
'
;
import
CollapsedFilesWarning
from
'
~/diffs/components/collapsed_files_warning.vue
'
;
import
CommitWidget
from
'
~/diffs/components/commit_widget.vue
'
;
import
TreeList
from
'
~/diffs/components/tree_list.vue
'
;
import
{
INLINE_DIFF_VIEW_TYPE
,
PARALLEL_DIFF_VIEW_TYPE
}
from
'
~/diffs/constants
'
;
...
...
@@ -22,6 +23,10 @@ const TEST_ENDPOINT = `${TEST_HOST}/diff/endpoint`;
const
COMMIT_URL
=
'
[BASE URL]/OLD
'
;
const
UPDATED_COMMIT_URL
=
'
[BASE URL]/NEW
'
;
function
getCollapsedFilesWarning
(
wrapper
)
{
return
wrapper
.
find
(
CollapsedFilesWarning
);
}
describe
(
'
diffs/components/app
'
,
()
=>
{
const
oldMrTabs
=
window
.
mrTabs
;
let
store
;
...
...
@@ -668,24 +673,51 @@ describe('diffs/components/app', () => {
);
});
it
(
'
should render hidden files warning if render overflow warning is present
'
,
()
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
renderOverflowWarning
=
true
;
state
.
diffs
.
realSize
=
'
5
'
;
state
.
diffs
.
plainDiffPath
=
'
plain diff path
'
;
state
.
diffs
.
emailPatchPath
=
'
email patch path
'
;
state
.
diffs
.
size
=
1
;
describe
(
'
warnings
'
,
()
=>
{
describe
(
'
hidden files
'
,
()
=>
{
it
(
'
should render hidden files warning if render overflow warning is present
'
,
()
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
renderOverflowWarning
=
true
;
state
.
diffs
.
realSize
=
'
5
'
;
state
.
diffs
.
plainDiffPath
=
'
plain diff path
'
;
state
.
diffs
.
emailPatchPath
=
'
email patch path
'
;
state
.
diffs
.
size
=
1
;
});
expect
(
wrapper
.
find
(
HiddenFilesWarning
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
HiddenFilesWarning
).
props
()).
toEqual
(
expect
.
objectContaining
({
total
:
'
5
'
,
plainDiffPath
:
'
plain diff path
'
,
emailPatchPath
:
'
email patch path
'
,
visible
:
1
,
}),
);
});
});
expect
(
wrapper
.
find
(
HiddenFilesWarning
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
HiddenFilesWarning
).
props
()).
toEqual
(
expect
.
objectContaining
({
total
:
'
5
'
,
plainDiffPath
:
'
plain diff path
'
,
emailPatchPath
:
'
email patch path
'
,
visible
:
1
,
}),
);
describe
(
'
collapsed files
'
,
()
=>
{
it
(
'
should render the collapsed files warning if there are any collapsed files
'
,
()
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
diffFiles
=
[{
viewer
:
{
collapsed
:
true
}
}];
});
expect
(
getCollapsedFilesWarning
(
wrapper
).
exists
()).
toBe
(
true
);
});
it
(
'
should not render the collapsed files warning if the user has dismissed the alert already
'
,
async
()
=>
{
createComponent
({},
({
state
})
=>
{
state
.
diffs
.
diffFiles
=
[{
viewer
:
{
collapsed
:
true
}
}];
});
expect
(
getCollapsedFilesWarning
(
wrapper
).
exists
()).
toBe
(
true
);
wrapper
.
vm
.
collapsedWarningDismissed
=
true
;
await
wrapper
.
vm
.
$nextTick
();
expect
(
getCollapsedFilesWarning
(
wrapper
).
exists
()).
toBe
(
false
);
});
});
});
it
(
'
should display commit widget if store has a commit
'
,
()
=>
{
...
...
spec/frontend/diffs/components/collapsed_files_warning_spec.js
0 → 100644
View file @
dd066c10
import
Vuex
from
'
vuex
'
;
import
{
shallowMount
,
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
createStore
from
'
~/diffs/store/modules
'
;
import
CollapsedFilesWarning
from
'
~/diffs/components/collapsed_files_warning.vue
'
;
import
{
CENTERED_LIMITED_CONTAINER_CLASSES
}
from
'
~/diffs/constants
'
;
const
propsData
=
{
limited
:
true
,
mergeable
:
true
,
resolutionPath
:
'
a-path
'
,
};
const
limitedClasses
=
CENTERED_LIMITED_CONTAINER_CLASSES
.
split
(
'
'
);
function
getAlertActionButton
(
wrapper
)
{
return
wrapper
.
find
(
'
.gl-alert-actions button.gl-alert-action:first-child
'
).
element
;
}
function
getAlertCloseButton
(
wrapper
)
{
return
wrapper
.
find
(
'
[data-testid="close-icon"]
'
).
element
.
parentNode
;
}
describe
(
'
CollapsedFilesWarning
'
,
()
=>
{
const
localVue
=
createLocalVue
();
let
store
;
let
wrapper
;
localVue
.
use
(
Vuex
);
const
createComponent
=
(
props
=
{},
{
full
}
=
{
full
:
false
})
=>
{
const
mounter
=
full
?
mount
:
shallowMount
;
store
=
new
Vuex
.
Store
({
modules
:
{
diffs
:
createStore
(),
},
});
wrapper
=
mounter
(
CollapsedFilesWarning
,
{
propsData
:
{
...
propsData
,
...
props
},
localVue
,
store
,
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
.
each
`
limited | containerClasses
${
true
}
|
${
limitedClasses
}
${
false
}
|
${[]}
`
(
'
has the correct container classes when limited is $limited
'
,
({
limited
,
containerClasses
})
=>
{
createComponent
({
limited
});
expect
(
wrapper
.
classes
()).
toEqual
(
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
'
,
()
=>
{
createComponent
({},
{
full
:
true
});
expect
(
wrapper
.
vm
.
isDismissed
).
toBe
(
false
);
getAlertCloseButton
(
wrapper
).
click
();
expect
(
wrapper
.
vm
.
isDismissed
).
toBe
(
true
);
});
it
(
'
triggers the expandAllFiles action when the alert action button is clicked
'
,
()
=>
{
createComponent
({},
{
full
:
true
});
jest
.
spyOn
(
wrapper
.
vm
.
$store
,
'
dispatch
'
).
mockReturnValue
(
undefined
);
getAlertActionButton
(
wrapper
).
click
();
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
'
diffs/expandAllFiles
'
,
undefined
);
});
});
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