feat: refine archived habit management
This commit is contained in:
@@ -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>')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user