Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions static/app/views/releases/detail/commitsAndFiles/commits.spec.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,10 +16,15 @@ import Commits from './commits';
describe('Commits', () => {
const release = ReleaseFixture();
const project = ReleaseProjectFixture() as Required<ReleaseProject>;
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(
Expand All @@ -36,8 +42,8 @@ describe('Commits', () => {
<Commits />
</ReleaseContext>,
{
router,
deprecatedRouterMocks: true,
organization,
initialRouterConfig,
}
);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -178,8 +178,14 @@ describe('Commits', () => {
<Commits />
</ReleaseContext>,
{
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -29,10 +30,15 @@ function CommitFileFixture(params: Partial<CommitFile> = {}): CommitFile {
describe('FilesChanged', () => {
const release = ReleaseFixture();
const project = ReleaseProjectFixture() as Required<ReleaseProject>;
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(
Expand All @@ -50,8 +56,8 @@ describe('FilesChanged', () => {
<FilesChanged />
</ReleaseContext>,
{
router,
deprecatedRouterMocks: true,
organization,
initialRouterConfig,
}
);
}
Expand Down