mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
test(chat): coverage for new sunsets
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
createAndPopulateGroup,
|
createAndPopulateGroup,
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration/v3';
|
} from '../../../../helpers/api-integration/v3';
|
||||||
|
import { model as Group } from '../../../../../website/server/models/group';
|
||||||
|
|
||||||
describe('GET /groups/:groupId/chat', () => {
|
describe('GET /groups/:groupId/chat', () => {
|
||||||
let user;
|
let user;
|
||||||
@@ -37,4 +38,34 @@ describe('GET /groups/:groupId/chat', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('public Guild', () => {
|
||||||
|
let group;
|
||||||
|
before(async () => {
|
||||||
|
({ group } = await createAndPopulateGroup({
|
||||||
|
groupDetails: {
|
||||||
|
name: 'test group',
|
||||||
|
type: 'guild',
|
||||||
|
privacy: 'private',
|
||||||
|
},
|
||||||
|
members: 1,
|
||||||
|
upgradeToGroupPlan: true,
|
||||||
|
chat: [
|
||||||
|
'Hello',
|
||||||
|
'Welcome to the Guild',
|
||||||
|
],
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Creation API is shut down, we need to simulate an extant public group
|
||||||
|
await Group.updateOne({ _id: group._id }, { $set: { privacy: 'public' }, $unset: { 'purchased.plan': 1 }}).exec();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns error if user attempts to fetch a sunset Guild', async () => {
|
||||||
|
await expect(user.get(`/groups/${group._id}/chat`)).to.eventually.be.rejected.and.eql({
|
||||||
|
code: 400,
|
||||||
|
error: 'BadRequest',
|
||||||
|
message: t('featureRetired'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
createAndPopulateGroup,
|
createAndPopulateGroup,
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration/v3';
|
} from '../../../../helpers/api-integration/v3';
|
||||||
|
import { model as Group } from '../../../../../website/server/models/group';
|
||||||
|
|
||||||
describe('POST /chat/:chatId/like', () => {
|
describe('POST /chat/:chatId/like', () => {
|
||||||
let user;
|
let user;
|
||||||
@@ -111,4 +112,18 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
message: t('groupNotFound'),
|
message: t('groupNotFound'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not like a message that belongs to a sunset public group', async () => {
|
||||||
|
const message = await anotherUser.post(`/groups/${groupWithChat._id}/chat`, { message: testMessage });
|
||||||
|
|
||||||
|
// Creation API is shut down, we need to simulate an extant public group
|
||||||
|
await Group.updateOne({ _id: groupWithChat._id }, { $set: { privacy: 'public' }, $unset: { 'purchased.plan': 1 }}).exec();
|
||||||
|
|
||||||
|
await expect(user.post(`/groups/${groupWithChat._id}/chat/${message.message.id}/like`))
|
||||||
|
.to.eventually.be.rejected.and.eql({
|
||||||
|
code: 400,
|
||||||
|
error: 'BadRequest',
|
||||||
|
message: t('featureRetired'),
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user