Skip to content

bug: todos-components delete flow not working in E2E test #24

@adnaan

Description

@adnaan

Summary

The TestBrowserDeleteFlow test in todos-components fails - the delete confirmation modal works correctly but the todo is not actually deleted.

Symptoms

  1. Click delete button on a todo → Modal appears ✓
  2. Click confirm button in modal → Modal closes ✓
  3. 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

  1. State not persisted between WebSocket actions - The state from ConfirmDelete might not be saved before ConfirmDeleteConfirm runs
  2. Serialization issue - DeleteID might not be serializing/deserializing correctly
  3. 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.sh WORKING_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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions