mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 17:06:16 -04:00
GroupManager: Clean up any mappings when deleting a group
This commit is contained in:
parent
5b37a56197
commit
777d045246
3 changed files with 36 additions and 19 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const assert = require('assert').strict;
|
||||
const common = require('../../common');
|
||||
const db = require('../../../../node/db/DB');
|
||||
|
||||
let agent;
|
||||
const apiKey = common.apiKey;
|
||||
|
@ -89,13 +90,33 @@ describe(__filename, function () {
|
|||
});
|
||||
|
||||
it('createGroupIfNotExistsFor', async function () {
|
||||
await agent.get(`${endPoint('createGroupIfNotExistsFor')}&groupMapper=management`)
|
||||
const mapper = makeid();
|
||||
let groupId;
|
||||
await agent.get(`${endPoint('createGroupIfNotExistsFor')}&groupMapper=${mapper}`)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect((res) => {
|
||||
assert.equal(res.body.code, 0);
|
||||
assert(res.body.data.groupID);
|
||||
groupId = res.body.data.groupID;
|
||||
assert(groupId);
|
||||
});
|
||||
// Passing the same mapper should return the same group ID.
|
||||
await agent.get(`${endPoint('createGroupIfNotExistsFor')}&groupMapper=${mapper}`)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect((res) => {
|
||||
assert.equal(res.body.code, 0);
|
||||
assert.equal(res.body.data.groupID, groupId);
|
||||
});
|
||||
// Deleting the group should clean up the mapping.
|
||||
assert.equal(await db.get(`mapper2group:${mapper}`), groupId);
|
||||
await agent.get(`${endPoint('deleteGroup')}&groupID=${groupId}`)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect((res) => {
|
||||
assert.equal(res.body.code, 0);
|
||||
});
|
||||
assert(await db.get(`mapper2group:${mapper}`) == null);
|
||||
});
|
||||
|
||||
// Test coverage for https://github.com/ether/etherpad-lite/issues/4227
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue