
















@@ -418,13 +418,21 @@ describe("monitorMatrixProvider", () => {
418418}
419419420420function mockCallArg(mock: { mock: { calls: unknown[][] } }, index = 0, argIndex = 0): unknown {
421-const call = mock.mock.calls[index];
421+const call = mock.mock.calls.at(index);
422422if (!call) {
423423throw new Error(`expected mock call ${index}`);
424424}
425425return call[argIndex];
426426}
427427428+function directRoomTrackerOptions(): DirectRoomTrackerOptions {
429+const opts = mockCallArg(hoisted.createDirectRoomTracker, 0, 1);
430+if (!opts || typeof opts !== "object") {
431+throw new Error("expected direct room tracker options");
432+}
433+return opts as DirectRoomTrackerOptions;
434+}
435+428436function lastMockCallArg(mock: { mock: { calls: unknown[][] } }, argIndex = 0): unknown {
429437const call = mock.mock.calls.at(-1);
430438if (!call) {
@@ -811,12 +819,9 @@ describe("monitorMatrixProvider", () => {
811819it("resolves text chunk limit for the effective Matrix account", async () => {
812820await startMonitorAndAbortAfterStartup();
813821814-const textLimitCall = hoisted.resolveTextChunkLimit.mock.calls[0];
815-if (textLimitCall?.[0] === undefined) {
816-throw new Error("Expected Matrix text chunk limit config argument");
817-}
818-expect(textLimitCall?.[1]).toBe("matrix");
819-expect(textLimitCall?.[2]).toBe("default");
822+expect(mockCallArg(hoisted.resolveTextChunkLimit, 0, 0)).toBeDefined();
823+expect(mockCallArg(hoisted.resolveTextChunkLimit, 0, 1)).toBe("matrix");
824+expect(mockCallArg(hoisted.resolveTextChunkLimit, 0, 2)).toBe("default");
820825});
821826822827it("starts monitoring without waiting for best-effort deviceId backfill", async () => {
@@ -931,7 +936,7 @@ describe("monitorMatrixProvider", () => {
931936it("wires recent-invite promotion to fail closed when room metadata is unresolved", async () => {
932937await startMonitorAndAbortAfterStartup();
933938934-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
939+const trackerOpts = directRoomTrackerOptions();
935940if (!trackerOpts?.canPromoteRecentInvite) {
936941throw new Error("recent invite promotion callback was not wired");
937942}
@@ -948,7 +953,7 @@ describe("monitorMatrixProvider", () => {
948953it("wires recent-invite promotion to reject named rooms", async () => {
949954await startMonitorAndAbortAfterStartup();
950955951-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
956+const trackerOpts = directRoomTrackerOptions();
952957if (!trackerOpts?.canPromoteRecentInvite) {
953958throw new Error("recent invite promotion callback was not wired");
954959}
@@ -970,7 +975,7 @@ describe("monitorMatrixProvider", () => {
970975971976await startMonitorAndAbortAfterStartup();
972977973-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
978+const trackerOpts = directRoomTrackerOptions();
974979if (!trackerOpts?.canPromoteRecentInvite) {
975980throw new Error("recent invite promotion callback was not wired");
976981}
@@ -987,7 +992,7 @@ describe("monitorMatrixProvider", () => {
987992it("does not wire unmapped strict room promotion for per-user DM scope", async () => {
988993await startMonitorAndAbortAfterStartup();
989994990-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
995+const trackerOpts = directRoomTrackerOptions();
991996992997expect(trackerOpts?.canPromoteUnmappedStrictRoom).toBeUndefined();
993998});
@@ -997,7 +1002,7 @@ describe("monitorMatrixProvider", () => {
99710029981003await startMonitorAndAbortAfterStartup();
99910041000-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
1005+const trackerOpts = directRoomTrackerOptions();
10011006if (!trackerOpts?.canPromoteUnmappedStrictRoom) {
10021007throw new Error("per-room strict fallback callback was not wired");
10031008}
@@ -1021,7 +1026,7 @@ describe("monitorMatrixProvider", () => {
10211026it("treats unresolved room metadata as indeterminate for local promotion revalidation", async () => {
10221027await startMonitorAndAbortAfterStartup();
102310281024-const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
1029+const trackerOpts = directRoomTrackerOptions();
10251030if (!trackerOpts?.shouldKeepLocallyPromotedDirectRoom) {
10261031throw new Error("local promotion revalidation callback was not wired");
10271032}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。