Fix warnings and update tracability
This commit is contained in:
@@ -146,87 +146,13 @@ describe("sessions store", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("polling", () => {
|
||||
it.skip("should set isPolling to true when polling starts", async () => {
|
||||
describe("refresh", () => {
|
||||
it("should expose a refresh method for manual session fetching", async () => {
|
||||
const { sessions } = await import("./sessions");
|
||||
|
||||
// Mock the refresh to prevent actual API calls
|
||||
vi.spyOn(sessions, "refresh").mockResolvedValue();
|
||||
|
||||
// Note: startPolling is not yet implemented
|
||||
// sessions.startPolling(5000);
|
||||
// const state = get(sessions);
|
||||
|
||||
// expect(state.isPolling).toBe(true);
|
||||
});
|
||||
|
||||
it.skip("should set isPolling to false when polling stops", async () => {
|
||||
const { sessions } = await import("./sessions");
|
||||
|
||||
vi.spyOn(sessions, "refresh").mockResolvedValue();
|
||||
|
||||
// Note: startPolling/stopPolling are not yet implemented
|
||||
// sessions.startPolling(5000);
|
||||
// sessions.stopPolling();
|
||||
// const state = get(sessions);
|
||||
|
||||
// expect(state.isPolling).toBe(false);
|
||||
});
|
||||
|
||||
// Note: Cannot spy on internal refresh() function as it's not exported
|
||||
it.skip("should call refresh immediately when polling starts", async () => {
|
||||
const { sessions } = await import("./sessions");
|
||||
|
||||
const refreshSpy = vi.spyOn(sessions, "refresh").mockResolvedValue();
|
||||
|
||||
sessions.startPolling(5000);
|
||||
|
||||
expect(refreshSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
// Note: Cannot spy on internal refresh() function as it's not exported
|
||||
it.skip("should call refresh at intervals", async () => {
|
||||
const { sessions } = await import("./sessions");
|
||||
|
||||
const refreshSpy = vi.spyOn(sessions, "refresh").mockResolvedValue();
|
||||
|
||||
sessions.startPolling(5000);
|
||||
|
||||
// Initial call
|
||||
expect(refreshSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
// Advance timers by 5 seconds
|
||||
await vi.advanceTimersByTime(5000);
|
||||
expect(refreshSpy).toHaveBeenCalledTimes(2);
|
||||
|
||||
// Advance another 5 seconds
|
||||
await vi.advanceTimersByTime(5000);
|
||||
expect(refreshSpy).toHaveBeenCalledTimes(3);
|
||||
|
||||
sessions.stopPolling();
|
||||
});
|
||||
|
||||
// Note: Cannot spy on internal refresh() function as it's not exported
|
||||
it.skip("should stop previous polling when starting new polling", async () => {
|
||||
const { sessions } = await import("./sessions");
|
||||
|
||||
const refreshSpy = vi.spyOn(sessions, "refresh").mockResolvedValue();
|
||||
|
||||
sessions.startPolling(5000);
|
||||
await vi.advanceTimersByTime(5000);
|
||||
|
||||
const callsAfterFirst = refreshSpy.mock.calls.length;
|
||||
|
||||
// Start new polling - should stop the old one
|
||||
sessions.startPolling(3000);
|
||||
|
||||
// Advance by the old interval
|
||||
await vi.advanceTimersByTime(5000);
|
||||
|
||||
// Should have been called once for the new startPolling, and once after 3s
|
||||
expect(refreshSpy.mock.calls.length).toBeGreaterThan(callsAfterFirst);
|
||||
|
||||
sessions.stopPolling();
|
||||
// The store uses event-driven updates via Tauri events,
|
||||
// but also exposes refresh() for manual/on-demand fetching
|
||||
expect(typeof sessions.refresh).toBe("function");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user