feat(grid): add clock-hand progress animation to auto refresh

This commit is contained in:
zipg authored and GitHub committed 2026-09-24 12:13:47 +08:00
1 parent 6517284d95
commit e8e2625801
10 files changed
+185 -2

No files matched your search

@@ -29,4 +29,50 @@ describe("useDataGridAutoRefresh", () => {
expect(refresh).not.toHaveBeenCalled();
autoRefresh.stop();
});
it("bumps the sweep key when the countdown is armed and on every tick", () => {
vi.useFakeTimers();
const autoRefresh = useDataGridAutoRefresh({ canRefresh: computed(() => true), refresh: vi.fn(), initialIntervalSeconds: 5 });
expect(autoRefresh.sweepKey.value).toBe(0);
autoRefresh.toggle();
expect(autoRefresh.sweepKey.value).toBe(1);
vi.advanceTimersByTime(5000);
expect(autoRefresh.sweepKey.value).toBe(2);
vi.advanceTimersByTime(5000);
expect(autoRefresh.sweepKey.value).toBe(3);
autoRefresh.stop();
});
it("bumps the sweep key when the interval changes while enabled", () => {
vi.useFakeTimers();
const autoRefresh = useDataGridAutoRefresh({ canRefresh: computed(() => true), refresh: vi.fn(), initialIntervalSeconds: 5 });
autoRefresh.toggle();
expect(autoRefresh.sweepKey.value).toBe(1);
autoRefresh.setIntervalSeconds(30);
expect(autoRefresh.sweepKey.value).toBe(2);
expect(autoRefresh.intervalSeconds.value).toBe(30);
autoRefresh.stop();
});
it("keeps sweeping through skipped refreshes and freezes once disabled", () => {
vi.useFakeTimers();
const autoRefresh = useDataGridAutoRefresh({ canRefresh: computed(() => false), refresh: vi.fn(), initialIntervalSeconds: 1 });
autoRefresh.toggle();
vi.advanceTimersByTime(2000);
expect(autoRefresh.sweepKey.value).toBe(3);
autoRefresh.toggle();
vi.advanceTimersByTime(5000);
expect(autoRefresh.enabled.value).toBe(false);
expect(autoRefresh.sweepKey.value).toBe(3);
});
});