Fix: Editing a poll will silently change it to a closed poll (#9809)
* add failing test case * dont reset poll disclosure on editing
This commit is contained in:
parent
8660293424
commit
9a8545bf34
2 changed files with 20 additions and 1 deletions
|
@ -138,7 +138,7 @@ export default class PollCreateDialog extends ScrollableBaseModal<IProps, IState
|
||||||
const pollStart = PollStartEvent.from(
|
const pollStart = PollStartEvent.from(
|
||||||
this.state.question.trim(),
|
this.state.question.trim(),
|
||||||
this.state.options.map((a) => a.trim()).filter((a) => !!a),
|
this.state.options.map((a) => a.trim()).filter((a) => !!a),
|
||||||
this.state.kind,
|
this.state.kind.name,
|
||||||
).serialize();
|
).serialize();
|
||||||
|
|
||||||
if (!this.props.editingMxEvent) {
|
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 {
|
function createRoom(): Room {
|
||||||
|
|
Loading…
Reference in a new issue