Skip to content

Commit f7bc3ac

Browse files
committed
Verify grouped reply identity and fix gallery types
Signed-off-by: Arjun Mahanti <[email protected]>
1 parent 342bee3 commit f7bc3ac

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎src/features/messages/ThreadPanel.identity.test.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,21 @@ it("retains mounted rows through a deferred real-session page and profile noise"
133133
]);
134134
bodyRender.mockClear();
135135

136+
const retainedReply = screen.getByText("Reply body");
137+
const retainedRow = retainedReply.closest("[data-message-id]");
136138
const appended = message(bobKey, "a", "Appended reply body", 3, [
137139
["e", root.id, "", "root"],
138140
["e", root.id, "", "reply"],
139141
]);
140142
await act(async () => page.respond([root, appended]));
141143
expect(await screen.findByText("Appended reply body")).toBeInTheDocument();
144+
// The previous last bubble re-renders to join the new same-author reply.
145+
// Its mounted content stays intact; unrelated rows still do not render.
146+
expect(screen.getByText("Reply body")).toBe(retainedReply);
147+
expect(retainedRow?.querySelector("[data-stack-next]")).not.toBeNull();
142148
expect(bodyRender.mock.calls).toEqual([
149+
["Reply body"],
150+
["Reply body"],
143151
["Appended reply body"],
144152
["Appended reply body"],
145153
]);

‎tests/fixtures/message-gallery/main.tsx‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ function Specimen({ example }: { example: Example }) {
7979
<p className="text-body-sm text-tertiary">{example.description}</p>
8080
</header>
8181
<div className="message-gallery-frame">
82-
{rows.map((row, index) =>
83-
row.membership ? (
82+
{rows.map((row, index) => {
83+
const nextRow = rows[index + 1];
84+
return row.membership ? (
8485
<MembershipRow
8586
key={row.id}
8687
row={row}
@@ -96,11 +97,7 @@ function Specimen({ example }: { example: Example }) {
9697
row={row}
9798
viewer={reader}
9899
stackPrevious={continuesMessageGroup(rows[index - 1], row)}
99-
stackNext={
100-
rows[index + 1]
101-
? continuesMessageGroup(row, rows[index + 1])
102-
: false
103-
}
100+
stackNext={nextRow ? continuesMessageGroup(row, nextRow) : false}
104101
profile={profiles.get(row.authorId)}
105102
participantProfiles={profiles}
106103
agentPubkeys={agentPubkeys}
@@ -129,8 +126,8 @@ function Specimen({ example }: { example: Example }) {
129126
}
130127
: {})}
131128
/>
132-
),
133-
)}
129+
);
130+
})}
134131
{thread && (
135132
<section
136133
aria-label="Sample thread replies"

0 commit comments

Comments
 (0)