fix: refresh tasks after completion
This commit is contained in:
@@ -499,7 +499,11 @@ async function patchTask(task: Task, patch: Partial<Task>) {
|
||||
async function toggle(task: Task) {
|
||||
try {
|
||||
await patchTask(task, { completed: !task.completed })
|
||||
if (activeView.value === 'today') void loadTodayTaskSummary()
|
||||
await loadTasksPage()
|
||||
if (activeView.value === 'today') {
|
||||
await loadOverdueTasks()
|
||||
void loadTodayTaskSummary()
|
||||
}
|
||||
toast(task.completed ? '已重新打开' : '完成啦')
|
||||
} catch (reason) { fail(reason) }
|
||||
}
|
||||
|
||||
@@ -101,6 +101,15 @@ describe('task and habit row decoration', () => {
|
||||
expect(css).toContain('.task-check:focus-visible{')
|
||||
})
|
||||
|
||||
it('refreshes the current task data after toggling completion', () => {
|
||||
const toggleBlock = app.slice(app.indexOf('async function toggle(task: Task)'), app.indexOf('function isInteractiveTarget'))
|
||||
expect(toggleBlock).toContain('await patchTask(task, { completed: !task.completed })')
|
||||
expect(toggleBlock).toContain('await loadTasksPage()')
|
||||
expect(toggleBlock).toContain("if (activeView.value === 'today')")
|
||||
expect(toggleBlock).toContain('await loadOverdueTasks()')
|
||||
expect(toggleBlock).toContain('void loadTodayTaskSummary()')
|
||||
})
|
||||
|
||||
it('shows the same visible round check control for boolean and numeric habits in both views', () => {
|
||||
expect(mvpPanel).not.toContain('class="sr-only" :aria-label="isDone(h, todayKey)')
|
||||
expect(mvpPanel.match(/class="task-check habit-check"/g)?.length).toBe(2)
|
||||
|
||||
Reference in New Issue
Block a user