Add Reply in thread
button to the right-click message context-menu (#9004)
This commit is contained in:
parent
dfa844a035
commit
787ace9dc5
13 changed files with 236 additions and 56 deletions
|
@ -40,6 +40,7 @@ import { makeBeaconEvent, makeBeaconInfoEvent, makeLocationEvent, stubClient } f
|
|||
import dispatcher from '../../../../src/dispatcher/dispatcher';
|
||||
import SettingsStore from '../../../../src/settings/SettingsStore';
|
||||
import { ReadPinsEventId } from '../../../../src/components/views/right_panel/types';
|
||||
import { Action } from "../../../../src/dispatcher/actions";
|
||||
|
||||
jest.mock("../../../../src/utils/strings", () => ({
|
||||
copyPlaintext: jest.fn(),
|
||||
|
@ -50,6 +51,7 @@ jest.mock("../../../../src/utils/EventUtils", () => ({
|
|||
...jest.requireActual("../../../../src/utils/EventUtils"),
|
||||
canEditContent: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../../../src/dispatcher/dispatcher');
|
||||
|
||||
const roomId = 'roomid';
|
||||
|
||||
|
@ -461,6 +463,29 @@ describe('MessageContextMenu', () => {
|
|||
const reactButton = menu.find('div[aria-label="View in room"]');
|
||||
expect(reactButton).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('creates a new thread on reply in thread click', () => {
|
||||
const eventContent = MessageEvent.from("hello");
|
||||
const mxEvent = new MatrixEvent(eventContent.serialize());
|
||||
|
||||
Thread.hasServerSideSupport = true;
|
||||
const context = {
|
||||
canSendMessages: true,
|
||||
};
|
||||
jest.spyOn(SettingsStore, 'getValue').mockReturnValue(true);
|
||||
|
||||
const menu = createRightClickMenu(mxEvent, context);
|
||||
|
||||
const replyInThreadButton = menu.find('div[aria-label="Reply in thread"]');
|
||||
expect(replyInThreadButton).toHaveLength(1);
|
||||
replyInThreadButton.simulate("click");
|
||||
|
||||
expect(dispatcher.dispatch).toHaveBeenCalledWith({
|
||||
action: Action.ShowThread,
|
||||
rootEvent: mxEvent,
|
||||
push: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -471,6 +496,10 @@ function createRightClickMenuWithContent(
|
|||
return createMenuWithContent(eventContent, { rightClick: true }, context);
|
||||
}
|
||||
|
||||
function createRightClickMenu(mxEvent: MatrixEvent, context?: Partial<IRoomState>): ReactWrapper {
|
||||
return createMenu(mxEvent, { rightClick: true }, context);
|
||||
}
|
||||
|
||||
function createMenuWithContent(
|
||||
eventContent: ExtensibleEvent,
|
||||
props?: Partial<React.ComponentProps<typeof MessageContextMenu>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue