diff --git a/packages/viewer/package.json b/packages/viewer/package.json index 410f6b5..d745def 100644 --- a/packages/viewer/package.json +++ b/packages/viewer/package.json @@ -1,6 +1,6 @@ { "name": "fuji-viewer", - "version": "0.1.6", + "version": "0.1.7", "private": true, "license": "AGPL-3.0-only", "type": "module", @@ -11,7 +11,7 @@ "test:tutorial": "node --test src/tutorial/*.spec.ts" }, "dependencies": { - "@boardgamers/protocol": "0.6.0", + "@boardgamers/protocol": "0.6.1", "fuji-engine": "workspace:*" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c94574d..38b9175 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,8 +34,8 @@ importers: packages/viewer: dependencies: '@boardgamers/protocol': - specifier: 0.6.0 - version: 0.6.0 + specifier: 0.6.1 + version: 0.6.1 fuji-engine: specifier: workspace:* version: link:../engine @@ -61,8 +61,8 @@ importers: packages: - '@boardgamers/protocol@0.6.0': - resolution: {integrity: sha512-byHV2eOOFpnQCnhLaM0LPUpT30ew1aAOuTIYxwztkVjg4NgeTyPwjU8Efmc/xi+DGCrfIjo2LTb7YlNUhmzy0g==} + '@boardgamers/protocol@0.6.1': + resolution: {integrity: sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==} '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -631,7 +631,7 @@ packages: snapshots: - '@boardgamers/protocol@0.6.0': + '@boardgamers/protocol@0.6.1': dependencies: zod: 4.6.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 28b1c4c..c30ce72 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,4 @@ packages: - packages/* minimumReleaseAgeExclude: - - "@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0" + - "@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1" diff --git a/tests/chat-smoke.mjs b/tests/chat-smoke.mjs index f033e3e..c18767c 100644 --- a/tests/chat-smoke.mjs +++ b/tests/chat-smoke.mjs @@ -94,6 +94,26 @@ try { ); await page.waitForTimeout(650); assert.equal(await page.evaluate(() => window.events.filter((e) => e.name === "chat:read").length), receipts + 1); + + await page.getByRole("button", { name: "Collapse chat" }).click(); + await page.evaluate(() => { + window.restoredReceipts = []; + bridge.on("chat:read", (payload) => restoredReceipts.push(payload)); + bridge.emit("chat:state", { canSend: true, readState: { userId: "self", lastReadAt: 500000 } }); + bridge.emit("chat:messages", [ + { _id: "000001f40000000000000001", type: "text", authorId: "other", text: "Already read" }, + { _id: "000001f50000000000000001", type: "text", authorId: "other", text: "Unread after reload" }, + { _id: "000001f60000000000000001", type: "text", authorId: "self", text: "My own message" }, + { _id: "000001f70000000000000001", type: "system", text: "Game started" }, + ]); + }); + await page.waitForFunction(() => document.querySelector(".utility-count")?.textContent === "1"); + await page.waitForTimeout(650); + assert.equal(await page.evaluate(() => restoredReceipts.length), 0, "collapsed chat preserves unread history"); + await page.getByRole("button", { name: "Expand chat" }).click(); + await page.locator(".chat-messages").scrollIntoViewIfNeeded(); + await page.waitForFunction(() => restoredReceipts.length > 0); + assert.equal(await page.locator(".utility-count").count(), 0, "opening chat clears restored unread"); await page.screenshot({ path: "work/chat-desktop.png" }); await page.evaluate(() => window.bridge.emit("chat:disabled", true)); assert.equal(await page.getByRole("textbox", { name: "Chat message" }).count(), 0);