Add cy.viewRoomById
command (#11317)
... and use it to fix a racy composer test. Fixes https://github.com/vector-im/element-web/issues/25527
This commit is contained in:
parent
c57a4cb090
commit
a47ee92094
2 changed files with 28 additions and 18 deletions
|
@ -36,10 +36,8 @@ describe("Composer", () => {
|
||||||
|
|
||||||
describe("CIDER", () => {
|
describe("CIDER", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.initTestUser(homeserver, "Janet").then(() => {
|
cy.initTestUser(homeserver, "Janet");
|
||||||
cy.createRoom({ name: "Composing Room" });
|
cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId));
|
||||||
});
|
|
||||||
cy.viewRoomByName("Composing Room");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sends a message when you click send or press Enter", () => {
|
it("sends a message when you click send or press Enter", () => {
|
||||||
|
@ -113,10 +111,8 @@ describe("Composer", () => {
|
||||||
describe("Rich text editor", () => {
|
describe("Rich text editor", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.enableLabsFeature("feature_wysiwyg_composer");
|
cy.enableLabsFeature("feature_wysiwyg_composer");
|
||||||
cy.initTestUser(homeserver, "Janet").then(() => {
|
cy.initTestUser(homeserver, "Janet");
|
||||||
cy.createRoom({ name: "Composing Room" });
|
cy.createRoom({ name: "Composing Room" }).then((roomId) => cy.viewRoomById(roomId));
|
||||||
});
|
|
||||||
cy.viewRoomByName("Composing Room");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Commands", () => {
|
describe("Commands", () => {
|
||||||
|
@ -197,15 +193,16 @@ describe("Composer", () => {
|
||||||
bobClient = bob;
|
bobClient = bob;
|
||||||
});
|
});
|
||||||
// create DM with bob
|
// create DM with bob
|
||||||
cy.getClient().then(async (cli) => {
|
cy.getClient()
|
||||||
|
.then(async (cli) => {
|
||||||
const bobRoom = await cli.createRoom({ is_direct: true });
|
const bobRoom = await cli.createRoom({ is_direct: true });
|
||||||
await cli.invite(bobRoom.room_id, bobClient.getUserId());
|
await cli.invite(bobRoom.room_id, bobClient.getUserId());
|
||||||
await cli.setAccountData("m.direct" as EventType, {
|
await cli.setAccountData("m.direct" as EventType, {
|
||||||
[bobClient.getUserId()]: [bobRoom.room_id],
|
[bobClient.getUserId()]: [bobRoom.room_id],
|
||||||
});
|
});
|
||||||
});
|
return bobRoom.room_id;
|
||||||
|
})
|
||||||
cy.viewRoomByName("Bob");
|
.then((bobRoomId) => cy.viewRoomById(bobRoomId));
|
||||||
|
|
||||||
// Select plain text mode after composer is ready
|
// Select plain text mode after composer is ready
|
||||||
cy.get("div[contenteditable=true]").should("exist");
|
cy.get("div[contenteditable=true]").should("exist");
|
||||||
|
|
|
@ -29,6 +29,15 @@ declare global {
|
||||||
*/
|
*/
|
||||||
viewRoomByName(name: string): Chainable<JQuery<HTMLElement>>;
|
viewRoomByName(name: string): Chainable<JQuery<HTMLElement>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the given room by room ID.
|
||||||
|
*
|
||||||
|
* This works by browsing to `/#/room/${id}`, so it will also work for room aliases.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
viewRoomById(id: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the space panel space button based on a name. The space
|
* Returns the space panel space button based on a name. The space
|
||||||
* must be visible in the space panel
|
* must be visible in the space panel
|
||||||
|
@ -57,6 +66,10 @@ Cypress.Commands.add("viewRoomByName", (name: string): Chainable<JQuery<HTMLElem
|
||||||
return cy.findByRole("treeitem", { name: name }).should("have.class", "mx_RoomTile").click();
|
return cy.findByRole("treeitem", { name: name }).should("have.class", "mx_RoomTile").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add("viewRoomById", (id: string): void => {
|
||||||
|
cy.visit(`/#/room/${id}`);
|
||||||
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("getSpacePanelButton", (name: string): Chainable<JQuery<HTMLElement>> => {
|
Cypress.Commands.add("getSpacePanelButton", (name: string): Chainable<JQuery<HTMLElement>> => {
|
||||||
return cy.findByRole("button", { name: name }).should("have.class", "mx_SpaceButton");
|
return cy.findByRole("button", { name: name }).should("have.class", "mx_SpaceButton");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue