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
bfcc3543
Commit
bfcc3543
authored
Aug 23, 2019
by
Kyle Keating
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage
parent
7c2eea8e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
45 deletions
+104
-45
search-status-bar.js
src/sidebar/components/search-status-bar.js
+5
-4
selection-tabs.js
src/sidebar/components/selection-tabs.js
+3
-1
search-status-bar-test.js
src/sidebar/components/test/search-status-bar-test.js
+46
-24
selection-tabs-test.js
src/sidebar/components/test/selection-tabs-test.js
+32
-12
root-thread-test.js
src/sidebar/services/test/root-thread-test.js
+7
-4
selection-test.js
src/sidebar/store/modules/test/selection-test.js
+11
-0
No files found.
src/sidebar/components/search-status-bar.js
View file @
bfcc3543
...
...
@@ -28,10 +28,11 @@ function SearchStatusBar({ rootThread }) {
selectedAnnotationMap
,
selectedTab
,
}
=
useStore
(
store
=>
({
directLinkedGroupFetchFailed
:
store
.
getState
().
directLinkedGroupFetchFailed
,
filterQuery
:
store
.
getState
().
filterQuery
,
selectedAnnotationMap
:
store
.
getState
().
selectedAnnotationMap
,
selectedTab
:
store
.
getState
().
selectedTab
,
directLinkedGroupFetchFailed
:
store
.
getRootState
().
directLinked
.
directLinkedGroupFetchFailed
,
filterQuery
:
store
.
getRootState
().
selection
.
filterQuery
,
selectedAnnotationMap
:
store
.
getRootState
().
selection
.
selectedAnnotationMap
,
selectedTab
:
store
.
getRootState
().
selection
.
selectedTab
,
}));
const
clearSelection
=
useStore
(
store
=>
store
.
clearSelection
);
const
filterActive
=
!!
filterQuery
;
...
...
src/sidebar/components/selection-tabs.js
View file @
bfcc3543
...
...
@@ -70,7 +70,9 @@ Tab.propTypes = {
*/
function
SelectionTabs
({
isLoading
,
settings
,
session
})
{
const
selectedTab
=
useStore
(
store
=>
store
.
getState
().
selectedTab
);
const
selectedTab
=
useStore
(
store
=>
store
.
getRootState
().
selection
.
selectedTab
);
const
noteCount
=
useStore
(
store
=>
store
.
noteCount
());
const
annotationCount
=
useStore
(
store
=>
store
.
annotationCount
());
const
orphanCount
=
useStore
(
store
=>
store
.
orphanCount
());
...
...
src/sidebar/components/test/search-status-bar-test.js
View file @
bfcc3543
...
...
@@ -21,7 +21,10 @@ describe('SearchStatusBar', () => {
};
fakeStore
=
{
getState
:
sinon
.
stub
(),
getRootState
:
sinon
.
stub
(),
getRootState
:
sinon
.
stub
().
returns
({
selection
:
{},
directLinked
:
{},
}),
annotationCount
:
sinon
.
stub
().
returns
(
1
),
noteCount
:
sinon
.
stub
().
returns
(
0
),
};
...
...
@@ -92,9 +95,14 @@ describe('SearchStatusBar', () => {
fakeRootThread
.
thread
.
returns
({
children
:
test
.
children
,
});
fakeStore
.
getState
.
returns
({
filterQuery
:
'tag:foo'
,
selectedTab
:
'annotation'
,
fakeStore
.
getRootState
.
returns
({
selection
:
{
filterQuery
:
'tag:foo'
,
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
fakeStore
.
annotationCount
.
returns
(
3
);
...
...
@@ -109,11 +117,13 @@ describe('SearchStatusBar', () => {
});
it
(
'displays "Show all annotations" button when a direct-linked group fetch fails'
,
()
=>
{
fakeStore
.
getState
.
returns
({
filterQuery
:
null
,
directLinkedGroupFetchFailed
:
true
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
fakeStore
.
getRootState
.
returns
({
selection
:
{
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
},
directLinked
:
{},
});
const
wrapper
=
createComponent
({});
...
...
@@ -123,11 +133,15 @@ describe('SearchStatusBar', () => {
});
it
(
'displays "Show all annotations" button when there are selected annotations'
,
()
=>
{
fakeStore
.
getState
.
returns
({
filterQuery
:
null
,
directLinkedGroupFetchFailed
:
false
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
fakeStore
.
getRootState
.
returns
({
selection
:
{
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
const
wrapper
=
createComponent
({});
...
...
@@ -138,11 +152,15 @@ describe('SearchStatusBar', () => {
[
null
,
{}].
forEach
(
selectedAnnotationMap
=>
{
it
(
'does not display "Show all annotations" button when there are no selected annotations'
,
()
=>
{
fakeStore
.
getState
.
returns
({
filterQuery
:
null
,
directLinkedGroupFetchFailed
:
false
,
selectedAnnotationMap
:
selectedAnnotationMap
,
selectedTab
:
'annotation'
,
fakeStore
.
getRootState
.
returns
({
selection
:
{
filterQuery
:
null
,
selectedAnnotationMap
:
selectedAnnotationMap
,
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
const
wrapper
=
createComponent
({});
...
...
@@ -187,11 +205,15 @@ describe('SearchStatusBar', () => {
},
].
forEach
(
test
=>
{
it
(
test
.
description
,
()
=>
{
fakeStore
.
getState
.
returns
({
filterQuery
:
null
,
directLinkedGroupFetchFailed
:
false
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
test
.
selectedTab
,
fakeStore
.
getRootState
.
returns
({
selection
:
{
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
test
.
selectedTab
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
fakeStore
.
noteCount
.
returns
(
test
.
totalNotes
);
fakeStore
.
annotationCount
.
returns
(
test
.
totalAnnotations
);
...
...
src/sidebar/components/test/selection-tabs-test.js
View file @
bfcc3543
...
...
@@ -63,9 +63,11 @@ describe('SelectionTabs', function() {
noteCount
:
sinon
.
stub
().
returns
(
456
),
orphanCount
:
sinon
.
stub
().
returns
(
0
),
isWaitingToAnchorAnnotations
:
sinon
.
stub
().
returns
(
false
),
getState
:
sinon
.
stub
()
.
returns
({
selectedTab
:
uiConstants
.
TAB_ANNOTATIONS
}),
getRootState
:
sinon
.
stub
().
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},
}),
};
});
...
...
@@ -101,14 +103,18 @@ describe('SelectionTabs', function() {
});
it
(
'should display notes tab as selected'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
const
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
assert
.
isTrue
(
tabs
.
at
(
1
).
hasClass
(
'is-selected'
));
});
it
(
'should display orphans tab as selected if there is 1 or more orphans'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_ORPHANS
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_ORPHANS
},
});
fakeStore
.
orphanCount
.
returns
(
1
);
const
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
...
...
@@ -116,7 +122,9 @@ describe('SelectionTabs', function() {
});
it
(
'should not display orphans tab if there are 0 orphans'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_ORPHANS
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_ORPHANS
},
});
const
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
assert
.
equal
(
tabs
.
length
,
2
);
...
...
@@ -139,14 +147,18 @@ describe('SelectionTabs', function() {
});
it
(
'should not display the new-note-btn when the notes tab is active and the new-note-btn is disabled'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
const
wrapper
=
createComponent
({});
assert
.
equal
(
wrapper
.
find
(
NewNoteBtn
).
length
,
0
);
});
it
(
'should display the new-note-btn when the notes tab is active and the new-note-btn is enabled'
,
function
()
{
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
const
wrapper
=
createComponent
({});
assert
.
equal
(
wrapper
.
find
(
NewNoteBtn
).
length
,
1
);
});
...
...
@@ -160,7 +172,9 @@ describe('SelectionTabs', function() {
});
it
(
'should not display a message when its loading notes count is 0'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({
isLoading
:
true
,
...
...
@@ -178,7 +192,9 @@ describe('SelectionTabs', function() {
});
it
(
'should display the longer version of the no notes message when there are no notes'
,
function
()
{
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
assert
.
include
(
...
...
@@ -189,7 +205,9 @@ describe('SelectionTabs', function() {
it
(
'should display the prompt to create a note when there are no notes and enableExperimentalNewNoteButton is true'
,
function
()
{
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
assert
.
include
(
...
...
@@ -224,7 +242,9 @@ describe('SelectionTabs', function() {
context
(
'when the sidebar tutorial is displayed'
,
function
()
{
it
(
'should display the shorter version of the no notes message when there are no notes'
,
function
()
{
fakeSession
.
state
.
preferences
.
show_sidebar_tutorial
=
true
;
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
...
...
src/sidebar/services/test/root-thread-test.js
View file @
bfcc3543
...
...
@@ -46,11 +46,7 @@ describe('rootThread', function() {
focusedAnnotationMap
:
null
,
forceVisible
:
{},
highlighted
:
[],
selectedAnnotationMap
:
null
,
session
:
{
features
:
{},
},
sortKey
:
'Location'
,
sortKeysAvailable
:
[
'Location'
],
},
...
...
@@ -301,6 +297,13 @@ describe('rootThread', function() {
// pages, since we show all types of annotations here
assert
.
notOk
(
threadFilterFn
);
});
it
(
'filter returns false when no annotations are provided'
,
function
()
{
fakeBuildThread
.
reset
();
rootThread
.
thread
(
fakeStore
.
state
);
const
threadFilterFn
=
fakeBuildThread
.
args
[
0
][
1
].
threadFilterFn
;
assert
.
isFalse
(
threadFilterFn
({}));
});
});
describe
(
'when the filter query changes'
,
function
()
{
...
...
src/sidebar/store/modules/test/selection-test.js
View file @
bfcc3543
...
...
@@ -80,6 +80,17 @@ describe('store/modules/selection', () => {
});
});
describe
(
'filterQuery'
,
function
()
{
it
(
'returns the filterQuery value when provided'
,
function
()
{
store
.
setFilterQuery
(
'tag:foo'
);
assert
.
equal
(
store
.
filterQuery
(),
'tag:foo'
);
});
it
(
'returns null when no filterQuery is present'
,
function
()
{
assert
.
isNull
(
store
.
filterQuery
());
});
});
describe
(
'isAnnotationSelected'
,
function
()
{
it
(
'returns true if the id provided is selected'
,
function
()
{
store
.
selectAnnotations
([
1
]);
...
...
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