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

Commit

Permalink
Merge branch 'develop' into taj/cryptosetup
Browse files Browse the repository at this point in the history
  • Loading branch information
thoraj authored Apr 12, 2024
2 parents ee14471 + aadb463 commit 2ddf31f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 10 deletions.
68 changes: 68 additions & 0 deletions playwright/e2e/threads/threads.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,72 @@ test.describe("Threads", () => {
await expect(locator.locator(".mx_EventTile").first().getByText("Hello Mr. Bot")).toBeAttached();
await expect(locator.locator(".mx_EventTile").last().getByText("Hello Mr. User")).toBeAttached();
});

test("navigate through right panel", async ({ page, app, user }) => {
// Create room
const roomId = await app.client.createRoom({});
await page.goto("/#/room/" + roomId);

/**
* Send a message in the main timeline
* @param message
*/
const sendMessage = async (message: string) => {
const messageComposer = page.getByRole("region", { name: "Message composer" });
const textbox = messageComposer.getByRole("textbox", { name: "Send a message…" });
await textbox.fill(message);
await textbox.press("Enter");
};

/**
* Create a thread from the rootMessage and send a message in the thread
* @param rootMessage
* @param threadMessage
*/
const createThread = async (rootMessage: string, threadMessage: string) => {
// First create a thread
const roomViewBody = page.locator(".mx_RoomView_body");
const messageTile = roomViewBody
.locator(".mx_EventTile[data-scroll-tokens]")
.filter({ hasText: rootMessage });
await messageTile.hover();
await messageTile.getByRole("button", { name: "Reply in thread" }).click();
await expect(page.locator(".mx_ThreadView_timelinePanelWrapper")).toHaveCount(1);

// Send a message in the thread
const threadPanel = page.locator(".mx_ThreadPanel");
const textbox = threadPanel.getByRole("textbox", { name: "Send a message…" });
await textbox.fill(threadMessage);
await textbox.press("Enter");
await expect(threadPanel.locator(".mx_EventTile_last").getByText(threadMessage)).toBeVisible();
// Close thread
await threadPanel.getByRole("button", { name: "Close" }).click();
};

await sendMessage("Hello Mr. Bot");
await sendMessage("Hello again Mr. Bot");
await createThread("Hello Mr. Bot", "Hello Mr. User in a thread");
await createThread("Hello again Mr. Bot", "Hello again Mr. User in a thread");

// Open thread panel
await page.getByRole("button", { name: "Threads" }).click();
const threadPanel = page.locator(".mx_ThreadPanel");
await expect(
threadPanel.locator(".mx_EventTile_last").getByText("Hello again Mr. User in a thread"),
).toBeVisible();

// Open threads list
await threadPanel.getByRole("button", { name: "Threads" }).click();
const rightPanel = page.locator(".mx_RightPanel");
// Check that the threads are listed
await expect(rightPanel.locator(".mx_EventTile").getByText("Hello Mr. User in a thread")).toBeVisible();
await expect(rightPanel.locator(".mx_EventTile").getByText("Hello again Mr. User in a thread")).toBeVisible();

// Open the first thread
await rightPanel.locator(".mx_EventTile").getByText("Hello Mr. User in a thread").click();
await expect(rightPanel.locator(".mx_EventTile").getByText("Hello Mr. User in a thread")).toBeVisible();
await expect(
rightPanel.locator(".mx_EventTile").getByText("Hello again Mr. User in a thread"),
).not.toBeVisible();
});
});
12 changes: 2 additions & 10 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
newState.initialEventPixelOffset = undefined;

const thread = initialEvent?.getThread();
// Handle the use case of a link to a thread message
// ie: #/room/roomId/eventId (eventId of a thread message)
if (thread?.rootEvent && !initialEvent?.isThreadRoot) {
dis.dispatch<ShowThreadPayload>({
action: Action.ShowThread,
Expand All @@ -719,16 +721,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
newState.initialEventId = initialEventId;
newState.isInitialEventHighlighted = this.context.roomViewStore.isInitialEventHighlighted();
newState.initialEventScrollIntoView = this.context.roomViewStore.initialEventScrollIntoView();

if (thread?.rootEvent && initialEvent?.isThreadRoot) {
dis.dispatch<ShowThreadPayload>({
action: Action.ShowThread,
rootEvent: thread.rootEvent,
initialEvent,
highlighted: this.context.roomViewStore.isInitialEventHighlighted(),
scroll_into_view: this.context.roomViewStore.initialEventScrollIntoView(),
});
}
}
}

Expand Down

0 comments on commit 2ddf31f

Please sign in to comment.