fix(viewer): restore saved unread chat counts
This commit is contained in:
parent
7f11b0c6c7
commit
28c4971d48
4 changed files with 32 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "outpost-viewer",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"description": "Browser viewer for the Outpost game on boardgamers.space",
|
||||
"license": "AGPL-3.0",
|
||||
"files": [
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.6.0",
|
||||
"@boardgamers/protocol": "0.6.1",
|
||||
"outpost-engine": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -40,8 +40,8 @@ importers:
|
|||
packages/viewer:
|
||||
dependencies:
|
||||
'@boardgamers/protocol':
|
||||
specifier: 0.6.0
|
||||
version: 0.6.0
|
||||
specifier: 0.6.1
|
||||
version: 0.6.1
|
||||
outpost-engine:
|
||||
specifier: workspace:*
|
||||
version: link:../engine
|
||||
|
|
@ -67,8 +67,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==}
|
||||
|
|
@ -772,7 +772,7 @@ packages:
|
|||
|
||||
snapshots:
|
||||
|
||||
'@boardgamers/protocol@0.6.0':
|
||||
'@boardgamers/protocol@0.6.1':
|
||||
dependencies:
|
||||
zod: 4.6.2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
packages:
|
||||
- "packages/*"
|
||||
minimumReleaseAgeExclude:
|
||||
- "@boardgamers/protocol@0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0"
|
||||
- "@boardgamers/protocol@0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1"
|
||||
|
|
|
|||
|
|
@ -221,6 +221,30 @@ try {
|
|||
emitter.emit("player", {});
|
||||
emitter.emit("state", state);
|
||||
}, stripSecret(state));
|
||||
|
||||
await page.locator(".board").evaluate((el) => {
|
||||
el.style.display = "none";
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
window.restoredReceipts = [];
|
||||
emitter.on("chat:read", (payload) => restoredReceipts.push(payload));
|
||||
emitter.emit("chat:state", { canSend: true, readState: { userId: "self", lastReadAt: 500000 } });
|
||||
emitter.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(".chat .caption")?.textContent === "Chat · 1");
|
||||
await page.waitForTimeout(650);
|
||||
assert.equal(await page.evaluate(() => restoredReceipts.length), 0, "hidden chat preserves unread history");
|
||||
await page.locator(".board").evaluate((el) => {
|
||||
el.style.display = "";
|
||||
});
|
||||
await page.getByRole("region", { name: "Chat messages" }).scrollIntoViewIfNeeded();
|
||||
await page.waitForFunction(() => restoredReceipts.length > 0);
|
||||
assert.equal(await page.locator(".chat .caption").textContent(), "Chat", "opening chat clears restored unread");
|
||||
await checkHostPresentation(page, "emitter", `/tmp/outpost-board-thumbnail-${width}.png`);
|
||||
assert.deepEqual(errors, []);
|
||||
await page.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue