git » sdk » commit 86d98f8

Share this test instead of being idb only

author Eric Roberts
2026-08-26 20:19:55 UTC
committer Stephen Paul Weber
2026-08-26 20:22:41 UTC
parent 81a4502c8c733adbd1d52422b38deb069bf190ac

Share this test instead of being idb only

As written it failed running against SQLite, but this was actually because the
test was wrong. The first message should have had a serverIdBy of
alice@example.com. Once that was changed the test passed against both backends.

test/idb.spec.ts +0 -54
test/persistence-tests.ts +53 -0

diff --git a/test/idb.spec.ts b/test/idb.spec.ts
index 2155f45..420e047 100644
--- a/test/idb.spec.ts
+++ b/test/idb.spec.ts
@@ -3,60 +3,6 @@ import { sharedPersistenceTests } from "./persistence-tests";
 
 sharedPersistenceTests(test);
 
-// TODO: Share this with SQLite once direct-chat reply hydration is fixed.
-test("hydrate message with incomplete replyToMessage", async ({
-	page,
-	borogove,
-	persistence,
-}) => {
-	const result = await page.evaluate(
-		async ({ borogove, persistence }) => {
-			const builder = new borogove.ChatMessageBuilder({
-				serverId: "parent",
-				serverIdBy: "hatter@example.com",
-				localId: "loc1",
-				senderId: "hatter@example.com",
-				direction: 0,
-			});
-			builder.sortId = "a0";
-			builder.to = borogove.JID.parse("alice@example.com");
-			builder.from = borogove.JID.parse("hatter@example.com");
-			builder.recipients = [builder.to];
-			builder.replyTo = [builder.from];
-			const parentStub = builder.build();
-
-			builder.setBody(borogove.Html.text("Hello"));
-			const parentMsg = builder.build();
-
-			const builder2 = new borogove.ChatMessageBuilder({
-				serverId: "child",
-				serverIdBy: "hatter@example.com",
-				localId: "loc2",
-				senderId: "hatter@example.com",
-				direction: 0,
-			});
-			builder2.sortId = "a1";
-			builder2.to = borogove.JID.parse("alice@example.com");
-			builder2.from = borogove.JID.parse("hatter@example.com");
-			builder2.recipients = [builder2.to];
-			builder2.replyTo = [builder2.from];
-			builder2.replyToMessage = parentStub;
-			const childMsg = builder2.build();
-
-			await persistence.storeMessages("alice@example.com", [parentMsg]);
-			const [childStored] = await persistence.storeMessages(
-				"alice@example.com",
-				[childMsg],
-			);
-
-			return childStored.replyToMessage.body().toPlainText();
-		},
-		{ borogove, persistence },
-	);
-
-	expect(result).toBe("Hello");
-});
-
 test("hydrate message with incomplete replyToMessage keys", async ({
 	page,
 	borogove,
diff --git a/test/persistence-tests.ts b/test/persistence-tests.ts
index f198e79..0b9b21c 100644
--- a/test/persistence-tests.ts
+++ b/test/persistence-tests.ts
@@ -2092,6 +2092,59 @@ export function sharedPersistenceTests(test: PersistenceTest) {
 		expect(result.loaded).toEqual(session);
 		expect(result.afterRemove).toBeNull();
 	});
+
+	test("hydrate message with incomplete replyToMessage", async ({
+		page,
+		borogove,
+		persistence,
+	}) => {
+		const result = await page.evaluate(
+			async ({ borogove, persistence }) => {
+				const builder = new borogove.ChatMessageBuilder({
+					serverId: "parent",
+					serverIdBy: "alice@example.com",
+					localId: "loc1",
+					senderId: "hatter@example.com",
+					direction: 0,
+				});
+				builder.sortId = "a0";
+				builder.to = borogove.JID.parse("alice@example.com");
+				builder.from = borogove.JID.parse("hatter@example.com");
+				builder.recipients = [builder.to];
+				builder.replyTo = [builder.from];
+				const parentStub = builder.build();
+
+				builder.setBody(borogove.Html.text("Hello"));
+				const parentMsg = builder.build();
+
+				const builder2 = new borogove.ChatMessageBuilder({
+					serverId: "child",
+					serverIdBy: "alice@example.com",
+					localId: "loc2",
+					senderId: "hatter@example.com",
+					direction: 0,
+				});
+				builder2.sortId = "a1";
+				builder2.to = borogove.JID.parse("alice@example.com");
+				builder2.from = borogove.JID.parse("hatter@example.com");
+				builder2.recipients = [builder2.to];
+				builder2.replyTo = [builder2.from];
+				builder2.replyToMessage = parentStub;
+				const childMsg = builder2.build();
+
+				await persistence.storeMessages("alice@example.com", [parentMsg]);
+				const [childStored] = await persistence.storeMessages(
+					"alice@example.com",
+					[childMsg],
+				);
+
+				return childStored.replyToMessage.body().toPlainText();
+			},
+			{ borogove, persistence },
+		);
+
+		expect(result).toBe("Hello");
+	});
 }
 
 type TestKeyPair = {