From 7a12b8ae62814e25681c90f2da0d8175424bc2ad Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Wed, 19 Nov 2025 17:42:35 -0800 Subject: [PATCH] test(releases): Migrate release components off deprecated route mocks just two last test files --- .../detail/commitsAndFiles/commits.spec.tsx | 36 +++++++++++-------- .../commitsAndFiles/filesChanged.spec.tsx | 18 ++++++---- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx b/static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx index 1bd025cd449eab..5d24825fff2257 100644 --- a/static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx +++ b/static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx @@ -1,10 +1,11 @@ import {CommitFixture} from 'sentry-fixture/commit'; +import {OrganizationFixture} from 'sentry-fixture/organization'; import {ReleaseFixture} from 'sentry-fixture/release'; import {ReleaseProjectFixture} from 'sentry-fixture/releaseProject'; import {RepositoryFixture} from 'sentry-fixture/repository'; -import {initializeOrg} from 'sentry-test/initializeOrg'; import {render, screen} from 'sentry-test/reactTestingLibrary'; +import type {RouterConfig} from 'sentry-test/reactTestingLibrary'; import selectEvent from 'sentry-test/selectEvent'; import type {ReleaseProject} from 'sentry/types/release'; @@ -15,10 +16,15 @@ import Commits from './commits'; describe('Commits', () => { const release = ReleaseFixture(); const project = ReleaseProjectFixture() as Required; - const {router, organization} = initializeOrg({ - router: {params: {release: release.version}}, - }); + const organization = OrganizationFixture(); const repos = [RepositoryFixture({integrationId: '1'})]; + const initialRouterConfig: RouterConfig = { + location: { + pathname: `/organizations/${organization.slug}/releases/${release.version}/commits/`, + query: {}, + }, + route: '/organizations/:orgId/releases/:release/commits/', + }; function renderComponent() { return render( @@ -36,8 +42,8 @@ describe('Commits', () => { , { - router, - deprecatedRouterMocks: true, + organization, + initialRouterConfig, } ); } @@ -139,13 +145,7 @@ describe('Commits', () => { name: 'getsentry/sentry-frontend', integrationId: '1', }); - // Current repo is stored in query parameter activeRepo - const {router: newRouterContext} = initializeOrg({ - router: { - params: {release: release.version}, - location: {query: {activeRepo: otherRepo.name}}, - }, - }); + MockApiClient.addMockResponse({ url: `/projects/${organization.slug}/${project.slug}/releases/${encodeURIComponent( release.version @@ -178,8 +178,14 @@ describe('Commits', () => { , { - router: newRouterContext, - deprecatedRouterMocks: true, + organization, + initialRouterConfig: { + ...initialRouterConfig, + location: { + query: {activeRepo: otherRepo.name}, + pathname: `/organizations/${organization.slug}/releases/${release.version}/commits/`, + }, + }, } ); expect(await screen.findByRole('button')).toHaveTextContent(otherRepo.name); diff --git a/static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx b/static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx index 21c5edb1fad930..2fe151d37b064b 100644 --- a/static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx +++ b/static/app/views/releases/detail/commitsAndFiles/filesChanged.spec.tsx @@ -1,10 +1,11 @@ import {CommitAuthorFixture} from 'sentry-fixture/commitAuthor'; +import {OrganizationFixture} from 'sentry-fixture/organization'; import {ReleaseFixture} from 'sentry-fixture/release'; import {ReleaseProjectFixture} from 'sentry-fixture/releaseProject'; import {RepositoryFixture} from 'sentry-fixture/repository'; -import {initializeOrg} from 'sentry-test/initializeOrg'; import {render, screen} from 'sentry-test/reactTestingLibrary'; +import type {RouterConfig} from 'sentry-test/reactTestingLibrary'; import selectEvent from 'sentry-test/selectEvent'; import type {CommitFile} from 'sentry/types/integrations'; @@ -29,10 +30,15 @@ function CommitFileFixture(params: Partial = {}): CommitFile { describe('FilesChanged', () => { const release = ReleaseFixture(); const project = ReleaseProjectFixture() as Required; - const {router, organization} = initializeOrg({ - router: {params: {release: release.version}}, - }); + const organization = OrganizationFixture(); const repos = [RepositoryFixture({integrationId: '1'})]; + const initialRouterConfig: RouterConfig = { + location: { + pathname: `/organizations/${organization.slug}/releases/${release.version}/files-changed/`, + query: {}, + }, + route: '/organizations/:orgId/releases/:release/files-changed/', + }; function renderComponent() { return render( @@ -50,8 +56,8 @@ describe('FilesChanged', () => { , { - router, - deprecatedRouterMocks: true, + organization, + initialRouterConfig, } ); }