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

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MidhunSureshR committed Sep 28, 2024
1 parent a9199a4 commit 6e3ef61
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/views/messages/MStickerBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class MStickerBody extends MImageBody {

return {
placement: "right",
label: content.body,
description: content.body,
};
}

Expand Down
21 changes: 12 additions & 9 deletions test/components/views/rooms/MessageComposer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.

import * as React from "react";
import { EventType, MatrixEvent, Room, RoomMember, THREAD_RELATION_TYPE } from "matrix-js-sdk/src/matrix";
import { act, fireEvent, render, screen, waitFor } from "jest-matrix-react";
import { act, fireEvent, prettyDOM, render, screen, waitFor } from "jest-matrix-react";

Check failure on line 11 in test/components/views/rooms/MessageComposer-test.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'fireEvent' is defined but never used

Check failure on line 11 in test/components/views/rooms/MessageComposer-test.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'fireEvent' is declared but its value is never read.
import userEvent from "@testing-library/user-event";

import {
Expand Down Expand Up @@ -432,7 +432,7 @@ describe("MessageComposer", () => {
});
});

describe("for a LocalRoom", () => {
describe.only("for a LocalRoom", () => {

Check failure on line 435 in test/components/views/rooms/MessageComposer-test.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected focused test
const localRoom = new LocalRoom("!room:example.com", cli, cli.getUserId()!);

it("should not show the stickers button", async () => {
Expand All @@ -444,7 +444,7 @@ describe("MessageComposer", () => {
});
});

it("wysiwyg correctly persists state to and from localStorage", async () => {
it.only("wysiwyg correctly persists state to and from localStorage", async () => {

Check failure on line 447 in test/components/views/rooms/MessageComposer-test.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected focused test
const room = mkStubRoom("!roomId:server", "Room 1", cli);
const messageText = "Test Text";
await SettingsStore.setValue("feature_wysiwyg_composer", null, SettingLevel.DEVICE, true);
Expand All @@ -458,14 +458,17 @@ describe("MessageComposer", () => {
const key = `mx_wysiwyg_state_${room.roomId}`;

await act(async () => {
console.log(prettyDOM(screen.getByRole("textbox")));
await userEvent.click(screen.getByRole("textbox"));
await userEvent.keyboard(messageText);
expect(screen.getByRole("textbox")).toHaveTextContent(messageText);

Check failure on line 464 in test/components/views/rooms/MessageComposer-test.tsx

View workflow job for this annotation

GitHub Actions / Jest (1)

MessageComposer › wysiwyg correctly persists state to and from localStorage

expect(element).toHaveTextContent() Expected element to have text content: Test Text Received: at toHaveTextContent (test/components/views/rooms/MessageComposer-test.tsx:464:49)
// await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(messageText));
});
fireEvent.input(screen.getByRole("textbox"), {
data: messageText,
inputType: "insertText",
});

await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(messageText));
// fireEvent.input(screen.getByRole("textbox"), {
// data: messageText,
// inputType: "insertText",
// });
// await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(messageText));

// Wait for event dispatch to happen
await act(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("<CallGuestLinkButton />", () => {

it("shows the JoinRuleDialog on click with private join rules", async () => {
getComponent(room);
fireEvent.click(screen.getByLabelText("Share call link"));
fireEvent.click(screen.getByRole("button", { name: "Share call link" }));
expect(modalSpy).toHaveBeenCalledWith(JoinRuleDialog, { room, canInvite: false });
// pretend public was selected
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
Expand All @@ -115,7 +115,7 @@ describe("<CallGuestLinkButton />", () => {
it("shows the ShareDialog on click with public join rules", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
getComponent(room);
fireEvent.click(screen.getByLabelText("Share call link"));
fireEvent.click(screen.getByRole("button", { name: "Share call link" }));
const callParams = modalSpy.mock.calls[0];
expect(callParams[0]).toEqual(ShareDialog);
expect(callParams[1].target.toString()).toEqual(expectedShareDialogProps.target);
Expand All @@ -127,7 +127,7 @@ describe("<CallGuestLinkButton />", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
jest.spyOn(room, "canInvite").mockReturnValue(true);
getComponent(room);
fireEvent.click(screen.getByLabelText("Share call link"));
fireEvent.click(screen.getByRole("button", { name: "Share call link" }));
const callParams = modalSpy.mock.calls[0];
expect(callParams[0]).toEqual(ShareDialog);
expect(callParams[1].target.toString()).toEqual(expectedShareDialogProps.target);
Expand Down
10 changes: 5 additions & 5 deletions test/components/views/spaces/ThreadsActivityCentre-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ describe("ThreadsActivityCentre", () => {
return screen.getByRole("menu");
};

const getTACDescription = () => {
return screen.getByText("Threads");
const getTACDescription = (container: ReturnType<typeof render>["container"]) => {
return container.querySelector(".mx_ThreadsActivityCentreButton_Text");
};

const renderTAC = (props?: ComponentProps<typeof ThreadsActivityCentre>) => {
render(
return render(
<MatrixClientContext.Provider value={cli}>
<ThreadsActivityCentre {...props} />
</MatrixClientContext.Provider>,
Expand Down Expand Up @@ -130,9 +130,9 @@ describe("ThreadsActivityCentre", () => {
});

it("should render the threads activity centre button and the display label", async () => {
renderTAC({ displayButtonLabel: true });
const { container } = renderTAC({ displayButtonLabel: true });
expect(getTACButton()).toBeInTheDocument();
expect(getTACDescription()).toBeInTheDocument();
expect(getTACDescription(container)).toBeInTheDocument();
});

it("should render the threads activity centre menu when the button is clicked", async () => {
Expand Down

0 comments on commit 6e3ef61

Please sign in to comment.