feat: auto-refresh calendar subscriptions
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m29s

This commit is contained in:
2026-09-21 15:36:09 +08:00
parent a970a03f5d
commit 97c1bd4e87
6 changed files with 257 additions and 42 deletions
+2
View File
@@ -92,6 +92,7 @@ describe('CalendarPanel',()=>{
vi.useRealTimers()
})
it('keeps the newest week response when requests finish out of order',async()=>{
vi.useFakeTimers();vi.setSystemTime(new Date(2026,8,20,10))
const pending:Array<{url:string;resolve:(response:Response)=>void}>=[]
const fetchMock=vi.fn((url:string)=>String(url).includes('calendar-events')?new Promise<Response>(resolve=>pending.push({url:String(url),resolve})):Promise.resolve(json(subscriptions)))
const {host}=await mount(fetchMock)
@@ -102,6 +103,7 @@ describe('CalendarPanel',()=>{
pending[0].resolve(json({events:[{...events[0],id:'old',title:'旧一周'}],sources:[]}));await flush()
expect(host.textContent).toContain('新一周')
expect(host.textContent).not.toContain('旧一周')
vi.useRealTimers()
})
it('supports week navigation and today',async()=>{
const fetchMock=vi.fn((url:string)=>Promise.resolve(json(url.includes('calendar-events')?{events:[],sources:[]}:subscriptions)))