fix(viewer): restore saved unread chat counts
This commit is contained in:
parent
83274465c0
commit
90bdce2021
4 changed files with 67 additions and 7 deletions
|
|
@ -15,7 +15,7 @@
|
|||
"test:locales": "node scripts/check-locales.mjs viewer/localization && node --test scripts/localization.test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.6.0",
|
||||
"@boardgamers/protocol": "0.6.1",
|
||||
"@noble/hashes": "2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -9,8 +9,8 @@ importers:
|
|||
.:
|
||||
dependencies:
|
||||
'@boardgamers/protocol':
|
||||
specifier: 0.6.0
|
||||
version: 0.6.0
|
||||
specifier: 0.6.1
|
||||
version: 0.6.1
|
||||
'@noble/hashes':
|
||||
specifier: 2.0.1
|
||||
version: 2.0.1
|
||||
|
|
@ -27,8 +27,8 @@ importers:
|
|||
|
||||
packages:
|
||||
|
||||
'@boardgamers/protocol@0.6.0':
|
||||
resolution: {integrity: sha512-byHV2eOOFpnQCnhLaM0LPUpT30ew1aAOuTIYxwztkVjg4NgeTyPwjU8Efmc/xi+DGCrfIjo2LTb7YlNUhmzy0g==}
|
||||
'@boardgamers/protocol@0.6.1':
|
||||
resolution: {integrity: sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==}
|
||||
|
||||
'@esbuild/aix-ppc64@0.25.12':
|
||||
resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
|
||||
|
|
@ -220,7 +220,7 @@ packages:
|
|||
|
||||
snapshots:
|
||||
|
||||
'@boardgamers/protocol@0.6.0':
|
||||
'@boardgamers/protocol@0.6.1':
|
||||
dependencies:
|
||||
zod: 4.6.5
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ allowBuilds:
|
|||
esbuild: true
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- '@boardgamers/protocol@0.4.0 || 0.4.2 || 0.5.0 || 0.6.0'
|
||||
- "@boardgamers/protocol@0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1"
|
||||
|
|
|
|||
|
|
@ -90,6 +90,66 @@ try {
|
|||
/Hello/,
|
||||
);
|
||||
assert.equal(await page.evaluate(() => requests.length), 1);
|
||||
|
||||
await page.getByRole("tab", { name: "Journal", exact: true }).click();
|
||||
await page.evaluate(() => {
|
||||
window.restoredReceipts = [];
|
||||
e.on("chat:read", (payload) => restoredReceipts.push(payload));
|
||||
e.emit("chat:state", {
|
||||
canSend: true,
|
||||
readState: { userId: "self", lastReadAt: 500000 },
|
||||
});
|
||||
e.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-count")?.textContent === "1",
|
||||
);
|
||||
await page.waitForTimeout(650);
|
||||
assert.equal(
|
||||
await page.evaluate(
|
||||
() =>
|
||||
restoredReceipts.filter(
|
||||
({ messageId }) => messageId >= "000001f50000000000000001",
|
||||
).length,
|
||||
),
|
||||
0,
|
||||
"journal does not mark restored chat read",
|
||||
);
|
||||
await page.locator(".soup-chat-shortcut").click();
|
||||
await page.waitForFunction(() =>
|
||||
restoredReceipts.some(
|
||||
({ messageId }) => messageId === "000001f70000000000000001",
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
await page.locator(".chat-count").isHidden(),
|
||||
true,
|
||||
"opening chat clears restored unread",
|
||||
);
|
||||
await page.evaluate(() =>
|
||||
e.emit("preferences", { sound: false, analysis: true }),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue