perf: streamline view data loading
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m29s

This commit is contained in:
2026-09-10 08:06:52 +08:00
parent a5ece8ca42
commit 98578b4f36
7 changed files with 545 additions and 75 deletions
+9 -11
View File
@@ -227,7 +227,7 @@ describe('mobile list row language', () => {
it('provides a minimal archived-habit viewing path', () => {
expect(mvpPanel).toContain("request('/habits?archived=true')")
expect(mvpPanel).toContain('已归档({{ archivedHabits.length }}')
expect(mvpPanel).toContain("{{ archivedHabitsLoaded ? `已归档(${archivedHabits.length}` : '已归档' }}")
expect(mvpPanel).toContain('v-for="h in archivedHabits"')
})
@@ -319,14 +319,13 @@ describe('task and habit row decoration', () => {
expect(css).toContain('.task-check:focus-visible{')
})
it('refreshes the current task data after toggling completion', () => {
it('reconciles concurrent completion mutations without suppressing their feedback', () => {
const toggleBlock = app.slice(app.indexOf('async function toggle(task: Task)'), app.indexOf('function isInteractiveTarget'))
expect(toggleBlock).toContain('const completing = !task.completed')
expect(toggleBlock).toContain('await patchTask(task, { completed: completing })')
expect(toggleBlock).toContain('await loadTasksPage()')
expect(toggleBlock).toContain("if (activeView.value === 'today')")
expect(toggleBlock).toContain('await loadOverdueTasks()')
expect(toggleBlock).toContain('void loadTodayTaskSummary()')
expect(toggleBlock).toContain('await taskMutationReconciler.run(')
expect(toggleBlock).toContain("() => toast(completing ? '完成啦' : '已重新打开')")
expect(toggleBlock).toContain('applyTaskUpdate(task, updated)')
expect(toggleBlock).not.toContain("beginLatestRequest('tasks')")
})
it('shows the same visible round check control for boolean and numeric habits in both views', () => {
@@ -634,11 +633,10 @@ describe('unified floating add interaction', () => {
expect(app).toContain('重复次数')
})
it('preloads countdowns after authentication', () => {
it('preloads countdowns through the shared cache after authentication', () => {
expect(app).toContain('void preloadCountdowns()')
expect(app).toContain("const active = await api('/countdowns')")
expect(app).toContain("const archived = await api('/countdowns?archived=true')")
expect(app).toContain('writeCountdownCache(active ?? [], archived ?? [])')
expect(app).toContain('await loadCountdownCache(async () =>')
expect(app).toContain("Promise.all([api('/countdowns'), api('/countdowns?archived=true')])")
})
it('reuses one draggable FAB component for task, habit, and countdown views', () => {