HH-569: guard replayed frontend realtime messages (#144)
* fix(HH-569): guard replayed realtime messages * fix(HH-569): gate dashboard message side effects --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -82,6 +82,38 @@ describe('#actions', () => {
|
||||
message_type: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it('ignores an older realtime update', async () => {
|
||||
const data = {
|
||||
id: 1,
|
||||
updated_at: '2026-08-24T01:00:00Z',
|
||||
content_attributes: {},
|
||||
};
|
||||
const state = {
|
||||
conversations: {
|
||||
1: { id: 1, updated_at: '2026-08-24T02:00:00Z' },
|
||||
},
|
||||
};
|
||||
|
||||
const result = await actions.addOrUpdateMessage({ commit, state }, data);
|
||||
|
||||
expect(result).toEqual({ applied: false, isNew: false });
|
||||
expect(commit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ignores a replayed message with the same id and version', async () => {
|
||||
const data = {
|
||||
id: 1,
|
||||
updated_at: '2026-08-24T02:00:00Z',
|
||||
content_attributes: {},
|
||||
};
|
||||
const state = { conversations: { 1: data } };
|
||||
|
||||
const result = await actions.addOrUpdateMessage({ commit, state }, data);
|
||||
|
||||
expect(result).toEqual({ applied: false, isNew: false });
|
||||
expect(commit).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toggleAgentTyping', () => {
|
||||
|
||||
Reference in New Issue
Block a user