Skip to content

[Due for payment 2026-03-06] [BT-006] Write Unit Tests for Dynamic Routing Logic #80911

@mjasikowski

Description

@mjasikowski

Description

Current State:

  • No tests for dynamic routing functionality
  • Existing navigation tests may not cover suffix-based routing

Expected State:

  • Comprehensive unit tests for all dynamic routing functions
  • Tests should cover happy paths and edge cases
  • Tests should validate access control behavior

Test Categories

1. createDynamicRoute() Tests

describe('createDynamicRoute', () => {
    it('should append suffix to simple path');
    it('should preserve query parameters');
    it('should throw for invalid suffix');
    it('should throw when current screen not in entryScreens');
});

2. isDynamicRouteSuffix() Tests

describe('isDynamicRouteSuffix', () => {
    it('should return true for valid dynamic suffix');
    it('should return false for non-dynamic suffix');
    it('should return false for empty string');
});

3. Access Control Tests

describe('access control', () => {
    it('should allow navigation from authorized screen');
    it('should block navigation from unauthorized screen');
    it('should validate on page refresh/deep link');
});

4. getPathWithoutSuffix() Tests

describe('getPathWithoutSuffix', () => {
    it('should strip suffix from path');
    it('should preserve query params when stripping');
    it('should return HOME for empty result');
});

Scope

Files:

  • App/tests/unit/libs/Navigation/createDynamicRoute.test.ts (new)
  • App/tests/unit/libs/Navigation/dynamicRouteHelpers.test.ts (new)
  • App/tests/unit/libs/Navigation/getAdaptedStateFromPath.test.ts (existing or new)

Test Coverage:

  • createDynamicRoute() - URL generation
  • isDynamicRouteSuffix() - Suffix detection
  • getStateForDynamicRoute() - State building
  • Access control validation
  • getPathWithoutSuffix() - Back navigation helper

Dependencies:

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionInternalRequires API changes or must be handled by Expensify staffWeeklyKSv2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions