mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-05 22:00:17 +00:00
Fix pinned message banner disappearing when a pinned message event is unkown (#33534)
* fix: remove unknown event when fetching pinned message events * test: update tsts
This commit is contained in:
@@ -294,6 +294,23 @@ describe("<PinnedMessagesCard />", () => {
|
||||
await initPinnedMessagesCard([], [pin]);
|
||||
expect(screen.queryAllByRole("listitem")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("should filter out null events returned by useFetchedPinnedEvents and only display valid events", async () => {
|
||||
// RoomCreate is not a pinnable event type — useFetchedPinnedEvents returns null for it
|
||||
const unpinnableEvent = mkEvent({
|
||||
event: true,
|
||||
type: EventType.RoomCreate,
|
||||
content: {},
|
||||
room: "!room:example.org",
|
||||
user: "@alice:example.org",
|
||||
});
|
||||
// pin1 is a valid pinnable message, unpinnableEvent causes useFetchedPinnedEvents to return null
|
||||
// useSortedFetchedPinnedEvents must filter out the null, leaving only pin1
|
||||
await initPinnedMessagesCard([pin1], [unpinnableEvent]);
|
||||
|
||||
await waitFor(() => expect(screen.queryAllByRole("listitem")).toHaveLength(1));
|
||||
expect(screen.getByText("First pinned message")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unpin all", () => {
|
||||
|
||||
Reference in New Issue
Block a user