feat: add explicit reorder modes
This commit is contained in:
@@ -554,6 +554,45 @@ describe('task and habit row decoration', () => {
|
||||
expect(mvpPanel.match(/'--reorder-y': `\$\{habitReorder\?\.id === h\.id \? habitReorder\.offsetY : 0\}px`/g)?.length).toBe(1)
|
||||
})
|
||||
|
||||
it('shows task drag handles only in an explicit available reorder mode', () => {
|
||||
expect(app).toContain('const taskReorderMode = ref(false)')
|
||||
expect(app).toContain("const taskReorderAvailable = computed(() => activeView.value === 'tasks' && !query.value && totalPages.value === 1 && taskTree.value.length > 1)")
|
||||
expect(app).toContain('class="soft-button reorder-mode-toggle task-reorder-toggle"')
|
||||
expect(app).toContain("{{ taskReorderMode ? '完成' : '调整顺序' }}")
|
||||
expect(app).toContain('v-if="taskReorderMode" class="drag-handle task-drag-handle"')
|
||||
expect(app).toContain('if (!taskReorderAvailable.value) taskReorderMode.value = false')
|
||||
expect(app).toContain('taskReorderMode.value = false')
|
||||
})
|
||||
|
||||
it('shows habit drag handles only in explicit available reorder mode and never changes Today habits', () => {
|
||||
expect(mvpPanel).toContain('const habitReorderMode = ref(false)')
|
||||
expect(mvpPanel).toContain("const habitReorderAvailable = computed(() => props.view === 'habits' && visibleHabits.value.length > 1)")
|
||||
expect(mvpPanel).toContain('v-if="habitReorderAvailable" class="habit-reorder-toolbar"')
|
||||
expect(mvpPanel).toContain('class="soft-button reorder-mode-toggle habit-reorder-toggle"')
|
||||
expect(mvpPanel).toContain("{{ habitReorderMode ? '完成' : '调整顺序' }}")
|
||||
expect(mvpPanel).toContain('v-if="habitReorderMode && habitReorderAvailable" class="drag-handle habit-drag-handle"')
|
||||
const todayHabits = mvpPanel.slice(mvpPanel.indexOf('<!-- 今日习惯'), mvpPanel.indexOf('<!-- 完整习惯列表'))
|
||||
expect(todayHabits).not.toContain('reorder-mode-toggle')
|
||||
expect(todayHabits).not.toContain('habit-drag-handle')
|
||||
})
|
||||
|
||||
it('reuses the task row completion control in task details', () => {
|
||||
const detailTitle = app.slice(app.indexOf('<div class="detail-title">'), app.indexOf('</div>', app.indexOf('<div class="detail-title">')))
|
||||
expect(detailTitle).toContain('class="task-check detail-task-check"')
|
||||
expect(detailTitle).toContain(':aria-label="selectedTask.completed ? `重新打开${selectedTask.title}` : `完成${selectedTask.title}`"')
|
||||
expect(detailTitle).toContain(':aria-pressed="selectedTask.completed"')
|
||||
expect(detailTitle).toContain('<span class="task-check-mark" :class="`p${selectedTask.priority}`"><Check v-if="selectedTask.completed" /></span>')
|
||||
expect(detailTitle).not.toContain('class="check large"')
|
||||
expect(css).toContain('.detail-title .detail-task-check{width:44px;height:44px;flex:0 0 44px;')
|
||||
})
|
||||
|
||||
it('removes English eyebrows from task and habit composers', () => {
|
||||
expect(app).not.toContain('<small>NEW TASK</small>')
|
||||
expect(mvpPanel).not.toContain("<small>{{ editingHabit ? 'EDIT HABIT' : 'NEW HABIT' }}</small>")
|
||||
expect(app).toContain('<h2 id="task-compose-title">{{ taskComposeTitle }}</h2>')
|
||||
expect(mvpPanel).toContain('<h2 id="habit-compose-title">{{ habitComposerTitle }}</h2>')
|
||||
})
|
||||
|
||||
it('exposes complete titles on every ellipsized visible task title node', () => {
|
||||
expect(app.match(/<strong :title="node\.task\.title">\{\{node\.task\.title\}\}<\/strong>/g)).toHaveLength(2)
|
||||
expect(app).not.toContain('<strong :title="subtask.title">{{subtask.title}}</strong>')
|
||||
@@ -777,7 +816,7 @@ describe('task and habit row decoration', () => {
|
||||
expect(mvpPanel).toContain('v-for="h in visibleTodayHabits"')
|
||||
expect(mvpPanel).toContain('v-for="h in visibleHabits"')
|
||||
expect(mvpPanel).not.toContain(':disabled="!showCompleted"')
|
||||
expect(mvpPanel).toContain('if (busy.value) return')
|
||||
expect(mvpPanel).toContain('if (!habitReorderMode.value || !habitReorderAvailable.value || busy.value) return')
|
||||
expect(mvpPanel).not.toContain('if (busy.value || !props.showCompleted) return')
|
||||
expect(mvpPanel).toContain('const reorderedVisible = moveItemWithinScope(visiblePrevious')
|
||||
expect(mvpPanel).toContain('const next = mergeReorderedSubset(previous, reorderedVisible)')
|
||||
|
||||
Reference in New Issue
Block a user