phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

feat(event-display): Remove Angular dependency from phoenix-event-display and fix phoenix-ng test infrastructure

Open joyy-7921 opened this issue 1 month ago • 1 comments

Summary

This PR removes the Angular dependency from phoenix-event-display and replaces it with a framework-independent EventEmitter implementation, while also fixing broken tests and integration issues in phoenix-ng. This makes the entire Phoenix ecosystem more modular, framework-agnostic, and test-stable.

Changes

Core Changes (phoenix-event-display)

  • Created framework-independent EventEmitter (src/helpers/event-emitter.ts)

    • Replaces Angular's EventEmitter in ThreeManager
    • Lightweight implementation with subscribe(), emit(), and unsubscribe() methods
    • Fully typed with TypeScript generics
    • Includes comprehensive test coverage (8 tests)
  • Removed Angular dependency from phoenix-event-display

    • Changed import { EventEmitter } from '@angular/core' to use new implementation
    • Library is now completely framework-independent
  • Updated exports in src/index.ts

    • Exports new EventEmitter for use in phoenix-ng and other projects

Test Infrastructure Fixes (phoenix-event-display)

  • Fixed Jest configuration

    • Renamed jest.conf.jsjest.conf.cjs for proper CommonJS module handling
    • Fixed jest.setup.ts path resolution
    • Added proper transforms for TypeScript, JavaScript, and MJS files
  • Added comprehensive mocks for three.js ESM examples

    • Created src/tests/__mocks__/three-examples.mock.ts with mocks for:
      • Geometries: BufferGeometryUtils, ConvexGeometry, TextGeometry
      • Postprocessing: EffectComposer, RenderPass, OutlinePass, ShaderPass, Pass
      • Controls: OrbitControls
      • Loaders: OBJLoader, GLTFLoader, DRACOLoader, FontLoader
      • Exporters: OBJExporter, GLTFExporter
      • WebXR: XRControllerModelFactory
      • Stats and other utilities
    • Resolves ESM/CommonJS compatibility issues in Jest tests

Fixes in phoenix-ng

  • Fixed test failures caused by dependency updates in phoenix-event-display

    • Updated import references to use new internal EventEmitter
    • Adjusted trackml.component.test.ts to align with new event system
  • Updated Jest and TypeScript configuration

    • Ensured correct linking between phoenix-ng and phoenix-event-display
    • Improved module resolution for CI environments
  • Verified functional integration

    • All phoenix-ng components work seamlessly with the updated phoenix-event-display

Test Results

All tests now passing:

  • phoenix-event-display: 27/27 test suites (169/169 tests)
  • phoenix-ng: 56/56 test suites (176/176 tests)
  • Total: 83/83 test suites (345/345 tests)

Previously: yarn test:ci was failing completely (0% pass rate).

Benefits

  1. Framework Independence: phoenix-event-display no longer depends on Angular, making it reusable across frameworks (React, Vue, vanilla JS, etc.)
  2. Improved Cross-Package Stability: phoenix-ng now fully compatible with the refactored event system
  3. Better Architecture: Cleaner separation between visualization core and framework layer
  4. Smaller Bundle Size: Removed unnecessary Angular dependencies
  5. Improved CI/CD Reliability: All tests now pass across both packages
  6. Maintainability: Simplified and more maintainable codebase

Breaking Changes

None. The API remains unchanged — EventEmitter has the same interface (emit() method). The only difference is the internal import source.

Backward Compatibility

Fully backward compatible. External users of both libraries (phoenix-event-display and phoenix-ng) will see no change in behavior.

Testing

  • Added new test suite for EventEmitter (8 tests with 100% coverage)
  • Fixed broken Jest configs in both packages
  • Verified with yarn test:ci across both phoenix-event-display and phoenix-ng
  • All integration points between packages validated

Files Changed

phoenix-event-display:

  • packages/phoenix-event-display/src/helpers/event-emitter.ts (new)
  • packages/phoenix-event-display/src/tests/helpers/event-emitter.test.ts (new)
  • packages/phoenix-event-display/src/tests/__mocks__/three-examples.mock.ts (new)
  • packages/phoenix-event-display/src/managers/three-manager/index.ts (modified)
  • packages/phoenix-event-display/src/index.ts (modified - exports EventEmitter)
  • packages/phoenix-event-display/configs/jest.conf.cjs (new, renamed from .js)

phoenix-ng:

  • packages/phoenix-ng/projects/phoenix-app/src/app/sections/trackml/trackml.component.test.ts (modified)

Root:

  • jest.setup.ts (new, root level)
  • Configuration files updated

Related Issue: Fixes test failures in both phoenix-event-display and phoenix-ng, and removes Angular framework dependency from the core library.

joyy-7921 avatar Nov 12 '25 09:11 joyy-7921

@joyy-7921 Thanks so much for this! I do see some failures though, all of the type:

projects/phoenix-ui-components/lib/components/ui-menu/view-options/cartesian-grid-config/cartesian-grid-config.component.ts:57:5 - error TS2322: Type '() => void' is not assignable to type 'Subscription'.
  
      57     this.originChangedSub = this.eventDisplay

You didn't see this locally? (I fixed a trivial linting issue)

EdwardMoyse avatar Nov 13 '25 13:11 EdwardMoyse