Frontend support and adjustments of current banned words blocking code to support new implementation (Fixes #12405) (#12496)

* Added the "Allow banned words" checkbox to create/update guild forms

Added the "Allow banned words" checkbox to guild create/update forms which are only visible to Admins

* Updated create/update group API to include bannedWordsAllowed property

Added logic to set bannedWordsAllowed depending on conditions

* Updated word banning logic to use bannedWordsAllowed guild value instead

Updated word banning logic to use bannedWordsAllowed guild value and deleted hardcoded guild file & import

* Updated banned words test

* Pull Request amends

Removed the setting of bannedWordsAllowed during group creation
Added v-once to elements
Updated existing test and added tests related to bannedWordsAllowed functionality

* Small amend

* Small amend

Removed leftover code that was left during testing
This commit is contained in:
Scott
2020-09-11 09:29:30 +01:00
committed by GitHub
parent c89f66e4b8
commit 5716b4eb72
7 changed files with 114 additions and 151 deletions

View File

@@ -79,4 +79,56 @@ describe('PUT /group', () => {
expect(updatedGroup.leader.profile.name).to.eql(nonLeader.profile.name);
expect(updatedGroup.name).to.equal(groupUpdatedName);
});
it('allows for an admin to update the bannedWordsAllow property for an existing guild', async () => {
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'public guild',
type: 'guild',
privacy: 'public',
},
});
const updateGroupDetails = {
id: group._id,
name: 'public guild',
type: 'guild',
privacy: 'public',
bannedWordsAllowed: true,
};
// Make guild leader into admin
await groupLeader.post('/debug/make-admin');
await groupLeader.sync();
// Update the bannedWordsAllowed property for the group
const response = await groupLeader.put(`/groups/${group._id}`, updateGroupDetails);
expect(groupLeader.contributor.admin).to.eql(true);
expect(response.bannedWordsAllowed).to.eql(true);
});
it('does not allow for a non-admin to update the bannedWordsAllow property for an existing guild', async () => {
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'public guild',
type: 'guild',
privacy: 'public',
},
});
const updateGroupDetails = {
id: group._id,
name: 'public guild',
type: 'guild',
privacy: 'public',
bannedWordsAllowed: true,
};
// Update the bannedWordsAllowed property for the group
const response = await groupLeader.put(`/groups/${group._id}`, updateGroupDetails);
expect(groupLeader.contributor.admin).to.eql(undefined);
expect(response.bannedWordsAllowed).to.eql(undefined);
});
});