test(server/rr): added prelim tests on read receipts

This commit is contained in:
Dimitrie Stefanescu
2021-10-25 10:17:01 +01:00
parent 1d40ad755f
commit cac9eaf073
4 changed files with 40 additions and 5 deletions
@@ -9,7 +9,6 @@ const {
createCommitByBranchName,
createCommitByBranchId,
updateCommit,
//receiveCommit,
deleteCommit,
getCommitById,
getCommitsByBranchId,
@@ -81,7 +81,7 @@ extend type Mutation {
@hasScope(scope: "streams:write")
commitReceive(input: CommitReceivedInput!): Boolean!
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
@hasScope(scope: "streams:read")
commitDelete(commit: CommitDeleteInput!): Boolean!
@hasRole(role: "server:user")
@hasScope(scope: "streams:write")
@@ -359,6 +359,44 @@ describe( 'GraphQL API Core @core-api', ( ) => {
expect( res2.body.errors ).to.exist
} )
it( 'Should create a read receipt', async () => {
let res = await sendRequest( userA.token, { query: 'mutation($input: CommitReceivedInput!) { commitReceive(input: $input) }' , variables: {
input: {
streamId: ts1,
commitId: c1.id,
sourceApplication: 'tests',
message: 'Irrelevant!'
}
}
} )
expect( res ).to.be.json
expect( res.body.errors ).to.not.exist
expect( res.body.data.commitReceive ).to.equal( true )
let res2 = await sendRequest( userB.token, { query: 'mutation($input: CommitReceivedInput!) { commitReceive(input: $input) }' , variables: {
input: {
streamId: ts1,
commitId: c1.id,
sourceApplication: 'tests',
message: 'Irrelevant!'
}
}
} )
console.log( res2.body.errors )
let res3 = await sendRequest( null, { query: 'mutation($input: CommitReceivedInput!) { commitReceive(input: $input) }' , variables: {
input: {
streamId: ts1,
commitId: c1.id,
sourceApplication: 'tests',
message: 'Irrelevant!'
}
}
} )
console.log( res3.body.errors )
} )
it( 'Should delete a commit', async ( ) => {
let payload = { streamId: ts1, id: c2.id }
@@ -240,17 +240,15 @@ describe( 'Actors & Tokens @user-services', () => {
let myFirstToken
let pregeneratedToken
let revokedToken
let someOtherToken
let expireSoonToken
before( async () => {
pregeneratedToken = await createPersonalAccessToken( myTestActor.id, 'Whabadub', [ 'streams:read', 'streams:write', 'profile:read', 'users:email' ] )
revokedToken = await createPersonalAccessToken( myTestActor.id, 'Mr. Revoked', [ 'streams:read' ] )
someOtherToken = await createPersonalAccessToken( otherUser.id, 'Hello World', [ 'streams:write' ] )
expireSoonToken = await createPersonalAccessToken( myTestActor.id, 'Mayfly', [ 'streams:read' ], 1 ) // 1ms lifespan
} )
it( 'Should create an personal api token', async () => {
it( 'Should create a personal api token', async () => {
let scopes = [ 'streams:write', 'profile:read' ]
let name = 'My Test Token'