Skip to content

Conversation

@jasonyuezhang
Copy link
Owner

@jasonyuezhang jasonyuezhang commented Nov 20, 2025

just two last test files


Copied from getsentry#103707
Original PR: getsentry#103707


Move release component tests to new router helpers

This PR updates the last two release-related test files to stop using the deprecated initializeOrg/deprecatedRouterMocks helpers and migrate to the newer OrganizationFixture + explicit RouterConfig pattern. The only changes are within test code; no production code is touched.

Key Changes

• Removed initializeOrg and deprecatedRouterMocks usage from commits.spec.tsx and filesChanged.spec.tsx
• Added OrganizationFixture and RouterConfig imports and constructed initialRouterConfig objects to provide routing context explicitly
• Updated render helpers to pass {organization, initialRouterConfig} instead of {router, deprecatedRouterMocks}
• Deleted obsolete mocks that relied on query params built via initializeOrg

Affected Areas

static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx
static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx


This summary was automatically generated by @propel-code-bot

Summary by CodeRabbit

  • Tests
    • Updated test infrastructure for release views and file change views with improved routing configuration and organization context setup.

✏️ Tip: You can customize this high-level summary in your review settings.

@propel-test-bot
Copy link

Replace deprecated router mocks in release tests

The PR updates the last two release-related test files to stop using the deprecated initializeOrg/deprecatedRouterMocks helpers. Tests now create an OrganizationFixture, build an explicit RouterConfig, and pass it through render()’s options, aligning with the current testing utilities.

Key Changes

• Removed initializeOrg and deprecatedRouterMocks from commits.spec.tsx and filesChanged.spec.tsx
• Added OrganizationFixture and typed RouterConfig construction (initialRouterConfig) in each file
• Updated all render() calls to pass {organization, initialRouterConfig} instead of {router, deprecatedRouterMocks}
• Adjusted inline router locations to match new release routes (/commits/, /files-changed/)

Affected Areas

static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx
static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx
• No production code touched; only Jest/RTL tests

This summary was automatically generated by @propel-code-bot

@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

Two test files in the releases module are refactored to replace deprecated router initialization patterns with a new OrganizationFixture and explicit RouterConfig-based approach for test setup.

Changes

Cohort / File(s) Summary
Test Infrastructure Migration for Releases Module
static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx, static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx
Replaces initializeOrg, deprecatedRouterMocks, and newRouterContext with OrganizationFixture and explicit initialRouterConfig object. Updates render/mount calls to pass organization and initialRouterConfig parameters. Adjusts route paths to match expected organization and release patterns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Homogeneous refactoring pattern applied consistently across both test files
  • Import statement updates are straightforward (old router mocks removed, new fixtures added)
  • RouterConfig initialization follows a clear, repeated structure
  • No complex logic or conditional changes involved

Poem

🐰 A rabbit hops through tests so bright,
Old mocks and routers fade from sight,
With fixtures fresh and routes so clear,
The tests now leap without a fear! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main change: migrating release test components away from deprecated route mocks, which is clearly reflected in both modified test files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copy/pr-103707-scttcper/test-releases-props

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx (1)

84-84: Consider using dynamic slug values in mock URLs (pre-existing).

These mock URLs use hardcoded 'org-slug' and 'project-slug' instead of organization.slug and project.slug. While this works because the fixtures default to these values, using the dynamic references (as done in lines 54, 58, 67, 78, 95, 115, 150) would improve consistency and reduce fragility if fixture defaults change.

Example refactor for line 84:

-    url: `/projects/org-slug/project-slug/releases/${encodeURIComponent(
+    url: `/projects/${organization.slug}/${project.slug}/releases/${encodeURIComponent(

Also applies to: 101-101, 128-128, 156-156

static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx (1)

98-98: Consider using dynamic organization slug in mock URLs (pre-existing).

These mock URLs use hardcoded 'org-slug' instead of organization.slug. While functional (since the fixture defaults to 'org-slug'), using the dynamic reference (as done in lines 68, 72, 80, 92, 109, 127) would improve consistency and maintainability.

Example refactor for line 98:

-    url: `/organizations/org-slug/releases/${encodeURIComponent(
+    url: `/organizations/${organization.slug}/releases/${encodeURIComponent(

Also applies to: 115-115, 140-140

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ddf3f6 and 7a12b8a.

📒 Files selected for processing (2)
  • static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx (5 hunks)
  • static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx (2)
tests/js/fixtures/organization.ts (1)
  • OrganizationFixture (5-93)
tests/js/sentry-test/reactTestingLibrary.tsx (1)
  • RouterConfig (88-118)
static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx (2)
tests/js/fixtures/organization.ts (1)
  • OrganizationFixture (5-93)
tests/js/sentry-test/reactTestingLibrary.tsx (1)
  • RouterConfig (88-118)
🔇 Additional comments (5)
static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx (3)

2-2: LGTM! Clean migration to the new test pattern.

The introduction of OrganizationFixture and RouterConfig properly replaces the deprecated router initialization. The route configuration accurately reflects the commits view path structure.

Also applies to: 8-8, 19-19, 21-27


45-46: Correct render configuration.

The renderComponent function now properly passes organization and initialRouterConfig to the render options, completing the migration from deprecated router mocks.


181-188: Proper query parameter override pattern.

The inline render call correctly spreads initialRouterConfig and overrides the location to test the active repository selection scenario. The explicit pathname redefinition is clear and maintains consistency.

static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx (2)

2-2: LGTM! Consistent migration pattern.

The migration properly introduces OrganizationFixture and RouterConfig, matching the pattern used in the commits test file. The route configuration correctly reflects the files-changed view path.

Also applies to: 8-8, 33-33, 35-41


59-60: Correct render configuration.

The render options now properly pass organization and initialRouterConfig, completing the migration away from deprecated router mocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants