Merge pull request #13325 from overleaf/jpa-real-time-check

[real-time] add check for project admin

GitOrigin-RevId: 1677b78cf7f263fc98ca539e26e21553d0ea55bd
This commit is contained in:
Jakob Ackermann
2023-06-05 11:18:00 +01:00
committed by Copybot
parent 14e014c667
commit 6d4d643fd9
4 changed files with 58 additions and 2 deletions

View File

@@ -66,6 +66,7 @@ describe('joinProject', function () {
it('should return the project', function () {
return this.project.should.deep.equal({
name: 'Test Project',
owner: { _id: this.user_id },
})
})

View File

@@ -234,6 +234,7 @@ describe('receiveEditorEvent', function () {
'userRemovedFromProject',
'project:publicAccessLevel:changed',
'project:access:revoked',
'project:tokens:changed',
]
for (const eventName of eventNames) {
@@ -273,6 +274,32 @@ describe('receiveEditorEvent', function () {
}
})
describe('event: project:tokens:changed', function () {
beforeEach(function (done) {
rclient.publish(
'editor-events',
JSON.stringify({
room_id: this.project_id,
message: 'project:tokens:changed',
payload: [{ tokens: 'TOKENS' }],
})
)
setTimeout(done, 200)
})
it('should send the event to the owner', function () {
expect(this.owner_updates).to.deep.equal([
{ 'project:tokens:changed': { tokens: 'TOKENS' } },
])
})
it('should not send the event to the other clients', function () {
expect(this.user_a_updates).to.deep.equal([])
expect(this.user_b_updates).to.deep.equal([])
expect(this.user_c_updates).to.deep.equal([])
})
})
describe('event: project:publicAccessLevel:changed, set to private', function () {
beforeEach(function (done) {
/**

View File

@@ -33,6 +33,11 @@ module.exports = MockWebServer = {
MockWebServer.privileges[projectId][userId] ||
MockWebServer.privileges[projectId]['anonymous-user']
const userMetadata = MockWebServer.userMetadata[projectId]?.[userId]
if (privilegeLevel === 'owner') {
project.owner = { _id: userId }
} else {
project.owner = { _id: '404404404404404404404404' }
}
return callback(null, project, privilegeLevel, userMetadata)
},