Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
8df71147
Commit
8df71147
authored
Apr 18, 2019
by
Hannah Stepanek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sidebar-content tests for direct-group error
parent
703924c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
4 deletions
+131
-4
sidebar-content-test.js
src/sidebar/components/test/sidebar-content-test.js
+131
-4
No files found.
src/sidebar/components/test/sidebar-content-test.js
View file @
8df71147
...
@@ -6,6 +6,7 @@ const EventEmitter = require('tiny-emitter');
...
@@ -6,6 +6,7 @@ const EventEmitter = require('tiny-emitter');
const
events
=
require
(
'../../events'
);
const
events
=
require
(
'../../events'
);
const
noCallThru
=
require
(
'../../../shared/test/util'
).
noCallThru
;
const
noCallThru
=
require
(
'../../../shared/test/util'
).
noCallThru
;
const
uiConstants
=
require
(
'../../ui-constants'
);
let
searchClients
;
let
searchClients
;
...
@@ -150,7 +151,7 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -150,7 +151,7 @@ describe('sidebar.components.sidebar-content', function() {
});
});
}
}
beforeEach
(
const
makeSidebarContentController
=
()
=>
{
angular
.
mock
.
inject
(
function
(
$componentController
,
_store_
,
_$rootScope_
)
{
angular
.
mock
.
inject
(
function
(
$componentController
,
_store_
,
_$rootScope_
)
{
$rootScope
=
_$rootScope_
;
$rootScope
=
_$rootScope_
;
$scope
=
$rootScope
.
$new
();
$scope
=
$rootScope
.
$new
();
...
@@ -163,13 +164,84 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -163,13 +164,84 @@ describe('sidebar.components.sidebar-content', function() {
auth
:
{
status
:
'unknown'
},
auth
:
{
status
:
'unknown'
},
}
}
);
);
})
});
);
};
beforeEach
(()
=>
{
makeSidebarContentController
();
});
afterEach
(
function
()
{
afterEach
(
function
()
{
return
sandbox
.
restore
();
return
sandbox
.
restore
();
});
});
describe
(
'clearSelection'
,
()
=>
{
it
(
'sets selectedTab to Annotations tab if selectedTab is null'
,
()
=>
{
store
.
selectTab
(
uiConstants
.
TAB_ORPHANS
);
$scope
.
$digest
();
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'sets selectedTab to Annotations tab if selectedTab is set to orphans'
,
()
=>
{
store
.
selectTab
(
uiConstants
.
TAB_ORPHANS
);
$scope
.
$digest
();
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedTab
,
uiConstants
.
TAB_ANNOTATIONS
);
});
it
(
'clears selected annotations'
,
()
=>
{
ctrl
.
clearSelection
();
assert
.
equal
(
store
.
getState
().
selectedAnnotationMap
,
null
);
assert
.
equal
(
store
.
getState
().
filterQuery
,
null
);
});
it
(
'clears the directLinkedGroupFetchFailed state'
,
()
=>
{
ctrl
.
directLinkedGroupFetchFailed
=
true
;
ctrl
.
clearSelection
();
assert
.
isFalse
(
ctrl
.
directLinkedGroupFetchFailed
);
});
});
describe
(
'showSelectedTabs'
,
()
=>
{
beforeEach
(()
=>
{
setFrames
([{
uri
:
'http://www.example.com'
}]);
ctrl
.
search
=
{
query
:
sinon
.
stub
().
returns
(
undefined
)
};
});
it
(
'returns false if there is a search query'
,
()
=>
{
ctrl
.
search
=
{
query
:
sinon
.
stub
().
returns
(
'tag:foo'
)
};
assert
.
isFalse
(
ctrl
.
showSelectedTabs
());
});
it
(
'returns false if selected group is unavailable'
,
()
=>
{
fakeSettings
.
group
=
'group-id'
;
store
.
loadGroups
([{
id
:
'default-id'
}]);
store
.
focusGroup
(
'default-id'
);
fakeGroups
.
focused
.
returns
({
id
:
'default-id'
});
$scope
.
$digest
();
// Re-construct the controller after the environment setup.
makeSidebarContentController
();
assert
.
isFalse
(
ctrl
.
showSelectedTabs
());
});
it
(
'returns false if selected annotation is unavailable'
,
()
=>
{
store
.
selectAnnotations
([
'missing'
]);
$scope
.
$digest
();
assert
.
isFalse
(
ctrl
.
showSelectedTabs
());
});
it
(
'returns true in all other cases'
,
()
=>
{
assert
.
isTrue
(
ctrl
.
showSelectedTabs
());
});
});
describe
(
'#loadAnnotations'
,
function
()
{
describe
(
'#loadAnnotations'
,
function
()
{
it
(
'unloads any existing annotations'
,
function
()
{
it
(
'unloads any existing annotations'
,
function
()
{
// When new clients connect, all existing annotations should be unloaded
// When new clients connect, all existing annotations should be unloaded
...
@@ -255,7 +327,62 @@ describe('sidebar.components.sidebar-content', function() {
...
@@ -255,7 +327,62 @@ describe('sidebar.components.sidebar-content', function() {
assert
.
isTrue
(
updateSpy
.
calledWith
(
frameUris
[
1
],
true
));
assert
.
isTrue
(
updateSpy
.
calledWith
(
frameUris
[
1
],
true
));
});
});
context
(
'when there is a selection'
,
function
()
{
context
(
'when there is a direct-linked group error'
,
()
=>
{
beforeEach
(()
=>
{
setFrames
([{
uri
:
'http://www.example.com'
}]);
fakeSettings
.
group
=
'group-id'
;
store
.
loadGroups
([{
id
:
'default-id'
}]);
store
.
focusGroup
(
'default-id'
);
fakeGroups
.
focused
.
returns
({
id
:
'default-id'
});
$scope
.
$digest
();
// Re-construct the controller after the environment setup.
makeSidebarContentController
();
});
it
(
'sets directLinkedGroupFetchFailed to true'
,
()
=>
{
assert
.
isTrue
(
ctrl
.
directLinkedGroupFetchFailed
);
});
it
(
'areAllAnnotationsVisible returns true since there is an error message'
,
()
=>
{
assert
.
isTrue
(
ctrl
.
areAllAnnotationsVisible
());
});
it
(
'selectedGroupUnavailable returns true'
,
()
=>
{
assert
.
isTrue
(
ctrl
.
selectedGroupUnavailable
());
});
});
context
(
'when there is a direct-linked group selection'
,
()
=>
{
beforeEach
(()
=>
{
setFrames
([{
uri
:
'http://www.example.com'
}]);
fakeSettings
.
group
=
'group-id'
;
store
.
loadGroups
([{
id
:
fakeSettings
.
group
}]);
store
.
focusGroup
(
fakeSettings
.
group
);
fakeGroups
.
focused
.
returns
({
id
:
fakeSettings
.
group
});
$scope
.
$digest
();
});
it
(
'sets directLinkedGroupFetchFailed to false'
,
()
=>
{
assert
.
isFalse
(
ctrl
.
directLinkedGroupFetchFailed
);
});
it
(
'areAllAnnotationsVisible returns false since group has no annotations'
,
()
=>
{
assert
.
isFalse
(
ctrl
.
areAllAnnotationsVisible
());
});
it
(
'selectedGroupUnavailable returns false'
,
()
=>
{
assert
.
isFalse
(
ctrl
.
selectedGroupUnavailable
());
});
it
(
'fetches annotations for the direct-linked group'
,
()
=>
{
assert
.
calledWith
(
searchClients
[
0
].
get
,
{
uri
:
[
'http://www.example.com'
],
group
:
'group-id'
,
});
});
});
context
(
'when there is a direct-linked annotation selection'
,
function
()
{
const
uri
=
'http://example.com'
;
const
uri
=
'http://example.com'
;
const
id
=
uri
+
'123'
;
const
id
=
uri
+
'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