mirror of
https://github.com/block/buzz.git
synced 2026-10-29 13:31:44 +00:00
test(desktop): cover nested live reply projection
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: tornquist <tornquist@squareup.com>
This commit is contained in:
@@ -33,6 +33,7 @@ after(() => dom.window.close());
|
||||
|
||||
const CHANNEL_ID = "channel-a";
|
||||
const ROOT_ID = "a".repeat(64);
|
||||
const PARENT_ID = "1".repeat(64);
|
||||
const EXISTING_REPLY_ID = "b".repeat(64);
|
||||
const NEW_REPLY_ID = "c".repeat(64);
|
||||
const TOP_LEVEL_ID = "d".repeat(64);
|
||||
@@ -134,6 +135,47 @@ test("non-broadcast replies stay out of channelMessagesKey and merge into an exi
|
||||
client.clear();
|
||||
});
|
||||
|
||||
test("nested non-broadcast replies use the root thread cache instead of the parent cache", async () => {
|
||||
const client = new QueryClient({
|
||||
defaultOptions: { queries: { retry: false } },
|
||||
});
|
||||
client.setQueryData(channelMessagesKey(CHANNEL_ID), [rootEvent()]);
|
||||
const parentReply = directReplyEvent(PARENT_ID, 101, [], "parent-reply");
|
||||
client.setQueryData(threadRepliesKey(CHANNEL_ID, ROOT_ID), [parentReply]);
|
||||
|
||||
const { callback, unmount } = await mountLiveUpdates(client);
|
||||
const nestedReply = event(
|
||||
NEW_REPLY_ID,
|
||||
102,
|
||||
[
|
||||
["h", CHANNEL_ID],
|
||||
["e", ROOT_ID, "", "root"],
|
||||
["e", PARENT_ID, "", "reply"],
|
||||
],
|
||||
"nested-reply",
|
||||
);
|
||||
|
||||
callback(nestedReply);
|
||||
|
||||
assert.deepEqual(client.getQueryData(channelMessagesKey(CHANNEL_ID)), [
|
||||
rootEvent(),
|
||||
]);
|
||||
assert.deepEqual(client.getQueryData(threadRepliesKey(CHANNEL_ID, ROOT_ID)), [
|
||||
parentReply,
|
||||
nestedReply,
|
||||
]);
|
||||
assert.equal(
|
||||
client.getQueryCache().find({
|
||||
queryKey: threadRepliesKey(CHANNEL_ID, PARENT_ID),
|
||||
exact: true,
|
||||
}),
|
||||
undefined,
|
||||
);
|
||||
|
||||
unmount();
|
||||
client.clear();
|
||||
});
|
||||
|
||||
test("non-broadcast replies merge into an existing empty thread query", async () => {
|
||||
const client = new QueryClient({
|
||||
defaultOptions: { queries: { retry: false } },
|
||||
|
||||
Reference in New Issue
Block a user