BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
38d56a8b
Commit
38d56a8b
authored
Mar 26, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Tests for all new functionality
parent
f0e1ee5f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
355 additions
and
21 deletions
+355
-21
api_spec.js
spec/javascripts/api_spec.js
+0
-0
repo_editor_spec.js
spec/javascripts/ide/components/repo_editor_spec.js
+58
-0
repo_tabs_spec.js
spec/javascripts/ide/components/repo_tabs_spec.js
+1
-0
model_spec.js
spec/javascripts/ide/lib/common/model_spec.js
+12
-2
editor_spec.js
spec/javascripts/ide/lib/editor_spec.js
+25
-0
file_spec.js
spec/javascripts/ide/stores/actions/file_spec.js
+35
-8
merge_request_spec.js
spec/javascripts/ide/stores/actions/merge_request_spec.js
+110
-0
tree_spec.js
spec/javascripts/ide/stores/actions/tree_spec.js
+3
-9
getters_spec.js
spec/javascripts/ide/stores/getters_spec.js
+21
-1
file_spec.js
spec/javascripts/ide/stores/mutations/file_spec.js
+25
-1
merge_request_spec.js
spec/javascripts/ide/stores/mutations/merge_request_spec.js
+65
-0
No files found.
spec/javascripts/api_spec.js
View file @
38d56a8b
This diff is collapsed.
Click to expand it.
spec/javascripts/ide/components/repo_editor_spec.js
View file @
38d56a8b
...
...
@@ -89,6 +89,20 @@ describe('RepoEditor', () => {
done
();
});
});
it
(
'calls createDiffInstance when viewer is a merge request diff'
,
done
=>
{
vm
.
$store
.
state
.
viewer
=
'mrdiff'
;
spyOn
(
vm
.
editor
,
'createDiffInstance'
);
vm
.
createEditorInstance
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
editor
.
createDiffInstance
).
toHaveBeenCalled
();
done
();
});
});
});
describe
(
'setupEditor'
,
()
=>
{
...
...
@@ -134,4 +148,48 @@ describe('RepoEditor', () => {
});
});
});
describe
(
'setup editor for merge request viewing'
,
()
=>
{
beforeEach
(
done
=>
{
vm
.
$destroy
();
resetStore
(
vm
.
$store
);
Editor
.
editorInstance
.
modelManager
.
dispose
();
const
f
=
file
();
const
RepoEditor
=
Vue
.
extend
(
repoEditor
);
vm
=
createComponentWithStore
(
RepoEditor
,
store
,
{
file
:
f
,
});
f
.
active
=
true
;
f
.
tempFile
=
true
;
f
.
html
=
'testing'
;
f
.
mrChange
=
{
diff
:
'ABC'
};
f
.
baseRaw
=
'testing'
;
f
.
content
=
'test'
;
vm
.
$store
.
state
.
openFiles
.
push
(
f
);
vm
.
$store
.
state
.
entries
[
f
.
path
]
=
f
;
vm
.
$store
.
state
.
viewer
=
'mrdiff'
;
vm
.
monaco
=
true
;
vm
.
$mount
();
monacoLoader
([
'vs/editor/editor.main'
],
()
=>
{
setTimeout
(
done
,
0
);
});
});
it
(
'attaches merge request model to editor when merge request diff'
,
()
=>
{
spyOn
(
vm
.
editor
,
'attachMergeRequestModel'
).
and
.
callThrough
();
vm
.
setupEditor
();
expect
(
vm
.
editor
.
attachMergeRequestModel
).
toHaveBeenCalledWith
(
vm
.
model
);
});
});
});
spec/javascripts/ide/components/repo_tabs_spec.js
View file @
38d56a8b
...
...
@@ -57,6 +57,7 @@ describe('RepoTabs', () => {
files
:
[],
viewer
:
'editor'
,
hasChanges
:
false
,
hasMergeRequest
:
false
,
},
'#test-app'
,
);
...
...
spec/javascripts/ide/lib/common/model_spec.js
View file @
38d56a8b
...
...
@@ -11,7 +11,10 @@ describe('Multi-file editor library model', () => {
spyOn
(
eventHub
,
'$on'
).
and
.
callThrough
();
monacoLoader
([
'vs/editor/editor.main'
],
()
=>
{
model
=
new
Model
(
monaco
,
file
(
'path'
));
const
f
=
file
(
'path'
);
f
.
mrChange
=
{
diff
:
'ABC'
};
f
.
baseRaw
=
'test'
;
model
=
new
Model
(
monaco
,
f
);
done
();
});
...
...
@@ -21,9 +24,10 @@ describe('Multi-file editor library model', () => {
model
.
dispose
();
});
it
(
'creates original model & new model'
,
()
=>
{
it
(
'creates original model &
base model &
new model'
,
()
=>
{
expect
(
model
.
originalModel
).
not
.
toBeNull
();
expect
(
model
.
model
).
not
.
toBeNull
();
expect
(
model
.
baseModel
).
not
.
toBeNull
();
});
it
(
'adds eventHub listener'
,
()
=>
{
...
...
@@ -51,6 +55,12 @@ describe('Multi-file editor library model', () => {
});
});
describe
(
'getBaseModel'
,
()
=>
{
it
(
'returns base model'
,
()
=>
{
expect
(
model
.
getBaseModel
()).
toBe
(
model
.
baseModel
);
});
});
describe
(
'setValue'
,
()
=>
{
it
(
'updates models value'
,
()
=>
{
model
.
setValue
(
'testing 123'
);
...
...
spec/javascripts/ide/lib/editor_spec.js
View file @
38d56a8b
...
...
@@ -143,6 +143,31 @@ describe('Multi-file editor library', () => {
});
});
describe
(
'attachMergeRequestModel'
,
()
=>
{
let
model
;
beforeEach
(()
=>
{
instance
.
createDiffInstance
(
document
.
createElement
(
'div'
));
const
f
=
file
();
f
.
mrChanges
=
{
diff
:
'ABC'
};
f
.
baseRaw
=
'testing'
;
model
=
instance
.
createModel
(
f
);
});
it
(
'sets original & modified'
,
()
=>
{
spyOn
(
instance
.
instance
,
'setModel'
);
instance
.
attachMergeRequestModel
(
model
);
expect
(
instance
.
instance
.
setModel
).
toHaveBeenCalledWith
({
original
:
model
.
getBaseModel
(),
modified
:
model
.
getModel
(),
});
});
});
describe
(
'clearEditor'
,
()
=>
{
it
(
'resets the editor model'
,
()
=>
{
instance
.
createInstance
(
document
.
createElement
(
'div'
));
...
...
spec/javascripts/ide/stores/actions/file_spec.js
View file @
38d56a8b
...
...
@@ -5,7 +5,7 @@ import router from '~/ide/ide_router';
import
eventHub
from
'~/ide/eventhub'
;
import
{
file
,
resetStore
}
from
'../../helpers'
;
describe
(
'
Multi-file
store file actions'
,
()
=>
{
describe
(
'
IDE
store file actions'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
router
,
'push'
);
});
...
...
@@ -189,7 +189,7 @@ describe('Multi-file store file actions', () => {
it
(
'calls the service'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
localFile
)
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
}
)
.
then
(()
=>
{
expect
(
service
.
getFileData
).
toHaveBeenCalledWith
(
'getFileDataURL'
);
...
...
@@ -200,7 +200,7 @@ describe('Multi-file store file actions', () => {
it
(
'sets the file data'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
localFile
)
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
}
)
.
then
(()
=>
{
expect
(
localFile
.
blamePath
).
toBe
(
'blame_path'
);
...
...
@@ -211,7 +211,7 @@ describe('Multi-file store file actions', () => {
it
(
'sets document title'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
localFile
)
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
}
)
.
then
(()
=>
{
expect
(
document
.
title
).
toBe
(
'testing getFileData'
);
...
...
@@ -222,7 +222,7 @@ describe('Multi-file store file actions', () => {
it
(
'sets the file as active'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
localFile
)
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
}
)
.
then
(()
=>
{
expect
(
localFile
.
active
).
toBeTruthy
();
...
...
@@ -231,9 +231,20 @@ describe('Multi-file store file actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'sets the file not as active if we pass makeFileActive false'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
,
makeFileActive
:
false
})
.
then
(()
=>
{
expect
(
localFile
.
active
).
toBeFalsy
();
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'adds the file to open files'
,
done
=>
{
store
.
dispatch
(
'getFileData'
,
localFile
)
.
dispatch
(
'getFileData'
,
{
path
:
localFile
.
path
}
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
1
);
expect
(
store
.
state
.
openFiles
[
0
].
name
).
toBe
(
localFile
.
name
);
...
...
@@ -256,7 +267,7 @@ describe('Multi-file store file actions', () => {
it
(
'calls getRawFileData service method'
,
done
=>
{
store
.
dispatch
(
'getRawFileData'
,
tmpFile
)
.
dispatch
(
'getRawFileData'
,
{
path
:
tmpFile
.
path
}
)
.
then
(()
=>
{
expect
(
service
.
getRawFileData
).
toHaveBeenCalledWith
(
tmpFile
);
...
...
@@ -267,7 +278,7 @@ describe('Multi-file store file actions', () => {
it
(
'updates file raw data'
,
done
=>
{
store
.
dispatch
(
'getRawFileData'
,
tmpFile
)
.
dispatch
(
'getRawFileData'
,
{
path
:
tmpFile
.
path
}
)
.
then
(()
=>
{
expect
(
tmpFile
.
raw
).
toBe
(
'raw'
);
...
...
@@ -275,6 +286,22 @@ describe('Multi-file store file actions', () => {
})
.
catch
(
done
.
fail
);
});
it
(
'calls also getBaseRawFileData service method'
,
done
=>
{
spyOn
(
service
,
'getBaseRawFileData'
).
and
.
returnValue
(
Promise
.
resolve
(
'baseraw'
));
tmpFile
.
mrChange
=
{
new_file
:
false
};
store
.
dispatch
(
'getRawFileData'
,
{
path
:
tmpFile
.
path
,
baseSha
:
'SHA'
})
.
then
(()
=>
{
expect
(
service
.
getBaseRawFileData
).
toHaveBeenCalledWith
(
tmpFile
,
'SHA'
);
expect
(
tmpFile
.
baseRaw
).
toBe
(
'baseraw'
);
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'changeFileContent'
,
()
=>
{
...
...
spec/javascripts/ide/stores/actions/merge_request_spec.js
0 → 100644
View file @
38d56a8b
import
store
from
'~/ide/stores'
;
import
service
from
'~/ide/services'
;
import
{
resetStore
}
from
'../../helpers'
;
describe
(
'IDE store merge request actions'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
projects
.
abcproject
=
{
mergeRequests
:
{},
};
});
afterEach
(()
=>
{
resetStore
(
store
);
});
describe
(
'getMergeRequestData'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'getProjectMergeRequestData'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
title
:
'mergerequest'
}
}),
);
});
it
(
'calls getProjectMergeRequestData service method'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestData'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
service
.
getProjectMergeRequestData
).
toHaveBeenCalledWith
(
'abcproject'
,
1
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'sets the Merge Request Object'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestData'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'1'
].
title
).
toBe
(
'mergerequest'
);
expect
(
store
.
state
.
currentMergeRequestId
).
toBe
(
1
);
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'getMergeRequestChanges'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'getProjectMergeRequestChanges'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
title
:
'mergerequest'
}
}),
);
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'1'
]
=
{
changes
:
[]
};
});
it
(
'calls getProjectMergeRequestChanges service method'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestChanges'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
service
.
getProjectMergeRequestChanges
).
toHaveBeenCalledWith
(
'abcproject'
,
1
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'sets the Merge Request Changes Object'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestChanges'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'1'
].
changes
.
title
).
toBe
(
'mergerequest'
,
);
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'getMergeRequestVersions'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'getProjectMergeRequestVersions'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
[{
id
:
789
}]
}),
);
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'1'
]
=
{
versions
:
[]
};
});
it
(
'calls getProjectMergeRequestVersions service method'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestVersions'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
service
.
getProjectMergeRequestVersions
).
toHaveBeenCalledWith
(
'abcproject'
,
1
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'sets the Merge Request Versions Object'
,
done
=>
{
store
.
dispatch
(
'getMergeRequestVersions'
,
{
projectId
:
'abcproject'
,
mergeRequestId
:
1
})
.
then
(()
=>
{
expect
(
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'1'
].
versions
.
length
).
toBe
(
1
);
done
();
})
.
catch
(
done
.
fail
);
});
});
});
spec/javascripts/ide/stores/actions/tree_spec.js
View file @
38d56a8b
...
...
@@ -68,9 +68,7 @@ describe('Multi-file store tree actions', () => {
expect
(
projectTree
.
tree
[
0
].
tree
[
1
].
name
).
toBe
(
'fileinfolder.js'
);
expect
(
projectTree
.
tree
[
1
].
type
).
toBe
(
'blob'
);
expect
(
projectTree
.
tree
[
0
].
tree
[
0
].
tree
[
0
].
type
).
toBe
(
'blob'
);
expect
(
projectTree
.
tree
[
0
].
tree
[
0
].
tree
[
0
].
name
).
toBe
(
'fileinsubfolder.js'
,
);
expect
(
projectTree
.
tree
[
0
].
tree
[
0
].
tree
[
0
].
name
).
toBe
(
'fileinsubfolder.js'
);
done
();
})
...
...
@@ -132,9 +130,7 @@ describe('Multi-file store tree actions', () => {
store
.
dispatch
(
'getLastCommitData'
,
projectTree
)
.
then
(()
=>
{
expect
(
service
.
getTreeLastCommit
).
toHaveBeenCalledWith
(
'lastcommitpath'
,
);
expect
(
service
.
getTreeLastCommit
).
toHaveBeenCalledWith
(
'lastcommitpath'
);
done
();
})
...
...
@@ -160,9 +156,7 @@ describe('Multi-file store tree actions', () => {
.
dispatch
(
'getLastCommitData'
,
projectTree
)
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
projectTree
.
tree
[
0
].
lastCommit
.
message
).
not
.
toBe
(
'commit message'
,
);
expect
(
projectTree
.
tree
[
0
].
lastCommit
.
message
).
not
.
toBe
(
'commit message'
);
done
();
})
...
...
spec/javascripts/ide/stores/getters_spec.js
View file @
38d56a8b
...
...
@@ -2,7 +2,7 @@ import * as getters from '~/ide/stores/getters';
import
state
from
'~/ide/stores/state'
;
import
{
file
}
from
'../helpers'
;
describe
(
'
Multi-file
store getters'
,
()
=>
{
describe
(
'
IDE
store getters'
,
()
=>
{
let
localState
;
beforeEach
(()
=>
{
...
...
@@ -52,4 +52,24 @@ describe('Multi-file store getters', () => {
expect
(
modifiedFiles
[
0
].
name
).
toBe
(
'added'
);
});
});
describe
(
'currentMergeRequest'
,
()
=>
{
it
(
'returns Current Merge Request'
,
()
=>
{
localState
.
currentProjectId
=
'abcproject'
;
localState
.
currentMergeRequestId
=
1
;
localState
.
projects
.
abcproject
=
{
mergeRequests
:
{
1
:
{
mergeId
:
1
},
},
};
expect
(
getters
.
currentMergeRequest
(
localState
).
mergeId
).
toBe
(
1
);
});
it
(
'returns null if no active Merge Request was found'
,
()
=>
{
localState
.
currentProjectId
=
'otherproject'
;
expect
(
getters
.
currentMergeRequest
(
localState
)).
toBeNull
();
});
});
});
spec/javascripts/ide/stores/mutations/file_spec.js
View file @
38d56a8b
...
...
@@ -2,7 +2,7 @@ import mutations from '~/ide/stores/mutations/file';
import
state
from
'~/ide/stores/state'
;
import
{
file
}
from
'../../helpers'
;
describe
(
'
Multi-file
store file mutations'
,
()
=>
{
describe
(
'
IDE
store file mutations'
,
()
=>
{
let
localState
;
let
localFile
;
...
...
@@ -62,6 +62,8 @@ describe('Multi-file store file mutations', () => {
expect
(
localFile
.
rawPath
).
toBe
(
'raw'
);
expect
(
localFile
.
binary
).
toBeTruthy
();
expect
(
localFile
.
renderError
).
toBe
(
'render_error'
);
expect
(
localFile
.
raw
).
toBeNull
();
expect
(
localFile
.
baseRaw
).
toBeNull
();
});
});
...
...
@@ -76,6 +78,17 @@ describe('Multi-file store file mutations', () => {
});
});
describe
(
'SET_FILE_BASE_RAW_DATA'
,
()
=>
{
it
(
'sets raw data from base branch'
,
()
=>
{
mutations
.
SET_FILE_BASE_RAW_DATA
(
localState
,
{
file
:
localFile
,
baseRaw
:
'testing'
,
});
expect
(
localFile
.
baseRaw
).
toBe
(
'testing'
);
});
});
describe
(
'UPDATE_FILE_CONTENT'
,
()
=>
{
beforeEach
(()
=>
{
localFile
.
raw
=
'test'
;
...
...
@@ -112,6 +125,17 @@ describe('Multi-file store file mutations', () => {
});
});
describe
(
'SET_FILE_MR_CHANGE'
,
()
=>
{
it
(
'sets file mr change'
,
()
=>
{
mutations
.
SET_FILE_MR_CHANGE
(
localState
,
{
file
:
localFile
,
mrChange
:
{
diff
:
'ABC'
},
});
expect
(
localFile
.
mrChange
.
diff
).
toBe
(
'ABC'
);
});
});
describe
(
'DISCARD_FILE_CHANGES'
,
()
=>
{
beforeEach
(()
=>
{
localFile
.
content
=
'test'
;
...
...
spec/javascripts/ide/stores/mutations/merge_request_spec.js
0 → 100644
View file @
38d56a8b
import
mutations
from
'~/ide/stores/mutations/merge_request'
;
import
state
from
'~/ide/stores/state'
;
describe
(
'IDE store merge request mutations'
,
()
=>
{
let
localState
;
beforeEach
(()
=>
{
localState
=
state
();
localState
.
projects
=
{
abcproject
:
{
mergeRequests
:
{}
}
};
mutations
.
SET_MERGE_REQUEST
(
localState
,
{
projectPath
:
'abcproject'
,
mergeRequestId
:
1
,
mergeRequest
:
{
title
:
'mr'
,
},
});
});
describe
(
'SET_CURRENT_MERGE_REQUEST'
,
()
=>
{
it
(
'sets current merge request'
,
()
=>
{
mutations
.
SET_CURRENT_MERGE_REQUEST
(
localState
,
2
);
expect
(
localState
.
currentMergeRequestId
).
toBe
(
2
);
});
});
describe
(
'SET_MERGE_REQUEST'
,
()
=>
{
it
(
'setsmerge request data'
,
()
=>
{
const
newMr
=
localState
.
projects
.
abcproject
.
mergeRequests
[
1
];
expect
(
newMr
.
title
).
toBe
(
'mr'
);
expect
(
newMr
.
active
).
toBeTruthy
();
});
});
describe
(
'SET_MERGE_REQUEST_CHANGES'
,
()
=>
{
it
(
'sets merge request changes'
,
()
=>
{
mutations
.
SET_MERGE_REQUEST_CHANGES
(
localState
,
{
projectPath
:
'abcproject'
,
mergeRequestId
:
1
,
changes
:
{
diff
:
'abc'
,
},
});
const
newMr
=
localState
.
projects
.
abcproject
.
mergeRequests
[
1
];
expect
(
newMr
.
changes
.
diff
).
toBe
(
'abc'
);
});
});
describe
(
'SET_MERGE_REQUEST_VERSIONS'
,
()
=>
{
it
(
'sets merge request versions'
,
()
=>
{
mutations
.
SET_MERGE_REQUEST_VERSIONS
(
localState
,
{
projectPath
:
'abcproject'
,
mergeRequestId
:
1
,
versions
:
[{
id
:
123
}],
});
const
newMr
=
localState
.
projects
.
abcproject
.
mergeRequests
[
1
];
expect
(
newMr
.
versions
.
length
).
toBe
(
1
);
expect
(
newMr
.
versions
[
0
].
id
).
toBe
(
123
);
});
});
});
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