bugfix: fix in-reply-to previews not disappearing when swapping rooms (#9278)

* bugfix: fix in-reply-to previews not disappearing when swapping rooms

This was caused by the fix for another issue:
  - https://github.com/vector-im/element-web/issues/21462

Both bugs are now fixed with cypress regression tests.

* Linting

* Ensure the reply-to reappears when you click back

* Add jest test for replyTo in RVS

* Linting
This commit is contained in:
kegsay 2022-09-15 13:09:16 +01:00 committed by GitHub
parent 8d9e5237fd
commit a3133fa907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 2 deletions

View file

@ -22,6 +22,7 @@ import * as testUtils from '../test-utils';
import { flushPromises, getMockClientWithEventEmitter } from '../test-utils';
import SettingsStore from '../../src/settings/SettingsStore';
import { SlidingSyncManager } from '../../src/SlidingSyncManager';
import { TimelineRenderingType } from '../../src/contexts/RoomContext';
const dispatch = testUtils.getDispatchForStore(RoomViewStore.instance);
@ -88,6 +89,21 @@ describe('RoomViewStore', function() {
expect(mockClient.joinRoom).toHaveBeenCalledWith(alias, { viaServers: [] });
});
it('remembers the event being replied to when swapping rooms', async () => {
dispatch({ action: Action.ViewRoom, room_id: '!randomcharacters:aser.ver' });
await flushPromises();
const replyToEvent = {
getRoomId: () => '!randomcharacters:aser.ver',
};
dispatch({ action: 'reply_to_event', event: replyToEvent, context: TimelineRenderingType.Room });
await flushPromises();
expect(RoomViewStore.instance.getQuotingEvent()).toEqual(replyToEvent);
// view the same room, should remember the event.
dispatch({ action: Action.ViewRoom, room_id: '!randomcharacters:aser.ver' });
await flushPromises();
expect(RoomViewStore.instance.getQuotingEvent()).toEqual(replyToEvent);
});
describe('Sliding Sync', function() {
beforeEach(() => {
jest.spyOn(SettingsStore, 'getValue').mockImplementation((settingName, roomId, value) => {