-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Parent: #319
Summary
Implement advanced scenarios that validate complex move-file behavior: path alias handling, export management, idempotence, and project graph updates. These scenarios ensure correctness in edge cases and complex import/export scenarios.
Objectives
- Verify path alias rewrites work correctly across multiple libraries
- Validate index.ts export management (additions and removals)
- Ensure generator is idempotent (re-running doesn't cause duplicates)
- Confirm Nx project graph updates correctly after moves
Scope / Scenario Details
1. PATH-ALIASES - Workspace with 3 libs; multiple alias moves
Purpose: Verify path alias handling across multiple libraries
Setup:
- Workspace with 3 libraries (lib-a, lib-b, lib-c)
- Each library has path alias in tsconfig.base.json
- Files import from each other using aliases (
@nxworker/lib-a, etc.)
Implementation:
- Move file from lib-a to lib-b (used by lib-c)
- Move file from lib-b to lib-c (used by lib-a)
Assertions:
- All path aliases updated correctly
- No broken imports
- tsconfig.base.json paths remain valid
- All libraries still build successfully
2. EXPORTS - Move exported file and verify index updated
Purpose: Verify index.ts export updates after move
Setup:
- Workspace with 2 libraries (lib-source, lib-target)
- lib-source has index.ts exporting multiple files
- One exported file will be moved
Implementation:
nx generate @nxworker/workspace:move-file --source=libs/lib-source/src/lib/exported-util.ts --destination=libs/lib-target/src/libAssertions:
- Source index.ts has export removed
- Target index.ts has export added
- No dangling exports in source
- External imports from
@nxworker/lib-sourceupdated to@nxworker/lib-target
3. REPEAT-MOVE - Re-run MOVE-PROJECT-DIR ensuring no duplicates
Purpose: Verify idempotence (running generator twice has no side effects)
Setup:
- Workspace from MOVE-PROJECT-DIR scenario (from test(e2e): implement generator option scenarios #322)
- Generator already run once successfully
Implementation:
- Re-run the exact same move-file command
- Verify no changes occur (generator detects already-moved state)
Assertions:
- No duplicate exports in index files
- No duplicate imports
- No file overwrites or duplicates
- Generator completes successfully with no-op behavior
Notes: This is critical for ensuring the generator can be safely re-run (e.g., in CI retries or user error).
4. GRAPH-REACTION - Force project graph rebuild after moves
Purpose: Verify Nx project graph updates correctly after moves
Setup:
- Workspace with 3 libraries with circular or complex dependencies
- Perform multiple moves that change dependency relationships
Implementation:
# Perform moves
nx generate @nxworker/workspace:move-file ...
# Force graph rebuild
nx reset
nx graph --file=graph.json
# Parse and validate graphAssertions:
- Project graph reflects new file locations
- Dependency edges updated correctly
- No stale or broken references in graph
nx affectedcorrectly identifies affected projects
Tasks
- Implement PATH-ALIASES scenario with 3-lib workspace and alias moves
- Implement EXPORTS scenario with index.ts management validation
- Implement REPEAT-MOVE scenario leveraging test(e2e): implement generator option scenarios #322's MOVE-PROJECT-DIR
- Implement GRAPH-REACTION scenario with graph validation
- Add targeted import/export path assertions
- Update orchestrator to call implementations instead of placeholders
Acceptance Criteria
- All four scenarios pass locally on Windows and Linux
- PATH-ALIASES validates complex alias rewrites
- EXPORTS confirms index.ts updates correctly
- REPEAT-MOVE ensures idempotence
- GRAPH-REACTION validates project graph correctness
- All scenarios use focused assertions (avoid broad tree diffs per Adopt new end-to-end test plan #319)
Dependencies
- Issue test(e2e): implement harness utilities for new test suite #320 (harness utilities) - completed
- Issue test(e2e): add orchestrator spec for e2e target #321 (orchestrator spec) - completed
- Issue test(e2e): implement generator option scenarios #322 (generator option scenarios) - REPEAT-MOVE depends on MOVE-PROJECT-DIR
- Issue test(e2e): implement infrastructure scenarios #332 (infrastructure scenarios) - needed for registry/publish
Out of Scope
- Performance measurement
- Scale testing (covered by test(e2e): implement scale and smoke scenarios #335)
Definition of Done
Advanced scenario implementations merged; orchestrator executes them with real assertions; all tests passing; import/export correctness validated.