mirror of https://github.com/vector-im/riot-web
Fix: Editing a poll will silently change it to a closed poll (#9809)
* add failing test case * dont reset poll disclosure on editingt3chguy/dedup-icons-17oct
parent
8660293424
commit
9a8545bf34
|
@ -138,7 +138,7 @@ export default class PollCreateDialog extends ScrollableBaseModal<IProps, IState
|
|||
const pollStart = PollStartEvent.from(
|
||||
this.state.question.trim(),
|
||||
this.state.options.map((a) => a.trim()).filter((a) => !!a),
|
||||
this.state.kind,
|
||||
this.state.kind.name,
|
||||
).serialize();
|
||||
|
||||
if (!this.props.editingMxEvent) {
|
||||
|
|
|
@ -252,6 +252,25 @@ describe("PollCreateDialog", () => {
|
|||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("retains poll disclosure type when editing", () => {
|
||||
const previousEvent: MatrixEvent = new MatrixEvent(
|
||||
PollStartEvent.from("Poll Q", ["Answer 1", "Answer 2"], M_POLL_KIND_DISCLOSED).serialize(),
|
||||
);
|
||||
previousEvent.event.event_id = "$prevEventId";
|
||||
|
||||
const dialog = mount(
|
||||
<PollCreateDialog room={createRoom()} onFinished={jest.fn()} editingMxEvent={previousEvent} />,
|
||||
);
|
||||
|
||||
changeValue(dialog, "Question or topic", "Poll Q updated");
|
||||
dialog.find("button").simulate("click");
|
||||
|
||||
const [, , eventType, sentEventContent] = mockClient.sendEvent.mock.calls[0];
|
||||
expect(M_POLL_START.matches(eventType)).toBeTruthy();
|
||||
// didnt change
|
||||
expect(sentEventContent["m.new_content"][M_POLL_START.name].kind).toEqual(M_POLL_KIND_DISCLOSED.name);
|
||||
});
|
||||
});
|
||||
|
||||
function createRoom(): Room {
|
||||
|
|
Loading…
Reference in New Issue