Skip to content

Add node creation event chain integration tests #158

Closed

Description

@malibio

Problem Statement

Node creation involves a complex event chain across multiple services that is untested end-to-end:

  1. User presses Enter in ContentEditableController
  2. Controller emits 'createNewNode' event
  3. BaseNode handles event, calls NodeManager
  4. NodeManager creates node via Tauri backend
  5. EventBus emits 'node:created', 'hierarchy:changed', 'cache:invalidate'
  6. UI updates with new node
  7. Focus moves to new node

Current Gap: Chain tested in isolation but not as complete flow.

Why This Matters

Bugs This Would Catch:

  • Node created but events not fired
  • Events fired but UI doesn't update
  • Focus doesn't move to new node
  • EventBus events out of order
  • Cache invalidation missing

Acceptance Criteria

Create src/tests/integration/node-creation-events.test.ts with:

  • Enter Key Flow (4 tests)

    • Enter at end creates new node below
    • Enter in middle splits content
    • Enter with selection replaces selection
    • EventBus emits correct events
  • Event Sequence (3 tests)

    • Events fire in correct order
    • All required events emitted (created, hierarchy, cache)
    • Event data contains correct nodeIds
  • UI Updates (3 tests)

    • New node appears in DOM
    • Content split correctly
    • Focus moves to new node
  • Backend Integration (2 tests)

    • Tauri command called with correct params
    • Backend response handled correctly

Implementation Pattern

describe('Node Creation Event Chain', () => {
  it('should fire complete event sequence when Enter pressed', async () => {
    const events: NodeSpaceEvent[] = [];
    eventBus.subscribe('*', (e) => events.push(e));

    // Create node and press Enter
    const { container } = render(BaseNode, { /* ... */ });
    await user.keyboard('{Enter}');

    // Verify event sequence
    expect(events).toContainEqual(
      expect.objectContaining({ type: 'node:created' })
    );
    expect(events).toContainEqual(
      expect.objectContaining({ type: 'hierarchy:changed' })
    );
    expect(events).toContainEqual(
      expect.objectContaining({ type: 'cache:invalidate' })
    );

    // Verify order
    const createdIndex = events.findIndex(e => e.type === 'node:created');
    const hierarchyIndex = events.findIndex(e => e.type === 'hierarchy:changed');
    expect(createdIndex).toBeLessThan(hierarchyIndex);
  });
});

Dependencies

Estimated Effort

3-4 hours

Activity

  1. self-assigned this
    on Oct 5, 2025
  2. added 6 commits that reference this issue on Oct 5, 2025
    0996724
    5b888f1
    58916e7
    80e241b
    3b94d4b
    c730099
  3. added 10 commits that reference this issue on Feb 4, 2026
    64ac099
    eda55c8
    bbbf0c8
    cfd96bb
    9b18503
    6cc969e
    c146829
    2a7f66a
    b1a7538
    f93ce5a
  4. added 5 commits that reference this issue on Feb 26, 2026
    20a276e
    69e1dce
    72ca628
    a525265
    62f28a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions