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 }) {
...
@@ -28,10 +28,11 @@ function SearchStatusBar({ rootThread }) {
selectedAnnotationMap
,
selectedAnnotationMap
,
selectedTab
,
selectedTab
,
}
=
useStore
(
store
=>
({
}
=
useStore
(
store
=>
({
directLinkedGroupFetchFailed
:
store
.
getState
().
directLinkedGroupFetchFailed
,
directLinkedGroupFetchFailed
:
store
.
getRootState
().
directLinked
filterQuery
:
store
.
getState
().
filterQuery
,
.
directLinkedGroupFetchFailed
,
selectedAnnotationMap
:
store
.
getState
().
selectedAnnotationMap
,
filterQuery
:
store
.
getRootState
().
selection
.
filterQuery
,
selectedTab
:
store
.
getState
().
selectedTab
,
selectedAnnotationMap
:
store
.
getRootState
().
selection
.
selectedAnnotationMap
,
selectedTab
:
store
.
getRootState
().
selection
.
selectedTab
,
}));
}));
const
clearSelection
=
useStore
(
store
=>
store
.
clearSelection
);
const
clearSelection
=
useStore
(
store
=>
store
.
clearSelection
);
const
filterActive
=
!!
filterQuery
;
const
filterActive
=
!!
filterQuery
;
...
...
src/sidebar/components/selection-tabs.js
View file @
bfcc3543
...
@@ -70,7 +70,9 @@ Tab.propTypes = {
...
@@ -70,7 +70,9 @@ Tab.propTypes = {
*/
*/
function
SelectionTabs
({
isLoading
,
settings
,
session
})
{
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
noteCount
=
useStore
(
store
=>
store
.
noteCount
());
const
annotationCount
=
useStore
(
store
=>
store
.
annotationCount
());
const
annotationCount
=
useStore
(
store
=>
store
.
annotationCount
());
const
orphanCount
=
useStore
(
store
=>
store
.
orphanCount
());
const
orphanCount
=
useStore
(
store
=>
store
.
orphanCount
());
...
...
src/sidebar/components/test/search-status-bar-test.js
View file @
bfcc3543
...
@@ -21,7 +21,10 @@ describe('SearchStatusBar', () => {
...
@@ -21,7 +21,10 @@ describe('SearchStatusBar', () => {
};
};
fakeStore
=
{
fakeStore
=
{
getState
:
sinon
.
stub
(),
getState
:
sinon
.
stub
(),
getRootState
:
sinon
.
stub
(),
getRootState
:
sinon
.
stub
().
returns
({
selection
:
{},
directLinked
:
{},
}),
annotationCount
:
sinon
.
stub
().
returns
(
1
),
annotationCount
:
sinon
.
stub
().
returns
(
1
),
noteCount
:
sinon
.
stub
().
returns
(
0
),
noteCount
:
sinon
.
stub
().
returns
(
0
),
};
};
...
@@ -92,9 +95,14 @@ describe('SearchStatusBar', () => {
...
@@ -92,9 +95,14 @@ describe('SearchStatusBar', () => {
fakeRootThread
.
thread
.
returns
({
fakeRootThread
.
thread
.
returns
({
children
:
test
.
children
,
children
:
test
.
children
,
});
});
fakeStore
.
getState
.
returns
({
fakeStore
.
getRootState
.
returns
({
filterQuery
:
'tag:foo'
,
selection
:
{
selectedTab
:
'annotation'
,
filterQuery
:
'tag:foo'
,
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
});
fakeStore
.
annotationCount
.
returns
(
3
);
fakeStore
.
annotationCount
.
returns
(
3
);
...
@@ -109,11 +117,13 @@ describe('SearchStatusBar', () => {
...
@@ -109,11 +117,13 @@ describe('SearchStatusBar', () => {
});
});
it
(
'displays "Show all annotations" button when a direct-linked group fetch fails'
,
()
=>
{
it
(
'displays "Show all annotations" button when a direct-linked group fetch fails'
,
()
=>
{
fakeStore
.
getState
.
returns
({
fakeStore
.
getRootState
.
returns
({
filterQuery
:
null
,
selection
:
{
directLinkedGroupFetchFailed
:
true
,
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
selectedTab
:
'annotation'
,
},
directLinked
:
{},
});
});
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
...
@@ -123,11 +133,15 @@ describe('SearchStatusBar', () => {
...
@@ -123,11 +133,15 @@ describe('SearchStatusBar', () => {
});
});
it
(
'displays "Show all annotations" button when there are selected annotations'
,
()
=>
{
it
(
'displays "Show all annotations" button when there are selected annotations'
,
()
=>
{
fakeStore
.
getState
.
returns
({
fakeStore
.
getRootState
.
returns
({
filterQuery
:
null
,
selection
:
{
directLinkedGroupFetchFailed
:
false
,
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
'annotation'
,
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
});
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
...
@@ -138,11 +152,15 @@ describe('SearchStatusBar', () => {
...
@@ -138,11 +152,15 @@ describe('SearchStatusBar', () => {
[
null
,
{}].
forEach
(
selectedAnnotationMap
=>
{
[
null
,
{}].
forEach
(
selectedAnnotationMap
=>
{
it
(
'does not display "Show all annotations" button when there are no selected annotations'
,
()
=>
{
it
(
'does not display "Show all annotations" button when there are no selected annotations'
,
()
=>
{
fakeStore
.
getState
.
returns
({
fakeStore
.
getRootState
.
returns
({
filterQuery
:
null
,
selection
:
{
directLinkedGroupFetchFailed
:
false
,
filterQuery
:
null
,
selectedAnnotationMap
:
selectedAnnotationMap
,
selectedAnnotationMap
:
selectedAnnotationMap
,
selectedTab
:
'annotation'
,
selectedTab
:
'annotation'
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
});
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
...
@@ -187,11 +205,15 @@ describe('SearchStatusBar', () => {
...
@@ -187,11 +205,15 @@ describe('SearchStatusBar', () => {
},
},
].
forEach
(
test
=>
{
].
forEach
(
test
=>
{
it
(
test
.
description
,
()
=>
{
it
(
test
.
description
,
()
=>
{
fakeStore
.
getState
.
returns
({
fakeStore
.
getRootState
.
returns
({
filterQuery
:
null
,
selection
:
{
directLinkedGroupFetchFailed
:
false
,
filterQuery
:
null
,
selectedAnnotationMap
:
{
annId
:
true
},
selectedAnnotationMap
:
{
annId
:
true
},
selectedTab
:
test
.
selectedTab
,
selectedTab
:
test
.
selectedTab
,
},
directLinked
:
{
directLinkedGroupFetchFailed
:
false
,
},
});
});
fakeStore
.
noteCount
.
returns
(
test
.
totalNotes
);
fakeStore
.
noteCount
.
returns
(
test
.
totalNotes
);
fakeStore
.
annotationCount
.
returns
(
test
.
totalAnnotations
);
fakeStore
.
annotationCount
.
returns
(
test
.
totalAnnotations
);
...
...
src/sidebar/components/test/selection-tabs-test.js
View file @
bfcc3543
...
@@ -63,9 +63,11 @@ describe('SelectionTabs', function() {
...
@@ -63,9 +63,11 @@ describe('SelectionTabs', function() {
noteCount
:
sinon
.
stub
().
returns
(
456
),
noteCount
:
sinon
.
stub
().
returns
(
456
),
orphanCount
:
sinon
.
stub
().
returns
(
0
),
orphanCount
:
sinon
.
stub
().
returns
(
0
),
isWaitingToAnchorAnnotations
:
sinon
.
stub
().
returns
(
false
),
isWaitingToAnchorAnnotations
:
sinon
.
stub
().
returns
(
false
),
getState
:
sinon
getRootState
:
sinon
.
stub
().
returns
({
.
stub
()
selection
:
{
.
returns
({
selectedTab
:
uiConstants
.
TAB_ANNOTATIONS
}),
selectedTab
:
uiConstants
.
TAB_ANNOTATIONS
,
},
}),
};
};
});
});
...
@@ -101,14 +103,18 @@ describe('SelectionTabs', function() {
...
@@ -101,14 +103,18 @@ describe('SelectionTabs', function() {
});
});
it
(
'should display notes tab as selected'
,
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
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
const
tabs
=
wrapper
.
find
(
'a'
);
assert
.
isTrue
(
tabs
.
at
(
1
).
hasClass
(
'is-selected'
));
assert
.
isTrue
(
tabs
.
at
(
1
).
hasClass
(
'is-selected'
));
});
});
it
(
'should display orphans tab as selected if there is 1 or more orphans'
,
function
()
{
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
);
fakeStore
.
orphanCount
.
returns
(
1
);
const
wrapper
=
createDeepComponent
({});
const
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
const
tabs
=
wrapper
.
find
(
'a'
);
...
@@ -116,7 +122,9 @@ describe('SelectionTabs', function() {
...
@@ -116,7 +122,9 @@ describe('SelectionTabs', function() {
});
});
it
(
'should not display orphans tab if there are 0 orphans'
,
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
wrapper
=
createDeepComponent
({});
const
tabs
=
wrapper
.
find
(
'a'
);
const
tabs
=
wrapper
.
find
(
'a'
);
assert
.
equal
(
tabs
.
length
,
2
);
assert
.
equal
(
tabs
.
length
,
2
);
...
@@ -139,14 +147,18 @@ describe('SelectionTabs', function() {
...
@@ -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
()
{
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
({});
const
wrapper
=
createComponent
({});
assert
.
equal
(
wrapper
.
find
(
NewNoteBtn
).
length
,
0
);
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
()
{
it
(
'should display the new-note-btn when the notes tab is active and the new-note-btn is enabled'
,
function
()
{
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
assert
.
equal
(
wrapper
.
find
(
NewNoteBtn
).
length
,
1
);
assert
.
equal
(
wrapper
.
find
(
NewNoteBtn
).
length
,
1
);
});
});
...
@@ -160,7 +172,9 @@ describe('SelectionTabs', function() {
...
@@ -160,7 +172,9 @@ describe('SelectionTabs', function() {
});
});
it
(
'should not display a message when its loading notes count is 0'
,
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
);
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({
const
wrapper
=
createComponent
({
isLoading
:
true
,
isLoading
:
true
,
...
@@ -178,7 +192,9 @@ describe('SelectionTabs', function() {
...
@@ -178,7 +192,9 @@ describe('SelectionTabs', function() {
});
});
it
(
'should display the longer version of the no notes message when there are no notes'
,
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
);
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
assert
.
include
(
assert
.
include
(
...
@@ -189,7 +205,9 @@ describe('SelectionTabs', function() {
...
@@ -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
()
{
it
(
'should display the prompt to create a note when there are no notes and enableExperimentalNewNoteButton is true'
,
function
()
{
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeSettings
.
enableExperimentalNewNoteButton
=
true
;
fakeStore
.
getState
.
returns
({
selectedTab
:
uiConstants
.
TAB_NOTES
});
fakeStore
.
getRootState
.
returns
({
selection
:
{
selectedTab
:
uiConstants
.
TAB_NOTES
},
});
fakeStore
.
noteCount
.
returns
(
0
);
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
assert
.
include
(
assert
.
include
(
...
@@ -224,7 +242,9 @@ describe('SelectionTabs', function() {
...
@@ -224,7 +242,9 @@ describe('SelectionTabs', function() {
context
(
'when the sidebar tutorial is displayed'
,
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
()
{
it
(
'should display the shorter version of the no notes message when there are no notes'
,
function
()
{
fakeSession
.
state
.
preferences
.
show_sidebar_tutorial
=
true
;
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
);
fakeStore
.
noteCount
.
returns
(
0
);
const
wrapper
=
createComponent
({});
const
wrapper
=
createComponent
({});
...
...
src/sidebar/services/test/root-thread-test.js
View file @
bfcc3543
...
@@ -46,11 +46,7 @@ describe('rootThread', function() {
...
@@ -46,11 +46,7 @@ describe('rootThread', function() {
focusedAnnotationMap
:
null
,
focusedAnnotationMap
:
null
,
forceVisible
:
{},
forceVisible
:
{},
highlighted
:
[],
highlighted
:
[],
selectedAnnotationMap
:
null
,
selectedAnnotationMap
:
null
,
session
:
{
features
:
{},
},
sortKey
:
'Location'
,
sortKey
:
'Location'
,
sortKeysAvailable
:
[
'Location'
],
sortKeysAvailable
:
[
'Location'
],
},
},
...
@@ -301,6 +297,13 @@ describe('rootThread', function() {
...
@@ -301,6 +297,13 @@ describe('rootThread', function() {
// pages, since we show all types of annotations here
// pages, since we show all types of annotations here
assert
.
notOk
(
threadFilterFn
);
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
()
{
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', () => {
...
@@ -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
()
{
describe
(
'isAnnotationSelected'
,
function
()
{
it
(
'returns true if the id provided is selected'
,
function
()
{
it
(
'returns true if the id provided is selected'
,
function
()
{
store
.
selectAnnotations
([
1
]);
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