Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions apps/web/src/features/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@
"reveal-muted": "Muted author - Reveal comment",
"reveal-muted-long-description": "Show additional replies, including those that may contain offensive content",
"reveal": "Reveal comment",
"hide": "Hide comment",
"reveal-comments": "Show {{n}} comments",
"no-conversation": "No conversation yet, be first to reply",
"start-conversation": "Start conversation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const DiscussionItem = memo(function DiscussionItem({
aria-expanded={!isContentCollapsed}
onClick={() => setIsContentCollapsed((value) => !value)}
>
{i18next.t(isContentCollapsed ? toggleLabelKey : "chat.hide-message")}
{i18next.t(isContentCollapsed ? toggleLabelKey : "discussion.hide")}
</Button>
)}
</div>
Expand Down
35 changes: 35 additions & 0 deletions apps/web/src/specs/features/shared/discussion-item.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ vi.mock("@/features/shared/discussion/discussion-list", () => ({ DiscussionList:
vi.mock("@/features/shared/comment", () => ({ Comment: () => null }));

import { DiscussionItem } from "@/features/shared/discussion/discussion-item";
import enUS from "@/features/i18n/locales/en-US.json";

// Resolve a dotted i18n key against the shipped English locale.
function getLocaleValue(key: string) {
return key
.split(".")
.reduce<any>((acc, part) => (acc == null ? acc : acc[part]), enUS as Record<string, unknown>);
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Outdated
}

function renderItem(entry: Entry, root: Entry) {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
Expand Down Expand Up @@ -148,6 +156,33 @@ describe("DiscussionItem", () => {
expect(screen.queryByTestId("entry-tip-btn")).not.toBeInTheDocument();
});

it("labels the collapse toggle with keys that exist in en-US.json", () => {
// i18next is globally mocked to echo the key, so the rendered text IS the
// key the component asked for. The hide side used to ask for
// `chat.hide-message`, which no locale defines, and shipped the raw key.
const lowRepComment = mockEntry({
author: "spammer",
permlink: "re-the-post-spam",
parent_author: "bob",
parent_permlink: "the-post",
depth: 1,
author_reputation: -8,
net_rshares: 0,
stats: { flag_weight: 0, gray: true, hide: false, total_votes: 0 }
});

renderItem(lowRepComment, root);

const revealKey = screen.getByRole("button", { name: /^discussion\./ }).textContent!;
expect(getLocaleValue(revealKey)).toBeTypeOf("string");

fireEvent.click(screen.getByText(revealKey));

const hideKey = screen.getByRole("button", { name: /^discussion\./ }).textContent!;
expect(hideKey).not.toBe(revealKey);
expect(getLocaleValue(hideKey)).toBeTypeOf("string");
});

it("animates the reply composer entrance only after clicking Reply, never on initial render", () => {
activeUserRef.current = "demo";
const { container } = renderItem(comment, root);
Expand Down
Loading