Commit 59fc740e authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/fixTreeListShowingIncorrectly' into 'master'

Fixes diffs tree list showing incorrectly

See merge request gitlab-org/gitlab!48775
parents e10c3757 65c81fd1
...@@ -429,7 +429,7 @@ export default { ...@@ -429,7 +429,7 @@ export default {
let showTreeList = true; let showTreeList = true;
if (storedTreeShow !== null) { if (storedTreeShow !== null) {
showTreeList = Boolean(storedTreeShow); showTreeList = parseBoolean(storedTreeShow);
} else if (!bp.isDesktop() || (!this.isBatchLoading && this.diffFiles.length <= 1)) { } else if (!bp.isDesktop() || (!this.isBatchLoading && this.diffFiles.length <= 1)) {
showTreeList = false; showTreeList = false;
} }
......
...@@ -678,8 +678,12 @@ describe('diffs/components/app', () => { ...@@ -678,8 +678,12 @@ describe('diffs/components/app', () => {
expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false }); expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false });
}); });
it('calls setShowTreeList with localstorage value', () => { it.each`
localStorage.setItem('mr_tree_show', 'true'); showTreeList
${true}
${false}
`('calls setShowTreeList with localstorage $showTreeList', ({ showTreeList }) => {
localStorage.setItem('mr_tree_show', showTreeList);
createComponent({}, ({ state }) => { createComponent({}, ({ state }) => {
state.diffs.diffFiles.push({ sha: '123' }); state.diffs.diffFiles.push({ sha: '123' });
...@@ -691,7 +695,7 @@ describe('diffs/components/app', () => { ...@@ -691,7 +695,7 @@ describe('diffs/components/app', () => {
wrapper.vm.setTreeDisplay(); wrapper.vm.setTreeDisplay();
expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false }); expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList, saving: false });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment