Skip to content

test(e2e): implement advanced scenarios #334

@LayZeeDK

Description

@LayZeeDK

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/lib

Assertions:

  • Source index.ts has export removed
  • Target index.ts has export added
  • No dangling exports in source
  • External imports from @nxworker/lib-source updated 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:

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 graph

Assertions:

  • Project graph reflects new file locations
  • Dependency edges updated correctly
  • No stale or broken references in graph
  • nx affected correctly 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

Out of Scope

Definition of Done

Advanced scenario implementations merged; orchestrator executes them with real assertions; all tests passing; import/export correctness validated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions