test(public/notes): compare permission lists as Set

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2023-02-12 21:20:59 +01:00 committed by Yannick Bungers
parent 5fc6265b77
commit 15a691b364

View file

@ -540,17 +540,19 @@ describe('Notes', () => {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect(200); .expect(200);
expect(permissions.body.owner).toBe('testuser1'); expect(permissions.body.owner).toBe('testuser1');
expect(permissions.body.sharedToUsers).toEqual([]); expect(new Set(permissions.body.sharedToUsers)).toEqual(new Set([]));
expect(permissions.body.sharedToGroups).toEqual([ expect(new Set(permissions.body.sharedToGroups)).toEqual(
{ new Set([
groupName: '_EVERYONE', {
canEdit: false, groupName: '_EVERYONE',
}, canEdit: false,
{ },
canEdit: true, {
groupName: '_LOGGED_IN', canEdit: true,
}, groupName: '_LOGGED_IN',
]); },
]),
);
}); });
it('can be updated', async function () { it('can be updated', async function () {
// add permission for testuser2 // add permission for testuser2
@ -568,19 +570,21 @@ describe('Notes', () => {
.set('Authorization', `Bearer ${testSetup.authTokens[0].secret}`) .set('Authorization', `Bearer ${testSetup.authTokens[0].secret}`)
.expect(200); .expect(200);
expect(permissions.body.owner).toBe('testuser1'); expect(permissions.body.owner).toBe('testuser1');
expect(permissions.body.sharedToUsers).toEqual([ expect(new Set(permissions.body.sharedToUsers)).toEqual(
{ username: 'testuser2', canEdit: true }, new Set([{ username: 'testuser2', canEdit: true }]),
]); );
expect(permissions.body.sharedToGroups).toEqual([ expect(new Set(permissions.body.sharedToGroups)).toEqual(
{ new Set([
groupName: '_EVERYONE', {
canEdit: false, groupName: '_EVERYONE',
}, canEdit: false,
{ },
canEdit: true, {
groupName: '_LOGGED_IN', canEdit: true,
}, groupName: '_LOGGED_IN',
]); },
]),
);
// add permission for everyone // add permission for everyone
await request(testSetup.app.getHttpServer()) await request(testSetup.app.getHttpServer())
@ -600,13 +604,15 @@ describe('Notes', () => {
expect(permissions.body.sharedToUsers).toEqual([ expect(permissions.body.sharedToUsers).toEqual([
{ username: 'testuser2', canEdit: true }, { username: 'testuser2', canEdit: true },
]); ]);
expect(permissions.body.sharedToGroups).toEqual([ expect(new Set(permissions.body.sharedToGroups)).toEqual(
{ groupName: '_EVERYONE', canEdit: true }, new Set([
{ { groupName: '_EVERYONE', canEdit: true },
canEdit: true, {
groupName: '_LOGGED_IN', canEdit: true,
}, groupName: '_LOGGED_IN',
]); },
]),
);
}); });
}); });
}); });