+7
-7
@@ -18,7 +18,6 @@ const status = (plan: string, remaining: number): QuotaStatus => ({
|
||||
used: 100 - remaining,
|
||||
resetsAt: 2,
|
||||
remaining,
|
||||
sessionConsumed: 1.5,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -32,13 +31,13 @@ test("built quota slot stays reactive across pending, empty, failure, update, an
|
||||
const { default: plugin } = tui;
|
||||
const pending = Promise.withResolvers<QuotaStatus | null>();
|
||||
const responses: Array<() => Promise<QuotaStatus | null>> = [() => pending.promise];
|
||||
const sessions: string[] = [];
|
||||
let statusCalls = 0;
|
||||
let slotRender: SlotRender | undefined;
|
||||
let notifyUpdated: (() => void) | undefined;
|
||||
|
||||
const quota = {
|
||||
status(input: { sessionID: string }) {
|
||||
sessions.push(input.sessionID);
|
||||
status() {
|
||||
statusCalls++;
|
||||
const response = responses.shift();
|
||||
if (!response) throw new Error("Missing test response");
|
||||
return response();
|
||||
@@ -84,7 +83,8 @@ test("built quota slot stays reactive across pending, empty, failure, update, an
|
||||
|
||||
pending.resolve(status("plus", 75));
|
||||
await setup.waitForFrame((frame) => frame.includes("ChatGPT quota (plus)"));
|
||||
expect(setup.captureCharFrame()).toContain("5h: 75% · ~1.5pp · due");
|
||||
expect(setup.captureCharFrame()).toContain("5h: 75% · due");
|
||||
expect(setup.captureCharFrame()).not.toContain("~");
|
||||
|
||||
responses.push(async () => null);
|
||||
notifyUpdated();
|
||||
@@ -94,13 +94,13 @@ test("built quota slot stays reactive across pending, empty, failure, update, an
|
||||
throw new Error("disconnected");
|
||||
});
|
||||
notifyUpdated();
|
||||
await setup.waitFor(() => sessions.length === 3);
|
||||
await setup.waitFor(() => statusCalls === 3);
|
||||
expect(setup.captureCharFrame()).not.toContain("ChatGPT quota");
|
||||
|
||||
responses.push(async () => status("pro", 42));
|
||||
setSessionID("session-two");
|
||||
await setup.waitForFrame((frame) => frame.includes("ChatGPT quota (pro)"));
|
||||
expect(sessions).toEqual(["session-one", "session-one", "session-one", "session-two"]);
|
||||
expect(statusCalls).toBe(4);
|
||||
} finally {
|
||||
setup.renderer.destroy();
|
||||
if (cleanup) await cleanup();
|
||||
|
||||
Reference in New Issue
Block a user