惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
小众软件
小众软件
V
V2EX
月光博客
月光博客
腾讯CDC
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
D
Docker
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
chore(deadcode): remove telegram topic cache test helpers...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main
11

// Telegram tests cover topic name cache plugin behavior.

22

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

33

import {

4-

clearTopicNameCache,

5-

getTopicEntry,

64

getTopicName,

75

resetTopicNameCacheForTest,

86

setTelegramTopicNameStoreFactoryForTest,

9-

topicNameCacheSize,

107

updateTopicName,

118

} from "./topic-name-cache.js";

12913-

type TopicEntry = NonNullable<Awaited<ReturnType<typeof getTopicEntry>>>;

10+

type TopicEntry = {

11+

name: string;

12+

iconColor?: number;

13+

iconCustomEmojiId?: string;

14+

closed?: boolean;

15+

updatedAt: number;

16+

};

17+18+

function topicKey(chatId: number | string, threadId: number | string): string {

19+

return `${chatId}:${threadId}`;

20+

}

21+22+

function getStoredTopicEntry(

23+

stores: Map<string, Map<string, TopicEntry>>,

24+

chatId: number | string,

25+

threadId: number | string,

26+

): TopicEntry | undefined {

27+

const key = topicKey(chatId, threadId);

28+

for (const entries of stores.values()) {

29+

const entry = entries.get(key);

30+

if (entry) {

31+

return entry;

32+

}

33+

}

34+

return undefined;

35+

}

36+37+

function topicStoreSize(stores: Map<string, Map<string, TopicEntry>>): number {

38+

return Array.from(stores.values(), (entries) => entries.size).reduce(

39+

(total, size) => total + size,

40+

0,

41+

);

42+

}

14431544

function installMemoryStores() {

1645

const stores = new Map<string, Map<string, TopicEntry>>();

@@ -36,10 +65,11 @@ function installMemoryStores() {

3665

}

37663867

describe("topic-name-cache", () => {

68+

let stores: Map<string, Map<string, TopicEntry>>;

69+3970

beforeEach(async () => {

4071

vi.useRealTimers();

41-

installMemoryStores();

42-

await clearTopicNameCache();

72+

stores = installMemoryStores();

4373

resetTopicNameCacheForTest();

4474

});

4575

@@ -67,13 +97,13 @@ describe("topic-name-cache", () => {

6797

await updateTopicName(-100123, 42, { name: "Deployments" });

6898

await updateTopicName(-100123, 42, { closed: true });

6999

await expect(getTopicName(-100123, 42)).resolves.toBe("Deployments");

70-

expect((await getTopicEntry(-100123, 42))?.closed).toBe(true);

100+

expect(getStoredTopicEntry(stores, -100123, 42)?.closed).toBe(true);

71101

});

7210273103

it("marks topic as reopened", async () => {

74104

await updateTopicName(-100123, 42, { name: "Deployments", closed: true });

75105

await updateTopicName(-100123, 42, { closed: false });

76-

expect((await getTopicEntry(-100123, 42))?.closed).toBe(false);

106+

expect(getStoredTopicEntry(stores, -100123, 42)?.closed).toBe(false);

77107

});

7810879109

it("stores icon metadata", async () => {

@@ -82,24 +112,24 @@ describe("topic-name-cache", () => {

82112

iconColor: 0x6fb9f0,

83113

iconCustomEmojiId: "emoji123",

84114

});

85-

const entry = await getTopicEntry(-100123, 42);

115+

const entry = getStoredTopicEntry(stores, -100123, 42);

86116

expect(entry?.iconColor).toBe(0x6fb9f0);

87117

expect(entry?.iconCustomEmojiId).toBe("emoji123");

88118

});

8911990120

it("does not store entries with empty name and no prior entry", async () => {

91121

await updateTopicName(-100123, 42, { closed: true });

92122

await expect(getTopicName(-100123, 42)).resolves.toBeUndefined();

93-

expect(topicNameCacheSize()).toBe(0);

123+

expect(topicStoreSize(stores)).toBe(0);

94124

});

9512596126

it("updates timestamps on write", async () => {

97127

vi.useFakeTimers();

98128

await updateTopicName(-100123, 42, { name: "A" });

99-

const t1 = (await getTopicEntry(-100123, 42))?.updatedAt ?? 0;

129+

const t1 = getStoredTopicEntry(stores, -100123, 42)?.updatedAt ?? 0;

100130

await vi.advanceTimersByTimeAsync(10);

101131

await updateTopicName(-100123, 42, { name: "B" });

102-

const t2 = (await getTopicEntry(-100123, 42))?.updatedAt ?? 0;

132+

const t2 = getStoredTopicEntry(stores, -100123, 42)?.updatedAt ?? 0;

103133

expect(t2).toBeGreaterThan(t1);

104134

});

105135

@@ -112,7 +142,7 @@ describe("topic-name-cache", () => {

112142

for (let i = 0; i < 2049; i++) {

113143

await updateTopicName(-100000, i, { name: `Topic ${i}` });

114144

}

115-

expect(topicNameCacheSize()).toBe(2048);

145+

expect(topicStoreSize(stores)).toBe(2048);

116146

await expect(getTopicName(-100000, 0)).resolves.toBeUndefined();

117147

await expect(getTopicName(-100000, 2048)).resolves.toBe("Topic 2048");

118148

});

@@ -127,7 +157,7 @@ describe("topic-name-cache", () => {

127157

await getTopicName(-100000, 1);

128158

await updateTopicName(-100000, 9999, { name: "Newcomer" });

129159

await expect(getTopicName(-100000, 1)).resolves.toBe("Active");

130-

expect(topicNameCacheSize()).toBe(2048);

160+

expect(topicStoreSize(stores)).toBe(2048);

131161

});

132162133163

it("reloads persisted entries from plugin state", async () => {