From 768ce5fefd161833e8225fa708f6d85fc6ba4055 Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Thu, 29 Aug 2024 15:39:38 -0700 Subject: [PATCH] test(ui): Use built-in test providers --- .../table/quickContext/issueContext.spec.tsx | 9 +-- .../landing/metricsDataSwitcher.spec.tsx | 69 +++++++++---------- .../transactionOverview/index.spec.tsx | 16 ++--- 3 files changed, 41 insertions(+), 53 deletions(-) diff --git a/static/app/views/discover/table/quickContext/issueContext.spec.tsx b/static/app/views/discover/table/quickContext/issueContext.spec.tsx index d232f274f78b34..2518ac55fe2494 100644 --- a/static/app/views/discover/table/quickContext/issueContext.spec.tsx +++ b/static/app/views/discover/table/quickContext/issueContext.spec.tsx @@ -3,12 +3,10 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; import {ProjectFixture} from 'sentry-fixture/project'; import {RepositoryFixture} from 'sentry-fixture/repository'; -import {makeTestQueryClient} from 'sentry-test/queryClient'; import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; import {GroupStatus} from 'sentry/types/group'; import type {EventData} from 'sentry/utils/discover/eventView'; -import {QueryClientProvider} from 'sentry/utils/queryClient'; import IssueContext from './issueContext'; import {defaultRow} from './testUtils'; @@ -32,12 +30,7 @@ const mockedGroup = GroupFixture({ const renderIssueContext = (dataRow: EventData = defaultRow) => { const organization = OrganizationFixture(); - render( - - - , - {organization} - ); + render(, {organization}); }; describe('Quick Context Content Issue Column', function () { diff --git a/static/app/views/performance/landing/metricsDataSwitcher.spec.tsx b/static/app/views/performance/landing/metricsDataSwitcher.spec.tsx index 6a838ece35f660..0655963356d769 100644 --- a/static/app/views/performance/landing/metricsDataSwitcher.spec.tsx +++ b/static/app/views/performance/landing/metricsDataSwitcher.spec.tsx @@ -2,17 +2,20 @@ import {ProjectFixture} from 'sentry-fixture/project'; import {addMetricsDataMock} from 'sentry-test/performance/addMetricsDataMock'; import {initializeData} from 'sentry-test/performance/initializePerformanceData'; -import {makeTestQueryClient} from 'sentry-test/queryClient'; import {act, render, screen} from 'sentry-test/reactTestingLibrary'; import TeamStore from 'sentry/stores/teamStore'; import {MetricsCardinalityProvider} from 'sentry/utils/performance/contexts/metricsCardinality'; -import {QueryClientProvider} from 'sentry/utils/queryClient'; -import {OrganizationContext} from 'sentry/views/organizationContext'; import {generatePerformanceEventView} from 'sentry/views/performance/data'; import {PerformanceLanding} from 'sentry/views/performance/landing'; -function WrappedComponent({data, withStaticFilters = true}) { +function WrappedComponent({ + data, + withStaticFilters = true, +}: { + data: any; + withStaticFilters?: boolean; +}) { const eventView = generatePerformanceEventView( data.router.location, data.projects, @@ -23,28 +26,24 @@ function WrappedComponent({data, withStaticFilters = true}) { ); return ( - - - - {}} - handleTrendsClick={() => {}} - setError={() => {}} - withStaticFilters={withStaticFilters} - /> - - - + + {}} + handleTrendsClick={() => {}} + setError={() => {}} + withStaticFilters={withStaticFilters} + /> + ); } @@ -133,7 +132,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(screen.getByTestId('performance-landing-v3')).toBeInTheDocument(); }); @@ -146,7 +145,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); }); @@ -164,7 +163,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); }); @@ -182,7 +181,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-single-project-incompatible') @@ -204,7 +203,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-multi-project-incompatible') @@ -226,7 +225,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-multi-project-all-incompatible') @@ -246,7 +245,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-unnamed-discover') @@ -266,7 +265,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-unnamed-discover-or-set') @@ -286,7 +285,7 @@ describe('Performance > Landing > MetricsDataSwitcher', function () { features, }); - wrapper = render(); + wrapper = render(, {organization: data.organization}); expect(await screen.findByTestId('transaction-search-bar')).toBeInTheDocument(); expect( await screen.findByTestId('landing-mep-alert-unnamed-discover') diff --git a/static/app/views/performance/transactionSummary/transactionOverview/index.spec.tsx b/static/app/views/performance/transactionSummary/transactionOverview/index.spec.tsx index 2e47dda50f78e5..d1a8fa0c1b9789 100644 --- a/static/app/views/performance/transactionSummary/transactionOverview/index.spec.tsx +++ b/static/app/views/performance/transactionSummary/transactionOverview/index.spec.tsx @@ -3,7 +3,6 @@ import {ProjectFixture} from 'sentry-fixture/project'; import {TeamFixture} from 'sentry-fixture/team'; import {initializeOrg} from 'sentry-test/initializeOrg'; -import {makeTestQueryClient} from 'sentry-test/queryClient'; import { render, renderGlobalModal, @@ -24,7 +23,6 @@ import { MEPSetting, MEPState, } from 'sentry/utils/performance/contexts/metricsEnhancedSetting'; -import {QueryClientProvider} from 'sentry/utils/queryClient'; import TransactionSummary from 'sentry/views/performance/transactionSummary/transactionOverview'; const teams = [ @@ -80,14 +78,12 @@ function TestComponent({ } return ( - - - - - + + + ); }