Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 26f3d10

Browse files
Johennesturt2live
andauthored
Set relations helper when creating event tile context menu (#9253)
* Set relations helper when creating event tile context menu Fixes element-hq/element-web#22018 Signed-off-by: Johannes Marbach <[email protected]> * Add e2e tests * Use idiomatic test names Signed-off-by: Johannes Marbach <[email protected]> Co-authored-by: Travis Ralston <[email protected]>
1 parent 2cf8a9a commit 26f3d10

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

cypress/e2e/polls/polls.spec.ts

+87-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe("Polls", () => {
9494
cy.stopSynapse(synapse);
9595
});
9696

97-
it("Open polls can be created and voted in", () => {
97+
it("should be creatable and votable", () => {
9898
let bot: MatrixClient;
9999
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
100100
bot = _bot;
@@ -159,7 +159,92 @@ describe("Polls", () => {
159159
});
160160
});
161161

162-
it("displays polls correctly in thread panel", () => {
162+
it("should be editable from context menu if no votes have been cast", () => {
163+
let bot: MatrixClient;
164+
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
165+
bot = _bot;
166+
});
167+
168+
let roomId: string;
169+
cy.createRoom({}).then(_roomId => {
170+
roomId = _roomId;
171+
cy.inviteUser(roomId, bot.getUserId());
172+
cy.visit('/#/room/' + roomId);
173+
});
174+
175+
cy.openMessageComposerOptions().within(() => {
176+
cy.get('[aria-label="Poll"]').click();
177+
});
178+
179+
const pollParams = {
180+
title: 'Does the polls feature work?',
181+
options: ['Yes', 'No', 'Maybe'],
182+
};
183+
createPoll(pollParams);
184+
185+
// Wait for message to send, get its ID and save as @pollId
186+
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", pollParams.title)
187+
.invoke("attr", "data-scroll-tokens").as("pollId");
188+
189+
cy.get<string>("@pollId").then(pollId => {
190+
// Open context menu
191+
getPollTile(pollId).rightclick();
192+
193+
// Select edit item
194+
cy.get('.mx_ContextualMenu').within(() => {
195+
cy.get('[aria-label="Edit"]').click();
196+
});
197+
198+
// Expect poll editing dialog
199+
cy.get('.mx_PollCreateDialog');
200+
});
201+
});
202+
203+
it("should not be editable from context menu if votes have been cast", () => {
204+
let bot: MatrixClient;
205+
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
206+
bot = _bot;
207+
});
208+
209+
let roomId: string;
210+
cy.createRoom({}).then(_roomId => {
211+
roomId = _roomId;
212+
cy.inviteUser(roomId, bot.getUserId());
213+
cy.visit('/#/room/' + roomId);
214+
});
215+
216+
cy.openMessageComposerOptions().within(() => {
217+
cy.get('[aria-label="Poll"]').click();
218+
});
219+
220+
const pollParams = {
221+
title: 'Does the polls feature work?',
222+
options: ['Yes', 'No', 'Maybe'],
223+
};
224+
createPoll(pollParams);
225+
226+
// Wait for message to send, get its ID and save as @pollId
227+
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", pollParams.title)
228+
.invoke("attr", "data-scroll-tokens").as("pollId");
229+
230+
cy.get<string>("@pollId").then(pollId => {
231+
// Bot votes 'Maybe' in the poll
232+
botVoteForOption(bot, roomId, pollId, pollParams.options[2]);
233+
234+
// Open context menu
235+
getPollTile(pollId).rightclick();
236+
237+
// Select edit item
238+
cy.get('.mx_ContextualMenu').within(() => {
239+
cy.get('[aria-label="Edit"]').click();
240+
});
241+
242+
// Expect error dialog
243+
cy.get('.mx_ErrorDialog');
244+
});
245+
});
246+
247+
it("should be displayed correctly in thread panel", () => {
163248
let botBob: MatrixClient;
164249
let botCharlie: MatrixClient;
165250
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {

src/components/views/rooms/EventTile.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ export class UnwrappedEventTile extends React.Component<IProps, IState> {
932932
rightClick={true}
933933
reactions={this.state.reactions}
934934
link={this.state.contextMenu.link}
935+
getRelationsForEvent={this.props.getRelationsForEvent}
935936
/>
936937
);
937938
}

0 commit comments

Comments
 (0)