-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
The TestBrowserDeleteFlow test in todos-components fails - the delete confirmation modal works correctly but the todo is not actually deleted.
Symptoms
- Click delete button on a todo → Modal appears ✓
- Click confirm button in modal → Modal closes ✓
- Todo should be deleted → Still present ✗
Root Cause Analysis
The issue appears to be that state.DeleteID is 0 when ConfirmDeleteConfirm is called, even though ConfirmDelete sets it:
// ConfirmDelete sets DeleteID when showing modal
func (c *TodoController) ConfirmDelete(state TodoState, ctx *livetemplate.Context) (TodoState, error) {
idStr := ctx.GetString("id")
state.DeleteID = atoi(idStr) // Sets DeleteID
state.DeleteConfirm.Show()
return state, nil
}
// ConfirmDeleteConfirm expects DeleteID to be set
func (c *TodoController) ConfirmDeleteConfirm(state TodoState, ctx *livetemplate.Context) (TodoState, error) {
for i := range state.Todos {
if state.Todos[i].ID == state.DeleteID { // DeleteID is 0 here!
state.Todos = append(state.Todos[:i], state.Todos[i+1:]...)
// ...
}
}
state.DeleteConfirm.Hide() // This works, so the handler IS called
// ...
}The modal closing confirms that ConfirmDeleteConfirm is being called and Hide() works. But the todo isn't deleted, which means the loop didn't find a matching ID (because DeleteID was 0).
Potential Causes
- State not persisted between WebSocket actions - The state from
ConfirmDeletemight not be saved beforeConfirmDeleteConfirmruns - Serialization issue -
DeleteIDmight not be serializing/deserializing correctly - Race condition - Second action might be processed before first action's state is saved
Notes
- This test is NOT in the CI matrix (not in
test-all.shWORKING_EXAMPLES) - Issue exists in both livetemplate v0.7.7 and v0.8.0
- Counter, chat, and todos examples all work correctly
Test Output
Step 2: Clicking delete button...
Step 3: Waiting for modal...
Modal appeared
Step 4: Clicking confirm button in modal...
Step 5: Verifying deletion...
Todo count: before=2, after=2
Modal closed correctly
❌ Todo count should decrease after deletion (before: 2, after: 2)
Labels
bug, todos-components
Metadata
Metadata
Assignees
Labels
No labels