mirror of https://github.com/vector-im/riot-web
Set relations helper when creating event tile context menu (#9253)
* Set relations helper when creating event tile context menu Fixes vector-im/element-web#22018 Signed-off-by: Johannes Marbach <johannesm@element.io> * Add e2e tests * Use idiomatic test names Signed-off-by: Johannes Marbach <johannesm@element.io> Co-authored-by: Travis Ralston <travisr@matrix.org>pull/28788/head^2
parent
2cf8a9a2f7
commit
26f3d107fd
|
@ -94,7 +94,7 @@ describe("Polls", () => {
|
||||||
cy.stopSynapse(synapse);
|
cy.stopSynapse(synapse);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Open polls can be created and voted in", () => {
|
it("should be creatable and votable", () => {
|
||||||
let bot: MatrixClient;
|
let bot: MatrixClient;
|
||||||
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
||||||
bot = _bot;
|
bot = _bot;
|
||||||
|
@ -159,7 +159,92 @@ describe("Polls", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("displays polls correctly in thread panel", () => {
|
it("should be editable from context menu if no votes have been cast", () => {
|
||||||
|
let bot: MatrixClient;
|
||||||
|
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
||||||
|
bot = _bot;
|
||||||
|
});
|
||||||
|
|
||||||
|
let roomId: string;
|
||||||
|
cy.createRoom({}).then(_roomId => {
|
||||||
|
roomId = _roomId;
|
||||||
|
cy.inviteUser(roomId, bot.getUserId());
|
||||||
|
cy.visit('/#/room/' + roomId);
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.openMessageComposerOptions().within(() => {
|
||||||
|
cy.get('[aria-label="Poll"]').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
const pollParams = {
|
||||||
|
title: 'Does the polls feature work?',
|
||||||
|
options: ['Yes', 'No', 'Maybe'],
|
||||||
|
};
|
||||||
|
createPoll(pollParams);
|
||||||
|
|
||||||
|
// Wait for message to send, get its ID and save as @pollId
|
||||||
|
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", pollParams.title)
|
||||||
|
.invoke("attr", "data-scroll-tokens").as("pollId");
|
||||||
|
|
||||||
|
cy.get<string>("@pollId").then(pollId => {
|
||||||
|
// Open context menu
|
||||||
|
getPollTile(pollId).rightclick();
|
||||||
|
|
||||||
|
// Select edit item
|
||||||
|
cy.get('.mx_ContextualMenu').within(() => {
|
||||||
|
cy.get('[aria-label="Edit"]').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Expect poll editing dialog
|
||||||
|
cy.get('.mx_PollCreateDialog');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not be editable from context menu if votes have been cast", () => {
|
||||||
|
let bot: MatrixClient;
|
||||||
|
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
||||||
|
bot = _bot;
|
||||||
|
});
|
||||||
|
|
||||||
|
let roomId: string;
|
||||||
|
cy.createRoom({}).then(_roomId => {
|
||||||
|
roomId = _roomId;
|
||||||
|
cy.inviteUser(roomId, bot.getUserId());
|
||||||
|
cy.visit('/#/room/' + roomId);
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.openMessageComposerOptions().within(() => {
|
||||||
|
cy.get('[aria-label="Poll"]').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
const pollParams = {
|
||||||
|
title: 'Does the polls feature work?',
|
||||||
|
options: ['Yes', 'No', 'Maybe'],
|
||||||
|
};
|
||||||
|
createPoll(pollParams);
|
||||||
|
|
||||||
|
// Wait for message to send, get its ID and save as @pollId
|
||||||
|
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", pollParams.title)
|
||||||
|
.invoke("attr", "data-scroll-tokens").as("pollId");
|
||||||
|
|
||||||
|
cy.get<string>("@pollId").then(pollId => {
|
||||||
|
// Bot votes 'Maybe' in the poll
|
||||||
|
botVoteForOption(bot, roomId, pollId, pollParams.options[2]);
|
||||||
|
|
||||||
|
// Open context menu
|
||||||
|
getPollTile(pollId).rightclick();
|
||||||
|
|
||||||
|
// Select edit item
|
||||||
|
cy.get('.mx_ContextualMenu').within(() => {
|
||||||
|
cy.get('[aria-label="Edit"]').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Expect error dialog
|
||||||
|
cy.get('.mx_ErrorDialog');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be displayed correctly in thread panel", () => {
|
||||||
let botBob: MatrixClient;
|
let botBob: MatrixClient;
|
||||||
let botCharlie: MatrixClient;
|
let botCharlie: MatrixClient;
|
||||||
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
cy.getBot(synapse, { displayName: "BotBob" }).then(_bot => {
|
||||||
|
|
|
@ -932,6 +932,7 @@ export class UnwrappedEventTile extends React.Component<IProps, IState> {
|
||||||
rightClick={true}
|
rightClick={true}
|
||||||
reactions={this.state.reactions}
|
reactions={this.state.reactions}
|
||||||
link={this.state.contextMenu.link}
|
link={this.state.contextMenu.link}
|
||||||
|
getRelationsForEvent={this.props.getRelationsForEvent}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue