mirror of https://github.com/openclaw/openclaw.git
test: share discord auto presence assertions
This commit is contained in:
parent
143ae5a5b0
commit
8ddb531346
|
|
@ -29,8 +29,7 @@ function createStore(params?: {
|
|||
};
|
||||
}
|
||||
|
||||
describe("discord auto presence", () => {
|
||||
it("maps exhausted runtime signal to dnd", () => {
|
||||
function expectExhaustedDecision(params: { failureCounts: Record<string, number> }) {
|
||||
const now = Date.now();
|
||||
const decision = resolveDiscordAutoPresenceDecision({
|
||||
discordConfig: {
|
||||
|
|
@ -39,7 +38,7 @@ describe("discord auto presence", () => {
|
|||
exhaustedText: "token exhausted",
|
||||
},
|
||||
},
|
||||
authStore: createStore({ cooldownUntil: now + 60_000, failureCounts: { rate_limit: 2 } }),
|
||||
authStore: createStore({ cooldownUntil: now + 60_000, failureCounts: params.failureCounts }),
|
||||
gatewayConnected: true,
|
||||
now,
|
||||
});
|
||||
|
|
@ -48,26 +47,15 @@ describe("discord auto presence", () => {
|
|||
expect(decision?.state).toBe("exhausted");
|
||||
expect(decision?.presence.status).toBe("dnd");
|
||||
expect(decision?.presence.activities[0]?.state).toBe("token exhausted");
|
||||
}
|
||||
|
||||
describe("discord auto presence", () => {
|
||||
it("maps exhausted runtime signal to dnd", () => {
|
||||
expectExhaustedDecision({ failureCounts: { rate_limit: 2 } });
|
||||
});
|
||||
|
||||
it("treats overloaded cooldown as exhausted", () => {
|
||||
const now = Date.now();
|
||||
const decision = resolveDiscordAutoPresenceDecision({
|
||||
discordConfig: {
|
||||
autoPresence: {
|
||||
enabled: true,
|
||||
exhaustedText: "token exhausted",
|
||||
},
|
||||
},
|
||||
authStore: createStore({ cooldownUntil: now + 60_000, failureCounts: { overloaded: 2 } }),
|
||||
gatewayConnected: true,
|
||||
now,
|
||||
});
|
||||
|
||||
expect(decision).toBeTruthy();
|
||||
expect(decision?.state).toBe("exhausted");
|
||||
expect(decision?.presence.status).toBe("dnd");
|
||||
expect(decision?.presence.activities[0]?.state).toBe("token exhausted");
|
||||
expectExhaustedDecision({ failureCounts: { overloaded: 2 } });
|
||||
});
|
||||
|
||||
it("recovers from exhausted to online once a profile becomes usable", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue