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

Update audio-player.spec.ts to reflect the latest status #10537

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Changes from 3 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
47 changes: 24 additions & 23 deletions cypress/e2e/audio-player/audio-player.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Audio player", () => {

cy.get(".mx_Dialog").within(() => {
// Find and click primary "Upload" button
cy.get("[data-testid='dialog-primary-button']").findButton("Upload").click();
cy.findByRole("button", { name: "Upload" }).click();
});

// Wait until the file is sent
Expand Down Expand Up @@ -65,7 +65,7 @@ describe("Audio player", () => {
);

// Assert that the play button can be found and is visible
cy.findButton("Play").should("be.visible");
cy.findByRole("button", { name: "Play" }).should("be.visible");

if (monospace) {
// Assert that the monospace timer is visible
Expand Down Expand Up @@ -148,10 +148,9 @@ describe("Audio player", () => {
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room");

// Wait until configuration is finished
cy.contains(
".mx_RoomView_body .mx_GenericEventListSummary[data-layout='group'] .mx_GenericEventListSummary_summary",
"created and configured the room.",
).should("exist");
cy.get(".mx_GenericEventListSummary[data-layout='group'] .mx_GenericEventListSummary_summary").within(() => {
cy.findByText(TEST_USER + " created and configured the room.").should("exist");
});
});

afterEach(() => {
Expand Down Expand Up @@ -179,15 +178,15 @@ describe("Audio player", () => {
cy.openUserSettings("Appearance")
.get(".mx_ThemeChoicePanel")
.within(() => {
cy.get("[data-testid='theme-choice-panel-selectors']").within(() => {
cy.findByTestId("theme-choice-panel-selectors").within(() => {
// Enable light theme
cy.get(".mx_ThemeSelector_light").click();

// Assert that the radio button for light theme was checked
cy.get(".mx_StyledRadioButton_checked input[value='light']").should("exist");
});

cy.get("[data-testid='theme-choice-panel-highcontrast']").within(() => {
cy.findByTestId("theme-choice-panel-highcontrast").within(() => {
// Click the checkbox
cy.get("label .mx_Checkbox_background").click();
luixxiul marked this conversation as resolved.
Show resolved Hide resolved
});
Expand Down Expand Up @@ -218,24 +217,24 @@ describe("Audio player", () => {
cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist");

// Find and click "Play" button
cy.findButton("Play").click();
cy.findByRole("button", { name: "Play" }).click();

// Assert that "Pause" button can be found
cy.findButton("Pause").should("exist");
cy.findByRole("button", { name: "Pause" }).should("exist");

// Assert that the timer is reset when the audio file finished playing
cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist");

// Assert that "Play" button can be found
cy.findButton("Play").should("exist");
cy.findByRole("button", { name: "Play" }).should("exist");
});
});

it("should support downloading an audio file", () => {
uploadFile("cypress/fixtures/1sec.ogg");

// Find and click "Download" button on MessageActionBar
cy.get(".mx_EventTile_last").realHover().findButton("Download").click();
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Download" }).click();

// Assert that the file was downloaded
cy.readFile("cypress/downloads/1sec.ogg").should("exist");
Expand All @@ -248,7 +247,7 @@ describe("Audio player", () => {
cy.get(".mx_EventTile_last .mx_AudioPlayer_container").should("exist");

// Find and click "Reply" button on MessageActionBar
cy.get(".mx_EventTile_last").realHover().findButton("Reply").click();
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Reply" }).click();

// Reply to the player with another audio file
uploadFile("cypress/fixtures/1sec.ogg");
Expand Down Expand Up @@ -276,7 +275,7 @@ describe("Audio player", () => {

// Find and click "Reply" button
const clickButtonReply = () => {
cy.get(".mx_EventTile_last").realHover().findButton("Reply").click();
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Reply" }).click();
};

uploadFile("cypress/fixtures/upload-first.ogg");
Expand Down Expand Up @@ -305,7 +304,9 @@ describe("Audio player", () => {
cy.get(".mx_ReplyChain").should("have.length", 2);

// Assert that one line contains the user name
cy.contains(".mx_ReplyChain .mx_ReplyTile_sender", TEST_USER);
cy.get(".mx_ReplyChain .mx_ReplyTile_sender").within(() => {
cy.findByText(TEST_USER);
});

// Assert that the other line contains the file button
cy.get(".mx_ReplyChain .mx_MFileBody").should("exist");
Expand All @@ -315,7 +316,7 @@ describe("Audio player", () => {

cy.get("blockquote.mx_ReplyChain:first-of-type").within(() => {
// Assert that "In reply to" has disappeared
cy.contains("In reply to").should("not.exist");
cy.findByText("In reply to").should("not.exist");

// Assert that audio file on the first row is rendered as file button
cy.get(".mx_MFileBody_info[role='button']").within(() => {
Expand All @@ -338,7 +339,7 @@ describe("Audio player", () => {
cy.get(".mx_EventTile_last .mx_AudioPlayer_container").should("exist");

// Find and click "Reply in thread" button
cy.get(".mx_EventTile_last").realHover().findButton("Reply in thread").click();
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Reply in thread" }).click();
});

// On a thread
Expand All @@ -351,20 +352,20 @@ describe("Audio player", () => {
cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist");

// Find and click "Play" button
cy.findButton("Play").click();
cy.findByRole("button", { name: "Play" }).click();

// Assert that "Pause" button can be found
cy.findButton("Pause").should("exist");
cy.findByRole("button", { name: "Pause" }).should("exist");

// Assert that the timer is reset when the audio file finished playing
cy.contains(".mx_AudioPlayer_seek [role='timer']", "00:00").should("exist");

// Assert that "Play" button can be found
cy.findButton("Play").should("exist");
cy.findByRole("button", { name: "Play" }).should("exist");
});
})
.realHover()
.findButton("Reply")
.findByRole("button", { name: "Reply" })
.click(); // Find and click "Reply" button

cy.get(".mx_MessageComposer--compact").within(() => {
Expand All @@ -375,9 +376,9 @@ describe("Audio player", () => {
});

// Select :smile: emoji and send it
cy.get("[data-testid='basicmessagecomposer']").type(":smile:");
cy.findByTestId("basicmessagecomposer").type(":smile:");
cy.get(".mx_Autocomplete_Completion[aria-selected='true']").click();
cy.get("[data-testid='basicmessagecomposer']").type("{enter}");
cy.findByTestId("basicmessagecomposer").type("{enter}");
});

cy.get(".mx_EventTile_last").within(() => {
Expand Down