Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion desktop/src/features/home/ui/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,11 @@ export function HomeView({
setIsDeletingMessage(false);
});
}}
onOpenChannel={(channelId) => {
onManageChannel={(channelId) => {
handleCloseProfilePanel();
setManagedChannelId(channelId);
}}
onOpenContext={onOpenContext}
onSendReply={async ({
content,
mediaTags,
Expand Down
21 changes: 17 additions & 4 deletions desktop/src/features/home/ui/InboxDetailPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ type InboxDetailPaneProps = {
latchedDefaultParentId?: string | null;
onBack?: () => void;
onDelete: () => void;
onOpenChannel: (channelId: string) => void;
onManageChannel: (channelId: string) => void;
onOpenContext: (
channelId: string,
messageId: string,
threadRootId?: string | null,
) => void;
onSendReply: (input: {
content: string;
mediaTags?: string[][];
Expand Down Expand Up @@ -111,7 +116,8 @@ export function InboxDetailPane({
latchedDefaultParentId = null,
onBack,
onDelete,
onOpenChannel,
onManageChannel,
onOpenContext,
onSendReply,
onToggleReaction,
}: InboxDetailPaneProps) {
Expand Down Expand Up @@ -318,6 +324,7 @@ export function InboxDetailPane({
const contextLabel = channelContextName ?? formatInboxTypeLabel(item);
const hasChannelContext = Boolean(channelContextName);
const contextChannelId = item.item.channelId;
const contextThreadRootId = getThreadReference(item.item.tags).rootId;

const handleSelectReplyTarget = (message: InboxDisplayMessage) => {
setReplyTargetId((currentReplyTargetId) =>
Expand Down Expand Up @@ -358,7 +365,13 @@ export function InboxDetailPane({
{canOpenChannel && contextChannelId ? (
<button
className="flex min-w-0 items-center gap-[4px] text-left text-sm font-semibold leading-5 tracking-tight text-foreground hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
onClick={() => onOpenChannel(contextChannelId)}
onClick={() =>
onOpenContext(
contextChannelId,
item.id,
contextThreadRootId,
)
}
title={item.fullTimestampLabel}
type="button"
>
Expand Down Expand Up @@ -394,7 +407,7 @@ export function InboxDetailPane({
currentPubkey={currentPubkey}
onManageChannel={() => {
if (contextChannelId) {
onOpenChannel(contextChannelId);
onManageChannel(contextChannelId);
}
}}
onToggleMembers={() =>
Expand Down
73 changes: 66 additions & 7 deletions desktop/tests/e2e/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,11 @@ test("manage channel keeps canvas near the top of the sheet", async ({
expect(canvasBox?.y).toBeLessThan(nameBox?.y);
});

test("home inbox channel label opens management without leaving home", async ({
page,
}) => {
async function seedHomeInboxMention(
page: import("@playwright/test").Page,
itemId: string,
tags?: string[][],
) {
await page.goto("/");
await expect(page.getByTestId("home-inbox-list")).toBeVisible();
await page.waitForFunction(
Expand All @@ -1718,22 +1720,29 @@ test("home inbox channel label opens management without leaving home", async ({
);

await page.evaluate(
({ channelId, createdAt, currentPubkey, senderPubkey }) => {
({
channelId,
createdAt,
currentPubkey,
itemId: id,
senderPubkey,
tags: seededTags,
}) => {
const pushFeedItem = (window as MockFeedWindow)
.__BUZZ_E2E_PUSH_MOCK_FEED_ITEM__;
if (!pushFeedItem) {
throw new Error("Mock feed injection helper is not installed.");
}

pushFeedItem({
id: "mock-feed-home-channel-panel",
id,
kind: 9,
pubkey: senderPubkey,
content: "Please review the home panel routing.",
created_at: createdAt,
channel_id: channelId,
channel_name: "general",
tags: [
tags: seededTags ?? [
["e", channelId],
["p", currentPubkey],
],
Expand All @@ -1744,18 +1753,68 @@ test("home inbox channel label opens management without leaving home", async ({
channelId: GENERAL_CHANNEL_ID,
createdAt: Math.floor(Date.now() / 1000),
currentPubkey: TEST_IDENTITIES.tyler.pubkey,
itemId,
senderPubkey: TEST_IDENTITIES.alice.pubkey,
tags,
},
);

await page.getByTestId(`home-inbox-item-${itemId}`).click();
}

test("home inbox channel label navigates to the channel message", async ({
page,
}) => {
await seedHomeInboxMention(page, "mock-feed-home-channel-navigate");

await page
.getByTestId("home-inbox-item-mock-feed-home-channel-panel")
.getByTestId("home-inbox-detail")
.getByRole("button", { exact: true, name: "general" })
.click();

await expect(page).toHaveURL(
new RegExp(`#/channels/${GENERAL_CHANNEL_ID}\\?`),
);
await expect(page).toHaveURL(/messageId=mock-feed-home-channel-navigate/);
await expect(page).not.toHaveURL(/threadRootId=/);
await expect(page.getByTestId("message-timeline")).toBeVisible();
await expect(page.getByTestId("home-inbox-list")).toHaveCount(0);
});

test("home inbox thread reply mention carries threadRootId to the channel", async ({
page,
}) => {
const rootEventId = "mock-feed-home-thread-root";
await seedHomeInboxMention(page, "mock-feed-home-thread-navigate", [
["e", rootEventId, "", "root"],
["e", "mock-feed-home-thread-parent", "", "reply"],
["p", TEST_IDENTITIES.tyler.pubkey],
]);

await page
.getByTestId("home-inbox-detail")
.getByRole("button", { exact: true, name: "general" })
.click();

await expect(page).toHaveURL(
new RegExp(`#/channels/${GENERAL_CHANNEL_ID}\\?`),
);
await expect(page).toHaveURL(/messageId=mock-feed-home-thread-navigate/);
await expect(page).toHaveURL(new RegExp(`threadRootId=${rootEventId}`));
await expect(page.getByTestId("message-timeline")).toBeVisible();
await expect(page.getByTestId("home-inbox-list")).toHaveCount(0);
});

test("home inbox manage affordance opens management without leaving home", async ({
page,
}) => {
await seedHomeInboxMention(page, "mock-feed-home-channel-panel");

await page
.getByTestId("home-inbox-detail")
.getByTestId("channel-management-trigger")
.click();

await expect(page.getByTestId("channel-management-sheet")).toBeVisible();
await expect(page.getByTestId("channel-management-name-row")).toContainText(
"general",
Expand Down
Loading