Skip to content

Commit d3f4ab6

Browse files
committed
fix(staged): revert qe-verify when dragging back to original column
When a bug is dragged to in-testing, handleBugMove auto-stages both the status change and qe-verify+. Previously, dragging back to the original column only reverted the status change, leaving qe-verify orphaned. Now handleBugMove detects when the status change is reverted and also reverts any auto-staged qe-verify change.
1 parent efb5440 commit d3f4ab6

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/App.test.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,56 @@ describe('App', () => {
446446
expect(change?.status).toEqual({ from: 'done', to: 'in-testing' })
447447
expect(change?.qeVerify).toBeUndefined()
448448
})
449+
450+
it('should revert qe-verify when dragging from in-testing back to original column', () => {
451+
// This test simulates handleBugMove flow:
452+
// 1. User drags bug from 'todo' to 'in-testing' (auto-stages qe-verify+)
453+
// 2. User drags bug back to 'todo' (should revert ALL staged changes)
454+
const { stageChange, stageQeVerifyChange } = useStore.getState()
455+
456+
// Step 1: Simulate handleBugMove(123, 'todo', 'in-testing')
457+
// This stages status and auto-stages qe-verify+
458+
stageChange(123, 'todo', 'in-testing')
459+
stageQeVerifyChange(123, 'unknown', 'plus')
460+
461+
// Verify intermediate state
462+
let changes = useStore.getState().changes
463+
expect(changes.get(123)?.status).toEqual({ from: 'todo', to: 'in-testing' })
464+
expect(changes.get(123)?.qeVerify).toEqual({ from: 'unknown', to: 'plus' })
465+
466+
// Step 2: Simulate handleBugMove(123, 'in-testing', 'todo')
467+
// Capture existing change before stageChange (as handleBugMove does)
468+
const existingChange = useStore.getState().changes.get(123)
469+
stageChange(123, 'in-testing', 'todo')
470+
471+
// handleBugMove detects status was reverted and also reverts qeVerify
472+
const updatedChange = useStore.getState().changes.get(123)
473+
if (existingChange?.qeVerify && !updatedChange?.status) {
474+
stageQeVerifyChange(123, 'unknown', 'unknown')
475+
}
476+
477+
// Expected: no changes should remain (both status and qeVerify reverted)
478+
changes = useStore.getState().changes
479+
expect(changes.has(123)).toBe(false)
480+
})
481+
482+
it('should keep qe-verify when moving from in-testing to a different column (not original)', () => {
483+
// Flow: todo -> in-testing -> done
484+
// qe-verify+ should persist since we're not reverting to original
485+
const { stageChange, stageQeVerifyChange } = useStore.getState()
486+
487+
// Step 1: todo -> in-testing
488+
stageChange(123, 'todo', 'in-testing')
489+
stageQeVerifyChange(123, 'unknown', 'plus')
490+
491+
// Step 2: in-testing -> done (different from original 'todo')
492+
stageChange(123, 'in-testing', 'done')
493+
494+
// qe-verify should still be staged (we want it applied)
495+
const changes = useStore.getState().changes
496+
const change = changes.get(123)
497+
expect(change?.status).toEqual({ from: 'todo', to: 'done' })
498+
expect(change?.qeVerify).toEqual({ from: 'unknown', to: 'plus' })
499+
})
449500
})
450501
})

src/App.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ function App() {
158158
// Handle bug move (drag and drop)
159159
const handleBugMove = useCallback(
160160
(bugId: number, fromColumn: string, toColumn: string) => {
161+
// Capture existing staged change before stageChange modifies the store
162+
const existingChange = changes.get(bugId)
163+
161164
stageChange(bugId, fromColumn, toColumn)
162165

163166
const bug = bugs.find((b) => b.id === bugId)
@@ -188,10 +191,18 @@ function App() {
188191
if (currentQeVerify !== 'plus') {
189192
stageQeVerifyChange(bugId, currentQeVerify, 'plus')
190193
}
194+
} else if (existingChange?.qeVerify) {
195+
// Revert auto-staged qe-verify+ when moving away from in-testing
196+
// Check if status was also reverted (back to original column)
197+
const updatedChange = useStore.getState().changes.get(bugId)
198+
if (!updatedChange?.status) {
199+
const currentQeVerify = getQeVerifyStatus(bug.flags)
200+
stageQeVerifyChange(bugId, currentQeVerify, currentQeVerify)
201+
}
191202
}
192203
}
193204
},
194-
[stageChange, bugs, stageWhiteboardChange, stageQeVerifyChange],
205+
[stageChange, bugs, stageWhiteboardChange, stageQeVerifyChange, changes],
195206
)
196207

197208
// Handle assignee change

0 commit comments

Comments
 (0)