test: lotus decorations, call caps, crypto, featureCheck, typing, markdown (+34)

Subagent batch (no bugs found) + markdown:
- lotus/avatarDecorations (8): decorationUrl, CDN shape, ALL_DECORATIONS
  flattening, data invariants (unique category ids + slugs, slug charset).
- plugins/call/utils (7): getCallCapabilities — static caps + room/user/device
  scoped state-keys.
- utils/matrix-crypto (3): verifiedDevice via a stubbed CryptoApi.
- utils/featureCheck (3): checkIndexedDBSupport success/error/throw paths.
- state/typingMembers (8): add/dedup-by-latest-ts/per-room-scope/delete reducer
  via a jotai store (enableMapSet, mirroring app startup).
- plugins/markdown/utils (5): inline + block escape/unescape round-trips.

Full suite now 231 tests, all passing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 14:32:53 -04:00
parent 9f4516c6a8
commit 6e59395fb8
6 changed files with 385 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
import { test, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import { checkIndexedDBSupport } from './featureCheck';
// `checkIndexedDBSupport` resolves by talking to the global `indexedDB`. There
// is no real IndexedDB in this Node test environment, so each case installs a
// minimal stub on `globalThis.indexedDB` and restores it afterwards.
type OpenRequest = {
onsuccess?: () => void;
onerror?: () => void;
};
const originalIndexedDB = (globalThis as { indexedDB?: unknown }).indexedDB;
afterEach(() => {
(globalThis as { indexedDB?: unknown }).indexedDB = originalIndexedDB;
});
const installIndexedDB = (impl: unknown) => {
(globalThis as { indexedDB?: unknown }).indexedDB = impl;
};
test('resolves true when the open request fires onsuccess', async () => {
let deleted = false;
installIndexedDB({
open: (): OpenRequest => {
const req: OpenRequest = {};
// fire async, mimicking the real event loop
queueMicrotask(() => req.onsuccess?.());
return req;
},
deleteDatabase: () => {
deleted = true;
},
});
assert.equal(await checkIndexedDBSupport(), true);
assert.equal(deleted, true);
});
test('resolves false when the open request fires onerror', async () => {
installIndexedDB({
open: (): OpenRequest => {
const req: OpenRequest = {};
queueMicrotask(() => req.onerror?.());
return req;
},
deleteDatabase: () => {},
});
assert.equal(await checkIndexedDBSupport(), false);
});
test('resolves false when indexedDB.open throws synchronously', async () => {
installIndexedDB({
open: () => {
throw new Error('blocked');
},
deleteDatabase: () => {},
});
assert.equal(await checkIndexedDBSupport(), false);
});
+42
View File
@@ -0,0 +1,42 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { CryptoApi } from 'matrix-js-sdk/lib/crypto-api';
import { verifiedDevice } from './matrix-crypto';
// `verifiedDevice` only touches `api.getDeviceVerificationStatus`, so a tiny
// stub standing in for the real CryptoApi is enough to exercise the pure logic.
// Anything requiring an actual crypto backend (key import, cross-signing setup,
// etc.) is out of scope here and intentionally not covered.
const cryptoApi = (status: unknown): CryptoApi =>
({
getDeviceVerificationStatus: async () => status,
}) as unknown as CryptoApi;
test('verifiedDevice returns null when there is no verification status', async () => {
assert.equal(await verifiedDevice(cryptoApi(null), '@a:b', 'DEV'), null);
assert.equal(await verifiedDevice(cryptoApi(undefined), '@a:b', 'DEV'), null);
});
test('verifiedDevice surfaces crossSigningVerified when status exists', async () => {
assert.equal(
await verifiedDevice(cryptoApi({ crossSigningVerified: true }), '@a:b', 'DEV'),
true,
);
assert.equal(
await verifiedDevice(cryptoApi({ crossSigningVerified: false }), '@a:b', 'DEV'),
false,
);
});
test('verifiedDevice forwards userId and deviceId to the crypto api', async () => {
let received: [string, string] | undefined;
const api = {
getDeviceVerificationStatus: async (userId: string, deviceId: string) => {
received = [userId, deviceId];
return { crossSigningVerified: true };
},
} as unknown as CryptoApi;
await verifiedDevice(api, '@alice:example.org', 'ABCDEF');
assert.deepEqual(received, ['@alice:example.org', 'ABCDEF']);
});