mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Move Chat to Model (#9703)
* Began moving group chat to separate model * Fixed lint issue * Updated delete chat with new model * Updated flag chat to support model * Updated like chat to use model * Fixed duplicate code and chat messages * Added note about concat chat * Updated clear flags to user new model * Updated more chat checks when loading get group * Fixed spell test and back save * Moved get chat to json method * Updated flagging with new chat model * Added missing await * Fixed chat user styles. Fixed spell group test * Added new model to quest chat and group plan chat * Removed extra timestamps. Added limit check for group plans * Updated tests * Synced id fields * Fixed id creation * Add meta and fixed tests * Fixed group quest accept test * Updated puppeteer * Added migration * Export vars * Updated comments
This commit is contained in:
committed by
Sabe Jones
parent
0ec1a91774
commit
7d7fe6047c
@@ -182,7 +182,7 @@ describe('Group Model', () => {
|
||||
await party.startQuest(questLeader);
|
||||
await party.save();
|
||||
|
||||
sendChatStub = sandbox.stub(Group.prototype, 'sendChat');
|
||||
sendChatStub = sandbox.spy(Group.prototype, 'sendChat');
|
||||
});
|
||||
|
||||
afterEach(() => sendChatStub.restore());
|
||||
@@ -378,7 +378,7 @@ describe('Group Model', () => {
|
||||
await party.startQuest(questLeader);
|
||||
await party.save();
|
||||
|
||||
sendChatStub = sandbox.stub(Group.prototype, 'sendChat');
|
||||
sendChatStub = sandbox.spy(Group.prototype, 'sendChat');
|
||||
});
|
||||
|
||||
afterEach(() => sendChatStub.restore());
|
||||
@@ -918,21 +918,8 @@ describe('Group Model', () => {
|
||||
sandbox.spy(User, 'update');
|
||||
});
|
||||
|
||||
it('puts message at top of chat array', () => {
|
||||
let oldMessage = {
|
||||
text: 'a message',
|
||||
};
|
||||
party.chat.push(oldMessage, oldMessage, oldMessage);
|
||||
|
||||
party.sendChat('a new message', {_id: 'user-id', profile: { name: 'user name' }});
|
||||
|
||||
expect(party.chat).to.have.a.lengthOf(4);
|
||||
expect(party.chat[0].text).to.eql('a new message');
|
||||
expect(party.chat[0].uuid).to.eql('user-id');
|
||||
});
|
||||
|
||||
it('formats message', () => {
|
||||
party.sendChat('a new message', {
|
||||
const chatMessage = party.sendChat('a new message', {
|
||||
_id: 'user-id',
|
||||
profile: { name: 'user name' },
|
||||
contributor: {
|
||||
@@ -947,11 +934,11 @@ describe('Group Model', () => {
|
||||
},
|
||||
});
|
||||
|
||||
let chat = party.chat[0];
|
||||
const chat = chatMessage;
|
||||
|
||||
expect(chat.text).to.eql('a new message');
|
||||
expect(validator.isUUID(chat.id)).to.eql(true);
|
||||
expect(chat.timestamp).to.be.a('number');
|
||||
expect(chat.timestamp).to.be.a('date');
|
||||
expect(chat.likes).to.eql({});
|
||||
expect(chat.flags).to.eql({});
|
||||
expect(chat.flagCount).to.eql(0);
|
||||
@@ -962,13 +949,11 @@ describe('Group Model', () => {
|
||||
});
|
||||
|
||||
it('formats message as system if no user is passed in', () => {
|
||||
party.sendChat('a system message');
|
||||
|
||||
let chat = party.chat[0];
|
||||
const chat = party.sendChat('a system message');
|
||||
|
||||
expect(chat.text).to.eql('a system message');
|
||||
expect(validator.isUUID(chat.id)).to.eql(true);
|
||||
expect(chat.timestamp).to.be.a('number');
|
||||
expect(chat.timestamp).to.be.a('date');
|
||||
expect(chat.likes).to.eql({});
|
||||
expect(chat.flags).to.eql({});
|
||||
expect(chat.flagCount).to.eql(0);
|
||||
|
||||
Reference in New Issue
Block a user