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
342f6f83
Commit
342f6f83
authored
May 11, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
May 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `isShared` property, use `notify` when sending annotation activity
parent
e7b406e9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
annotation-activity.js
src/sidebar/services/annotation-activity.js
+4
-3
annotation-activity-test.js
src/sidebar/services/test/annotation-activity-test.js
+18
-11
No files found.
src/sidebar/services/annotation-activity.js
View file @
342f6f83
import
{
isShared
}
from
'../helpers/permissions'
;
import
*
as
postMessageJsonRpc
from
'../util/postmessage-json-rpc'
;
/**
...
...
@@ -45,16 +46,16 @@ export class AnnotationActivityService {
date
:
activityDate
,
annotation
:
{
id
:
annotation
.
id
,
isShared
:
isShared
(
annotation
.
permissions
),
},
};
if
(
this
.
_reportConfig
.
events
.
includes
(
eventType
))
{
postMessageJsonRpc
.
call
(
postMessageJsonRpc
.
notify
(
this
.
_rpc
.
targetFrame
,
this
.
_rpc
.
origin
,
this
.
_reportConfig
.
method
,
[
eventType
,
data
],
3000
[
eventType
,
data
]
);
}
}
...
...
src/sidebar/services/test/annotation-activity-test.js
View file @
342f6f83
...
...
@@ -3,6 +3,7 @@ import * as fixtures from '../../test/annotation-fixtures';
import
{
AnnotationActivityService
,
$imports
}
from
'../annotation-activity'
;
describe
(
'AnnotationActivityService'
,
()
=>
{
let
fakePermissions
;
let
fakePostMessageJsonRpc
;
let
fakeRpcSettings
;
...
...
@@ -10,8 +11,12 @@ describe('AnnotationActivityService', () => {
let
fakeSettings
;
beforeEach
(()
=>
{
fakePermissions
=
{
isShared
:
sinon
.
stub
().
returns
(
true
),
};
fakePostMessageJsonRpc
=
{
call
:
sinon
.
stub
(),
notify
:
sinon
.
stub
(),
};
fakeRpcSettings
=
{
...
...
@@ -30,6 +35,7 @@ describe('AnnotationActivityService', () => {
};
$imports
.
$mock
({
'../helpers/permissions'
:
fakePermissions
,
'../util/postmessage-json-rpc'
:
fakePostMessageJsonRpc
,
});
});
...
...
@@ -45,9 +51,9 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'update'
,
annotation
);
assert
.
calledOnce
(
fakePostMessageJsonRpc
.
call
);
assert
.
calledOnce
(
fakePostMessageJsonRpc
.
notify
);
assert
.
calledWith
(
fakePostMessageJsonRpc
.
call
,
fakePostMessageJsonRpc
.
notify
,
window
,
'https://www.example.com'
,
'remoteMethod'
...
...
@@ -60,8 +66,8 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'update'
,
annotation
);
const
eventType
=
fakePostMessageJsonRpc
.
call
.
getCall
(
0
).
args
[
3
][
0
];
const
data
=
fakePostMessageJsonRpc
.
call
.
getCall
(
0
).
args
[
3
][
1
];
const
eventType
=
fakePostMessageJsonRpc
.
notify
.
getCall
(
0
).
args
[
3
][
0
];
const
data
=
fakePostMessageJsonRpc
.
notify
.
getCall
(
0
).
args
[
3
][
1
];
assert
.
equal
(
eventType
,
'update'
);
assert
.
deepEqual
(
data
,
{
...
...
@@ -70,6 +76,7 @@ describe('AnnotationActivityService', () => {
date
:
new
Date
(
annotation
.
updated
).
toISOString
(),
annotation
:
{
id
:
annotation
.
id
,
isShared
:
true
,
},
});
});
...
...
@@ -82,7 +89,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'update'
,
annotation
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
call
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
notify
);
});
it
(
'does not invoke remote activity method if reportActivity not configured'
,
()
=>
{
...
...
@@ -91,7 +98,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'update'
,
annotation
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
call
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
notify
);
});
it
(
'does not invoke remote activity method if annotation event type is not one of configured events'
,
()
=>
{
...
...
@@ -100,7 +107,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'delete'
,
annotation
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
call
);
assert
.
notCalled
(
fakePostMessageJsonRpc
.
notify
);
});
it
(
'uses annotation created date as `date` for `create` events'
,
()
=>
{
...
...
@@ -109,7 +116,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'create'
,
annotation
);
const
data
=
fakePostMessageJsonRpc
.
call
.
getCall
(
0
).
args
[
3
][
1
];
const
data
=
fakePostMessageJsonRpc
.
notify
.
getCall
(
0
).
args
[
3
][
1
];
assert
.
equal
(
data
.
date
,
new
Date
(
annotation
.
created
).
toISOString
());
});
...
...
@@ -120,7 +127,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'update'
,
annotation
);
const
data
=
fakePostMessageJsonRpc
.
call
.
getCall
(
0
).
args
[
3
][
1
];
const
data
=
fakePostMessageJsonRpc
.
notify
.
getCall
(
0
).
args
[
3
][
1
];
assert
.
equal
(
data
.
date
,
new
Date
(
annotation
.
updated
).
toISOString
());
});
...
...
@@ -145,7 +152,7 @@ describe('AnnotationActivityService', () => {
svc
.
reportActivity
(
'delete'
,
annotation
);
const
data
=
fakePostMessageJsonRpc
.
call
.
getCall
(
0
).
args
[
3
][
1
];
const
data
=
fakePostMessageJsonRpc
.
notify
.
getCall
(
0
).
args
[
3
][
1
];
assert
.
equal
(
data
.
date
,
now
.
toISOString
());
});
});
...
...
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