feat: refine archived habit management
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m28s

This commit is contained in:
2026-09-10 14:39:06 +08:00
parent bf61e69776
commit 3e80f2ecbb
8 changed files with 515 additions and 34 deletions
+9 -7
View File
@@ -219,18 +219,20 @@ describe('request generation protection', () => {
describe('habit request boundaries', () => {
it('never loads archived habits for embedded Today habits and loads them lazily on Habits', () => {
const mounted = habits.slice(habits.indexOf('onMounted(() =>'), habits.indexOf('onBeforeUnmount(() =>'))
const archiveBlock = habits.slice(habits.indexOf('async function archiveHabit'), habits.indexOf('async function deleteHabit'))
const archiveBlock = habits.slice(habits.indexOf('async function archiveHabit'), habits.indexOf('async function restoreHabit'))
const loadBlock = habits.slice(habits.indexOf('async function loadArchivedHabits'), habits.indexOf('async function toggleArchivedHabits'))
expect(mounted).not.toContain('loadArchivedHabits()')
expect(archiveBlock).toContain("if (props.view === 'habits' && showArchivedHabits.value)")
expect(habits).toContain('if (showArchivedHabits.value && !archivedHabitsLoaded.value)')
expect(habits).toContain("{{ archivedHabitsLoaded ? `已归档(${archivedHabits.length}` : '已归档' }}")
expect(loadBlock).toContain("if (props.view !== 'habits'")
expect(habits).toContain("archiveState === 'success' ? `已归档(${archivedHabits.length}` : '已归档'")
})
it('does not render an empty archive until loading succeeds and allows collapse-reopen retry', () => {
it('does not render an empty archive until loading succeeds and retries after failure', () => {
const toggleBlock = habits.slice(habits.indexOf('async function toggleArchivedHabits'), habits.indexOf('function refreshHabitDay'))
expect(toggleBlock).toContain('showArchivedHabits.value && !archivedHabitsLoaded.value')
expect(habits).toContain('v-if="archivedHabitsLoaded && !archivedHabits.length && !busy"')
expect(habits).not.toContain('v-if="!archivedHabits.length && !busy" class="empty-panel">暂无已归档习惯。')
expect(toggleBlock).toContain("showArchivedHabits.value && archiveState.value !== 'success'")
expect(habits).toContain('v-else-if="archiveFlags.empty"')
expect(habits).toContain("v-else-if=\"archiveState === 'error'\"")
expect(habits).toContain('@click="loadArchivedHabits">重试</button>')
})
})