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

Use Cypress Testing Library - composer.spec.ts #10511

Merged
merged 2 commits into from
Apr 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions cypress/e2e/composer/composer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,39 @@ describe("Composer", () => {

it("sends a message when you click send or press Enter", () => {
// Type a message
cy.get("div[contenteditable=true]").type("my message 0");
cy.findTextbox("Send a message…").type("my message 0");
// It has not been sent yet
cy.contains(".mx_EventTile_body", "my message 0").should("not.exist");

// Click send
cy.get('div[aria-label="Send message"]').click();
cy.findButton("Send message").click();
// It has been sent
cy.contains(".mx_EventTile_body", "my message 0");

// Type another and press Enter afterwards
cy.get("div[contenteditable=true]").type("my message 1{enter}");
cy.findTextbox("Send a message…").type("my message 1{enter}");
// It was sent
cy.contains(".mx_EventTile_body", "my message 1");
});

it("can write formatted text", () => {
cy.get("div[contenteditable=true]").type("my bold{ctrl+b} message");
cy.get('div[aria-label="Send message"]').click();
cy.findTextbox("Send a message…").type("my bold{ctrl+b} message");
cy.findButton("Send message").click();
// Note: both "bold" and "message" are bold, which is probably surprising
cy.contains(".mx_EventTile_body strong", "bold message");
});

it("should allow user to input emoji via graphical picker", () => {
cy.getComposer(false).within(() => {
cy.get('[aria-label="Emoji"]').click();
cy.findButton("Emoji").click();
});

cy.get('[data-testid="mx_EmojiPicker"]').within(() => {
cy.contains(".mx_EmojiPicker_item", "😇").click();
});

cy.get(".mx_ContextualMenu_background").click(); // Close emoji picker
cy.get("div[contenteditable=true]").type("{enter}"); // Send message
cy.findTextbox("Send a message…").type("{enter}"); // Send message

cy.contains(".mx_EventTile_body", "😇");
});
Expand All @@ -86,12 +86,12 @@ describe("Composer", () => {

it("only sends when you press Ctrl+Enter", () => {
// Type a message and press Enter
cy.get("div[contenteditable=true]").type("my message 3{enter}");
cy.findTextbox("Send a message…").type("my message 3{enter}");
// It has not been sent yet
cy.contains(".mx_EventTile_body", "my message 3").should("not.exist");

// Press Ctrl+Enter
cy.get("div[contenteditable=true]").type("{ctrl+enter}");
cy.findTextbox("Send a message…").type("{ctrl+enter}");
// It was sent
cy.contains(".mx_EventTile_body", "my message 3");
});
Expand All @@ -114,7 +114,7 @@ describe("Composer", () => {
cy.contains(".mx_EventTile_body", "my message 0").should("not.exist");

// Click send
cy.get('div[aria-label="Send message"]').click();
cy.findButton("Send message").click();
// It has been sent
cy.contains(".mx_EventTile_body", "my message 0");

Expand Down Expand Up @@ -143,7 +143,7 @@ describe("Composer", () => {

it("can write formatted text", () => {
cy.get("div[contenteditable=true]").type("my {ctrl+b}bold{ctrl+b} message");
cy.get('div[aria-label="Send message"]').click();
cy.findButton("Send message").click();
cy.contains(".mx_EventTile_body strong", "bold");
});

Expand Down Expand Up @@ -172,13 +172,13 @@ describe("Composer", () => {
cy.get("div[contenteditable=true]").type("my message 0{selectAll}");

// Open link modal
cy.get('button[aria-label="Link"]').click();
cy.findButton("Link").click();
// Fill the link field
cy.get('input[label="Link"]').type("https://matrix.org/");
cy.findTextbox("Link").type("https://matrix.org/");
// Click on save
cy.get('button[type="submit"]').click();
cy.findButton("Save").click();
// Send the message
cy.get('div[aria-label="Send message"]').click();
cy.findButton("Send message").click();

// It was sent
cy.contains(".mx_EventTile_body a", "my message 0");
Expand Down