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
2a7fedaf
Commit
2a7fedaf
authored
Mar 16, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed closeAll & discardAll specs
parent
4d2180d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
136 deletions
+178
-136
ee/app/assets/javascripts/ide/stores/actions.js
ee/app/assets/javascripts/ide/stores/actions.js
+46
-35
spec/javascripts/ide/stores/actions_spec.js
spec/javascripts/ide/stores/actions_spec.js
+132
-101
No files found.
ee/app/assets/javascripts/ide/stores/actions.js
View file @
2a7fedaf
...
...
@@ -10,7 +10,7 @@ export const setInitialData = ({ commit }, data) =>
commit
(
types
.
SET_INITIAL_DATA
,
data
);
export
const
discardAllChanges
=
({
state
,
commit
,
dispatch
})
=>
{
state
.
changedFiles
.
forEach
(
(
file
)
=>
{
state
.
changedFiles
.
forEach
(
file
=>
{
commit
(
types
.
DISCARD_FILE_CHANGES
,
file
.
path
);
if
(
file
.
tempFile
)
{
...
...
@@ -22,7 +22,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => {
};
export
const
closeAllFiles
=
({
state
,
dispatch
})
=>
{
state
.
openFiles
.
forEach
(
file
=>
dispatch
(
'
closeFile
'
,
file
));
state
.
openFiles
.
forEach
(
file
=>
dispatch
(
'
closeFile
'
,
file
.
path
));
};
export
const
setPanelCollapsedStatus
=
({
commit
},
{
side
,
collapsed
})
=>
{
...
...
@@ -40,12 +40,23 @@ export const setResizingStatus = ({ commit }, resizing) => {
export
const
createTempEntry
=
(
{
state
,
commit
,
dispatch
},
{
branchId
,
name
,
type
,
content
=
''
,
base64
=
false
},
)
=>
new
Promise
((
resolve
)
=>
{
)
=>
new
Promise
(
resolve
=>
{
const
worker
=
new
FilesDecoratorWorker
();
const
fullName
=
name
.
slice
(
-
1
)
!==
'
/
'
&&
type
===
'
tree
'
?
`
${
name
}
/`
:
name
;
const
fullName
=
name
.
slice
(
-
1
)
!==
'
/
'
&&
type
===
'
tree
'
?
`
${
name
}
/`
:
name
;
if
(
state
.
entries
[
name
])
{
flash
(
`The name "
${
name
.
split
(
'
/
'
).
pop
()}
" is already taken in this directory.`
,
'
alert
'
,
document
,
null
,
false
,
true
);
flash
(
`The name "
${
name
.
split
(
'
/
'
)
.
pop
()}
" is already taken in this directory.`
,
'
alert
'
,
document
,
null
,
false
,
true
,
);
resolve
();
...
...
@@ -83,7 +94,7 @@ export const createTempEntry = (
});
return
null
;
});
});
export
const
scrollToTab
=
()
=>
{
Vue
.
nextTick
(()
=>
{
...
...
spec/javascripts/ide/stores/actions_spec.js
View file @
2a7fedaf
...
...
@@ -13,10 +13,11 @@ describe('Multi-file store actions', () => {
});
describe
(
'
redirectToUrl
'
,
()
=>
{
it
(
'
calls visitUrl
'
,
(
done
)
=>
{
it
(
'
calls visitUrl
'
,
done
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
store
.
dispatch
(
'
redirectToUrl
'
,
'
test
'
)
store
.
dispatch
(
'
redirectToUrl
'
,
'
test
'
)
.
then
(()
=>
{
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalledWith
(
'
test
'
);
...
...
@@ -27,8 +28,9 @@ describe('Multi-file store actions', () => {
});
describe
(
'
setInitialData
'
,
()
=>
{
it
(
'
commits initial data
'
,
(
done
)
=>
{
store
.
dispatch
(
'
setInitialData
'
,
{
canCommit
:
true
})
it
(
'
commits initial data
'
,
done
=>
{
store
.
dispatch
(
'
setInitialData
'
,
{
canCommit
:
true
})
.
then
(()
=>
{
expect
(
store
.
state
.
canCommit
).
toBeTruthy
();
done
();
...
...
@@ -44,10 +46,12 @@ describe('Multi-file store actions', () => {
store
.
state
.
openFiles
.
push
(
f
);
store
.
state
.
changedFiles
.
push
(
f
);
store
.
state
.
entries
[
f
.
path
]
=
f
;
});
it
(
'
discards changes in file
'
,
(
done
)
=>
{
store
.
dispatch
(
'
discardAllChanges
'
)
it
(
'
discards changes in file
'
,
done
=>
{
store
.
dispatch
(
'
discardAllChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
changed
).
toBeFalsy
();
})
...
...
@@ -55,8 +59,9 @@ describe('Multi-file store actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
removes all files from changedFiles state
'
,
(
done
)
=>
{
store
.
dispatch
(
'
discardAllChanges
'
)
it
(
'
removes all files from changedFiles state
'
,
done
=>
{
store
.
dispatch
(
'
discardAllChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
changedFiles
.
length
).
toBe
(
0
);
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
1
);
...
...
@@ -68,12 +73,15 @@ describe('Multi-file store actions', () => {
describe
(
'
closeAllFiles
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
openFiles
.
push
(
file
(
'
closeAll
'
));
const
f
=
file
(
'
closeAll
'
);
store
.
state
.
openFiles
.
push
(
f
);
store
.
state
.
openFiles
[
0
].
opened
=
true
;
store
.
state
.
entries
[
f
.
path
]
=
f
;
});
it
(
'
closes all open files
'
,
(
done
)
=>
{
store
.
dispatch
(
'
closeAllFiles
'
)
it
(
'
closes all open files
'
,
done
=>
{
store
.
dispatch
(
'
closeAllFiles
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
0
);
...
...
@@ -103,8 +111,9 @@ describe('Multi-file store actions', () => {
});
describe
(
'
tree
'
,
()
=>
{
it
(
'
creates temp tree
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
it
(
'
creates temp tree
'
,
done
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
branchId
:
store
.
state
.
currentBranchId
,
name
:
'
test
'
,
type
:
'
tree
'
,
...
...
@@ -116,10 +125,11 @@ describe('Multi-file store actions', () => {
expect
(
entry
.
type
).
toBe
(
'
tree
'
);
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
creates new folder inside another tree
'
,
(
done
)
=>
{
it
(
'
creates new folder inside another tree
'
,
done
=>
{
const
tree
=
{
type
:
'
tree
'
,
name
:
'
testing
'
,
...
...
@@ -129,7 +139,8 @@ describe('Multi-file store actions', () => {
store
.
state
.
entries
[
tree
.
path
]
=
tree
;
store
.
dispatch
(
'
createTempEntry
'
,
{
store
.
dispatch
(
'
createTempEntry
'
,
{
branchId
:
store
.
state
.
currentBranchId
,
name
:
'
testing/test
'
,
type
:
'
tree
'
,
...
...
@@ -140,10 +151,11 @@ describe('Multi-file store actions', () => {
expect
(
tree
.
tree
[
0
].
type
).
toBe
(
'
tree
'
);
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
does not create new tree if already exists
'
,
(
done
)
=>
{
it
(
'
does not create new tree if already exists
'
,
done
=>
{
const
tree
=
{
type
:
'
tree
'
,
path
:
'
testing
'
,
...
...
@@ -153,7 +165,8 @@ describe('Multi-file store actions', () => {
store
.
state
.
entries
[
tree
.
path
]
=
tree
;
store
.
dispatch
(
'
createTempEntry
'
,
{
store
.
dispatch
(
'
createTempEntry
'
,
{
branchId
:
store
.
state
.
currentBranchId
,
name
:
'
testing
'
,
type
:
'
tree
'
,
...
...
@@ -163,91 +176,109 @@ describe('Multi-file store actions', () => {
expect
(
document
.
querySelector
(
'
.flash-alert
'
)).
not
.
toBeNull
();
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
blob
'
,
()
=>
{
it
(
'
creates temp file
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
it
(
'
creates temp file
'
,
done
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
branchId
:
'
mybranch
'
,
type
:
'
blob
'
,
}).
then
((
f
)
=>
{
})
.
then
(
f
=>
{
expect
(
f
.
tempFile
).
toBeTruthy
();
expect
(
store
.
state
.
trees
[
'
abcproject/mybranch
'
].
tree
.
length
).
toBe
(
1
);
expect
(
store
.
state
.
trees
[
'
abcproject/mybranch
'
].
tree
.
length
).
toBe
(
1
,
);
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
adds tmp file to open files
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
it
(
'
adds tmp file to open files
'
,
done
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
branchId
:
'
mybranch
'
,
type
:
'
blob
'
,
}).
then
((
f
)
=>
{
})
.
then
(
f
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
1
);
expect
(
store
.
state
.
openFiles
[
0
].
name
).
toBe
(
f
.
name
);
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
adds tmp file to changed files
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
it
(
'
adds tmp file to changed files
'
,
done
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
branchId
:
'
mybranch
'
,
type
:
'
blob
'
,
}).
then
((
f
)
=>
{
})
.
then
(
f
=>
{
expect
(
store
.
state
.
changedFiles
.
length
).
toBe
(
1
);
expect
(
store
.
state
.
changedFiles
[
0
].
name
).
toBe
(
f
.
name
);
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
sets tmp file as active
'
,
(
done
)
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
it
(
'
sets tmp file as active
'
,
done
=>
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
branchId
:
'
mybranch
'
,
type
:
'
blob
'
,
}).
then
((
f
)
=>
{
})
.
then
(
f
=>
{
expect
(
f
.
active
).
toBeTruthy
();
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
it
(
'
creates flash message if file already exists
'
,
(
done
)
=>
{
it
(
'
creates flash message if file already exists
'
,
done
=>
{
const
f
=
file
(
'
test
'
,
'
1
'
,
'
blob
'
);
store
.
state
.
trees
[
'
abcproject/mybranch
'
].
tree
=
[
f
];
store
.
state
.
entries
[
f
.
path
]
=
f
;
store
.
dispatch
(
'
createTempEntry
'
,
{
store
.
dispatch
(
'
createTempEntry
'
,
{
name
:
'
test
'
,
branchId
:
'
mybranch
'
,
type
:
'
blob
'
,
}).
then
(()
=>
{
})
.
then
(()
=>
{
expect
(
document
.
querySelector
(
'
.flash-alert
'
)).
not
.
toBeNull
();
done
();
}).
catch
(
done
.
fail
);
})
.
catch
(
done
.
fail
);
});
});
});
describe
(
'
popHistoryState
'
,
()
=>
{
});
describe
(
'
popHistoryState
'
,
()
=>
{});
describe
(
'
scrollToTab
'
,
()
=>
{
it
(
'
focuses the current active element
'
,
(
done
)
=>
{
document
.
body
.
innerHTML
+=
'
<div id="tabs"><div class="active"><div class="repo-tab"></div></div></div>
'
;
it
(
'
focuses the current active element
'
,
done
=>
{
document
.
body
.
innerHTML
+=
'
<div id="tabs"><div class="active"><div class="repo-tab"></div></div></div>
'
;
const
el
=
document
.
querySelector
(
'
.repo-tab
'
);
spyOn
(
el
,
'
focus
'
);
store
.
dispatch
(
'
scrollToTab
'
)
store
.
dispatch
(
'
scrollToTab
'
)
.
then
(()
=>
{
setTimeout
(()
=>
{
expect
(
el
.
focus
).
toHaveBeenCalled
();
...
...
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