diff --git a/static/app/actionCreators/pageFilters.spec.tsx b/static/app/actionCreators/pageFilters.spec.tsx index 1c587d4c71e3dc..0aeed2106ee60c 100644 --- a/static/app/actionCreators/pageFilters.spec.tsx +++ b/static/app/actionCreators/pageFilters.spec.tsx @@ -28,6 +28,9 @@ describe('PageFilters ActionCreators', function () { beforeEach(function () { jest.spyOn(PageFiltersStore, 'updateProjects'); jest.spyOn(PageFiltersStore, 'onInitializeUrlState').mockImplementation(); + jest + .spyOn(PageFiltersStore, 'onInitializeUrlStateWithCodecovData') + .mockImplementation(); jest.clearAllMocks(); }); @@ -275,6 +278,7 @@ describe('PageFilters ActionCreators', function () { organization, queryParams: { project: '1', + repository: 'repo-from-query', }, memberProjects: projects, nonMemberProjects: [], @@ -296,11 +300,19 @@ describe('PageFilters ActionCreators', function () { new Set(), true ); + expect(PageFiltersStore.onInitializeUrlStateWithCodecovData).toHaveBeenCalledWith( + { + repository: 'repo-from-query', + }, + new Set(), + true + ); expect(router.replace).toHaveBeenCalledWith( expect.objectContaining({ query: { environment: [], project: ['1'], + repository: 'repo-from-query', }, }) ); @@ -373,6 +385,7 @@ describe('PageFilters ActionCreators', function () { end: null, period: '14d', utc: null, + repository: null, }, pinnedFilters: new Set(), }); @@ -405,6 +418,7 @@ describe('PageFilters ActionCreators', function () { end: null, period: '7d', utc: null, + repository: null, }, pinnedFilters: new Set(['environments', 'datetime', 'projects']), }); @@ -696,6 +710,7 @@ describe('PageFilters ActionCreators', function () { end: null, period: '14d', utc: null, + repository: null, }, pinnedFilters: new Set(['projects', 'environments', 'datetime']), }); diff --git a/static/app/actionCreators/pageFilters.tsx b/static/app/actionCreators/pageFilters.tsx index f3cc90fdb23e09..cbf292eb0065c7 100644 --- a/static/app/actionCreators/pageFilters.tsx +++ b/static/app/actionCreators/pageFilters.tsx @@ -14,7 +14,10 @@ import { setPageFiltersStorage, } from 'sentry/components/organizations/pageFilters/persistence'; import type {PageFiltersStringified} from 'sentry/components/organizations/pageFilters/types'; -import {getDefaultSelection} from 'sentry/components/organizations/pageFilters/utils'; +import { + getCodecovDefaultSelection, + getDefaultSelection, +} from 'sentry/components/organizations/pageFilters/utils'; import {parseStatsPeriod} from 'sentry/components/timeRangeSelector/utils'; import { ALL_ACCESS_PROJECTS, @@ -23,7 +26,12 @@ import { } from 'sentry/constants/pageFilters'; import OrganizationStore from 'sentry/stores/organizationStore'; import PageFiltersStore from 'sentry/stores/pageFiltersStore'; -import type {DateString, PageFilters, PinnedPageFilter} from 'sentry/types/core'; +import type { + CodecovPageFilters, + DateString, + PageFilters, + PinnedPageFilter, +} from 'sentry/types/core'; import type {InjectedRouter} from 'sentry/types/legacyReactRouter'; import type {Organization} from 'sentry/types/organization'; import type {Environment, MinimalProject, Project} from 'sentry/types/project'; @@ -57,11 +65,16 @@ type Options = { storageNamespace?: string; }; +/** + * Union type between Sentry and Codecov Page filters + */ +type PageFiltersUpdate = SentryPageFilterUpdate & CodecovPageFiltersUpdate; + /** * This is the 'update' object used for updating the page filters. The types * here are a bit wider to allow for easy updates. */ -type PageFiltersUpdate = { +type SentryPageFilterUpdate = { end?: DateString; environment?: string[] | null; period?: string | null; @@ -70,6 +83,10 @@ type PageFiltersUpdate = { utc?: boolean | null; }; +type CodecovPageFiltersUpdate = { + repository?: string | null; +}; + /** * Represents the input for updating the date time of page filters */ @@ -198,6 +215,8 @@ export function initializeUrlState({ // Use period from default if we don't have a period set pageFilters.datetime.period ??= defaultDatetime.period; + const codecovPageFilters: CodecovPageFilters = getCodecovDefaultSelection(); + // Do not set a period if we have absolute start and end if (pageFilters.datetime.start && pageFilters.datetime.end) { pageFilters.datetime.period = null; @@ -206,6 +225,8 @@ export function initializeUrlState({ const hasDatetimeInUrl = Object.keys(pick(queryParams, DATE_TIME_KEYS)).length > 0; const hasProjectOrEnvironmentInUrl = Object.keys(pick(queryParams, [URL_PARAM.PROJECT, URL_PARAM.ENVIRONMENT])).length > 0; + const hasRepositoryInUrl = + Object.keys(pick(queryParams, URL_PARAM.REPOSITORY)).length > 0; // We should only check and update the desync state if the site has just been loaded // (not counting route changes). To check this, we can use the `isReady` state: if it's @@ -254,6 +275,12 @@ export function initializeUrlState({ } } + // We want to update the pageFilter's object with a repository if it is in the URL + // or in local storage, in that order. + if (hasRepositoryInUrl) { + codecovPageFilters.repository = parsed.repository ?? null; + } + const storedPageFilters = skipLoadLastUsed ? null : getPageFilterStorage(orgSlug, storageNamespace); @@ -293,6 +320,10 @@ export function initializeUrlState({ pageFilters.datetime = getDatetimeFromState(storedState); shouldUsePinnedDatetime = true; } + + if (!hasRepositoryInUrl && pinnedFilters.has('repository')) { + codecovPageFilters.repository = storedState.repository ?? null; + } } const {projects, environments: environment, datetime} = pageFilters; @@ -358,12 +389,16 @@ export function initializeUrlState({ } } } - const pinnedFilters = organization.features.includes('new-page-filter') - ? new Set(['projects', 'environments', 'datetime']) + ? new Set(['projects', 'environments', 'datetime', 'repository']) : (storedPageFilters?.pinnedFilters ?? new Set()); PageFiltersStore.onInitializeUrlState(pageFilters, pinnedFilters, shouldPersist); + PageFiltersStore.onInitializeUrlStateWithCodecovData( + codecovPageFilters, + pinnedFilters, + shouldPersist + ); if (shouldUpdateLocalStorage) { setPageFiltersStorage(organization.slug, new Set(['projects', 'environments'])); } @@ -392,10 +427,14 @@ export function initializeUrlState({ }; if (!skipInitializeUrlParams) { - updateParams({project, environment, ...newDatetime}, router, { - replace: true, - keepCursor: true, - }); + updateParams( + {project, environment, ...newDatetime, repository: codecovPageFilters.repository}, + router, + { + replace: true, + keepCursor: true, + } + ); } } @@ -469,6 +508,19 @@ export function updateDateTime( persistPageFilters('datetime', options); } +/** + * Updates store and global repository selection URL param if `router` is supplied + * + * @param repository Object with repository key + * @param router Router object + * @param options Options object + */ +export function updateRepository(repository: string, router?: Router, options?: Options) { + PageFiltersStore.updateRepository(repository); + updateParams({repository}, router, options); + persistPageFilters('repository', options); +} + /** * Pins a particular filter so that it is read out of local storage */ @@ -669,7 +721,7 @@ function getNewQueryParams( const extraParams = omit(cleanCurrentQuery, omittedParameters); // Override parameters - const {project, environment, start, end, utc} = { + const {project, environment, start, end, utc, repository} = { ...currentQueryState, ...obj, }; @@ -684,6 +736,7 @@ function getNewQueryParams( end: statsPeriod ? null : end instanceof Date ? getUtcDateString(end) : end, utc: utc ? 'true' : null, statsPeriod, + repository, ...extraParams, }; diff --git a/static/app/components/codecov/datePicker/datePicker.spec.tsx b/static/app/components/codecov/datePicker/datePicker.spec.tsx index c032d38ce5b6b0..1c655c0a2d0d83 100644 --- a/static/app/components/codecov/datePicker/datePicker.spec.tsx +++ b/static/app/components/codecov/datePicker/datePicker.spec.tsx @@ -64,6 +64,9 @@ describe('DatePicker', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }); }); @@ -106,6 +109,9 @@ describe('DatePicker', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }); }); diff --git a/static/app/components/organizations/datePageFilter.spec.tsx b/static/app/components/organizations/datePageFilter.spec.tsx index 4599d9c5171f40..0edd67ce4df35f 100644 --- a/static/app/components/organizations/datePageFilter.spec.tsx +++ b/static/app/components/organizations/datePageFilter.spec.tsx @@ -68,6 +68,9 @@ describe('DatePageFilter', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }); }); @@ -111,6 +114,9 @@ describe('DatePageFilter', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }); // Absolute option is marked as selected diff --git a/static/app/components/organizations/pageFilters/container.spec.tsx b/static/app/components/organizations/pageFilters/container.spec.tsx index de897c6b1f3780..2d537150b20e98 100644 --- a/static/app/components/organizations/pageFilters/container.spec.tsx +++ b/static/app/components/organizations/pageFilters/container.spec.tsx @@ -141,6 +141,9 @@ describe('PageFiltersContainer', function () { environments: ['prod'], projects: [], }, + codecovSelection: { + repository: null, + }, }) ); @@ -173,6 +176,9 @@ describe('PageFiltersContainer', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }) ); }); @@ -203,6 +209,9 @@ describe('PageFiltersContainer', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }) ); }); @@ -244,6 +253,9 @@ describe('PageFiltersContainer', function () { environments: [], projects: [], }, + codecovSelection: { + repository: null, + }, }); }); @@ -287,11 +299,13 @@ describe('PageFiltersContainer', function () { }); it('does not load from local storage when there are URL params', function () { - jest - .spyOn(localStorage, 'getItem') - .mockImplementation(() => - JSON.stringify({projects: [3], environments: ['staging']}) - ); + jest.spyOn(localStorage, 'getItem').mockImplementation(() => + JSON.stringify({ + projects: [3], + environments: ['staging'], + repository: 'repo-from-store', + }) + ); const initializationObj = initializeOrg({ organization: { @@ -301,7 +315,10 @@ describe('PageFiltersContainer', function () { // we need this to be set to make sure org in context is same as // current org in URL params: {orgId: 'org-slug'}, - location: {pathname: '/test', query: {project: ['1', '2']}}, + location: { + pathname: '/test', + query: {project: ['1', '2'], repository: 'repo-from-url'}, + }, }, }); @@ -312,6 +329,7 @@ describe('PageFiltersContainer', function () { ); expect(PageFiltersStore.getState().selection.projects).toEqual([1, 2]); + expect(PageFiltersStore.getState().codecovSelection.repository).toBe('repo-from-url'); // Since these are coming from URL, there should be no changes and // router does not need to be called @@ -327,7 +345,10 @@ describe('PageFiltersContainer', function () { // we need this to be set to make sure org in context is same as // current org in URL params: {orgId: 'org-slug'}, - location: {pathname: '/test', query: {project: ['1', '2']}}, + location: { + pathname: '/test', + query: {project: ['1', '2'], repository: 'repo-from-store'}, + }, }, }); @@ -338,6 +359,9 @@ describe('PageFiltersContainer', function () { ); expect(PageFiltersStore.getState().selection.projects).toEqual([1, 2]); + expect(PageFiltersStore.getState().codecovSelection.repository).toBe( + 'repo-from-store' + ); // Since these are coming from URL, there should be no changes and // router does not need to be called @@ -699,6 +723,11 @@ describe('PageFiltersContainer', function () { projects: [], }) ); + await waitFor(() => + expect(PageFiltersStore.getState().codecovSelection).toEqual({ + repository: null, + }) + ); expect(router.push).not.toHaveBeenCalled(); }); diff --git a/static/app/components/organizations/pageFilters/parse.tsx b/static/app/components/organizations/pageFilters/parse.tsx index 5f0eb96de8d14b..be5dd81626ce8d 100644 --- a/static/app/components/organizations/pageFilters/parse.tsx +++ b/static/app/components/organizations/pageFilters/parse.tsx @@ -8,7 +8,7 @@ import {defined} from 'sentry/utils'; import toArray from 'sentry/utils/array/toArray'; import {getUtcToLocalDateObject} from 'sentry/utils/dates'; -import type {PageFiltersState} from './types'; +import type {CodecovPageFiltersState, PageFiltersState} from './types'; type StatsPeriodType = 'h' | 'd' | 's' | 'm' | 'w'; @@ -150,6 +150,22 @@ function getEnvironment(maybe: ParamValue) { return toArray(maybe); } +/** + * Normalizes a string into the repository parameter. Repository is singular and + * doesn't handle arrays + */ +function getRepository(maybe: ParamValue) { + if (!defined(maybe)) { + return undefined; + } + + if (Array.isArray(maybe)) { + return null; + } + + return maybe; +} + type InputParams = { [others: string]: any; end?: ParamValue | Date; @@ -280,6 +296,7 @@ export function normalizeDateTimeParams( * * - Normalizes `project` and `environment` into a consistent list object. * - Normalizes date time filter parameters (using normalizeDateTimeParams). + * - Gets repository string from query params * - Parses `start` and `end` into Date objects. */ export function getStateFromQuery( @@ -290,6 +307,7 @@ export function getStateFromQuery( const project = getProject(query[URL_PARAM.PROJECT]) ?? null; const environment = getEnvironment(query[URL_PARAM.ENVIRONMENT]) ?? null; + const repository = getRepository(query[URL_PARAM.REPOSITORY]) ?? null; const dateTimeParams = normalizeDateTimeParams(query, normalizeOptions); @@ -310,7 +328,11 @@ export function getStateFromQuery( utc: typeof utc === 'undefined' ? null : utc === 'true', }; - return state; + const codecovState: CodecovPageFiltersState = { + repository, + }; + + return {...state, ...codecovState}; } /** diff --git a/static/app/components/organizations/pageFilters/persistence.tsx b/static/app/components/organizations/pageFilters/persistence.tsx index 454d2c5413935f..38429dc8fbdb61 100644 --- a/static/app/components/organizations/pageFilters/persistence.tsx +++ b/static/app/components/organizations/pageFilters/persistence.tsx @@ -11,16 +11,22 @@ function makeLocalStorageKey(orgSlug: string) { return `global-selection:${orgSlug}`; } -type StoredObject = { +type StoredObject = SentryStoredObject & CodecovStoredObject; + +type SentryStoredObject = { end: string | null; environments: string[]; period: string | null; pinnedFilters: PinnedPageFilter[]; projects: number[]; + repository: string | null; start: string | null; utc: 'true' | null; }; +type CodecovStoredObject = { + repository: string | null; +}; /** * Updates the localstorage page filters data for the specified filters. * @@ -37,7 +43,7 @@ export function setPageFiltersStorage( updateFilters: Set, storageNamespace = '' ) { - const {selection, pinnedFilters} = PageFiltersStore.getState(); + const {selection, codecovSelection, pinnedFilters} = PageFiltersStore.getState(); const {state: currentStoredState} = getPageFilterStorage(orgSlug, storageNamespace) ?? { state: null, @@ -51,6 +57,10 @@ export function setPageFiltersStorage( ? selection.environments : (currentStoredState?.environment ?? []); + const repository = updateFilters.has('repository') + ? codecovSelection.repository + : (currentStoredState?.repository ?? null); + const shouldUpdateDatetime = updateFilters.has('datetime'); const currentStart = shouldUpdateDatetime @@ -85,6 +95,7 @@ export function setPageFiltersStorage( period, utc, pinnedFilters: Array.from(pinnedFilters), + repository, }; const localStorageKey = makeLocalStorageKey( @@ -124,7 +135,8 @@ export function getPageFilterStorage(orgSlug: string, storageNamespace = '') { return null; } - const {projects, environments, start, end, period, utc, pinnedFilters} = decoded; + const {projects, environments, start, end, period, utc, pinnedFilters, repository} = + decoded; const state = getStateFromQuery( { @@ -134,6 +146,7 @@ export function getPageFilterStorage(orgSlug: string, storageNamespace = '') { end, period, utc, + repository, }, {allowAbsoluteDatetime: true} ); diff --git a/static/app/components/organizations/pageFilters/types.tsx b/static/app/components/organizations/pageFilters/types.tsx index 775bfd0af87ed2..d4cb103e378526 100644 --- a/static/app/components/organizations/pageFilters/types.tsx +++ b/static/app/components/organizations/pageFilters/types.tsx @@ -1,10 +1,16 @@ +/** + * A flat object of stringified Sentry and Codecov page filter data + */ +export type PageFiltersStringified = SentryPageFiltersStringified & + CodecovPageFiltersStringified; + /** * A flat object of stringified page filter data * * XXX: Note the stringified version of the page filter represents `period` as * `statsPeriod` */ -export type PageFiltersStringified = { +export type SentryPageFiltersStringified = { end?: string | null; environment?: string[] | null; project?: string[] | null; @@ -13,6 +19,13 @@ export type PageFiltersStringified = { utc?: string | null; }; +/** + * A flat object of stringified Codecov page filter data + */ +export type CodecovPageFiltersStringified = { + repository?: string | null; +}; + /** * This is a flat normalized variant of the PageFilters type. */ @@ -24,3 +37,10 @@ export type PageFiltersState = { start: Date | null; utc: boolean | null; }; + +/** + * This is a flat normalized variant of the CodecovPageFilters type. + */ +export type CodecovPageFiltersState = { + repository: string | null; +}; diff --git a/static/app/components/organizations/pageFilters/utils.tsx b/static/app/components/organizations/pageFilters/utils.tsx index 98f17cd9138eec..01869ec0b7a87d 100644 --- a/static/app/components/organizations/pageFilters/utils.tsx +++ b/static/app/components/organizations/pageFilters/utils.tsx @@ -6,7 +6,7 @@ import pickBy from 'lodash/pickBy'; import {DEFAULT_STATS_PERIOD} from 'sentry/constants'; import {URL_PARAM} from 'sentry/constants/pageFilters'; -import type {PageFilters} from 'sentry/types/core'; +import type {CodecovPageFilters, PageFilters} from 'sentry/types/core'; /** * Make a default page filters object @@ -26,6 +26,15 @@ export function getDefaultSelection(): PageFilters { }; } +/** + * Make a default page filters object for Codecov + */ +export function getCodecovDefaultSelection(): CodecovPageFilters { + return { + repository: null, + }; +} + /** * Extract the page filter parameters from an object * Useful for extracting page filter properties from the current URL diff --git a/static/app/constants/pageFilters.tsx b/static/app/constants/pageFilters.tsx index 86be437af58c7d..fb51f46ba8f646 100644 --- a/static/app/constants/pageFilters.tsx +++ b/static/app/constants/pageFilters.tsx @@ -5,6 +5,7 @@ export const URL_PARAM = { PERIOD: 'statsPeriod', PROJECT: 'project', ENVIRONMENT: 'environment', + REPOSITORY: 'repository', }; export const PAGE_URL_PARAM = { diff --git a/static/app/stores/pageFiltersStore.spec.tsx b/static/app/stores/pageFiltersStore.spec.tsx index 63826e2b70b441..703173845a1a27 100644 --- a/static/app/stores/pageFiltersStore.spec.tsx +++ b/static/app/stores/pageFiltersStore.spec.tsx @@ -6,6 +6,7 @@ import { updateEnvironments, updatePersistence, updateProjects, + updateRepository, } from 'sentry/actionCreators/pageFilters'; import PageFiltersStore from 'sentry/stores/pageFiltersStore'; @@ -33,6 +34,9 @@ describe('PageFiltersStore', function () { environments: [], datetime: {period: '14d', start: null, end: null, utc: null}, }, + codecovSelection: { + repository: null, + }, }); }); @@ -59,6 +63,26 @@ describe('PageFiltersStore', function () { expect(triggerSpy).toHaveBeenCalledTimes(1); }); + it('returns updated repository when calling updateRepository()', async function () { + expect(PageFiltersStore.getState().codecovSelection.repository).toBeNull(); + updateRepository('test-repo'); + await tick(); + expect(PageFiltersStore.getState().codecovSelection.repository).toBe('test-repo'); + }); + + it('does not update repository when calling updateRepository() if same value', async function () { + const triggerSpy = jest.spyOn(PageFiltersStore, 'trigger'); + const testRepoName = 'repo 123'; + PageFiltersStore.updateRepository(testRepoName); + + await waitFor( + () => PageFiltersStore.getState().codecovSelection.repository === testRepoName + ); + PageFiltersStore.updateRepository(testRepoName); + await tick(); + expect(triggerSpy).toHaveBeenCalledTimes(1); + }); + it('updateDateTime()', async function () { expect(PageFiltersStore.getState().selection.datetime).toEqual({ period: '14d', diff --git a/static/app/stores/pageFiltersStore.tsx b/static/app/stores/pageFiltersStore.tsx index 600656557585f3..aed4dfdff5c81a 100644 --- a/static/app/stores/pageFiltersStore.tsx +++ b/static/app/stores/pageFiltersStore.tsx @@ -1,7 +1,10 @@ import {createStore} from 'reflux'; -import {getDefaultSelection} from 'sentry/components/organizations/pageFilters/utils'; -import type {PageFilters, PinnedPageFilter} from 'sentry/types/core'; +import { + getCodecovDefaultSelection, + getDefaultSelection, +} from 'sentry/components/organizations/pageFilters/utils'; +import type {CodecovPageFilters, PageFilters, PinnedPageFilter} from 'sentry/types/core'; import {valueIsEqual} from 'sentry/utils/object/valueIsEqual'; import type {StrictStoreDefinition} from './types'; @@ -40,7 +43,13 @@ function datetimeHasSameValue( return true; } -interface PageFiltersState { +export interface PageFiltersState { + /** + * The current page filter selection for Codecov properties. This was added to + * keep a separation between Sentry selection values of type PageFilters and instead + * create a dedicated CodecovPageFilters type for Codecov values + */ + codecovSelection: CodecovPageFilters; /** * The set of page filters which have been pinned but do not match the current * URL state. @@ -72,20 +81,27 @@ interface PageFiltersStoreDefinition extends StrictStoreDefinition, persist?: boolean ): void; + onInitializeUrlStateWithCodecovData( + newSelection: CodecovPageFilters, + pinned: Set, + persist?: boolean + ): void; onReset(): void; pin(filter: PinnedPageFilter, pin: boolean): void; - reset(selection?: PageFilters): void; + reset(selection?: PageFilters, codecovSelection?: CodecovPageFilters): void; updateDateTime(datetime: PageFilters['datetime']): void; updateDesyncedFilters(filters: Set): void; updateEnvironments(environments: string[] | null): void; updatePersistence(shouldPersist: boolean): void; updateProjects(projects: PageFilters['projects'], environments: null | string[]): void; + updateRepository(repository: CodecovPageFilters['repository']): void; } const storeConfig: PageFiltersStoreDefinition = { state: { isReady: false, selection: getDefaultSelection(), + codecovSelection: getCodecovDefaultSelection(), pinnedFilters: new Set(), desyncedFilters: new Set(), shouldPersist: true, @@ -95,14 +111,15 @@ const storeConfig: PageFiltersStoreDefinition = { // XXX: Do not use `this.listenTo` in this store. We avoid usage of reflux // listeners due to their leaky nature in tests. - this.reset(this.state.selection); + this.reset(this.state.selection, this.state.codecovSelection); }, - reset(selection) { + reset(selection, codecovSelection) { this.state = { ...this.state, isReady: false, selection: selection || getDefaultSelection(), + codecovSelection: codecovSelection || getCodecovDefaultSelection(), pinnedFilters: new Set(), }; }, @@ -121,6 +138,20 @@ const storeConfig: PageFiltersStoreDefinition = { this.trigger(this.getState()); }, + /** + * Initializes the Codecov page filters store data + */ + onInitializeUrlStateWithCodecovData(newSelection, pinned, persist = true) { + this.state = { + ...this.state, + isReady: true, + codecovSelection: newSelection, + pinnedFilters: pinned, + shouldPersist: persist, + }; + this.trigger(this.getState()); + }, + getState() { return this.state; }, @@ -140,6 +171,21 @@ const storeConfig: PageFiltersStoreDefinition = { this.trigger(this.getState()); }, + updateRepository(repository = '') { + if (!repository || valueIsEqual(this.state.codecovSelection.repository, repository)) { + return; + } + + this.state = { + ...this.state, + codecovSelection: { + ...this.state.codecovSelection, + repository, + }, + }; + this.trigger(this.getState()); + }, + updateProjects(projects = [], environments = null) { if (valueIsEqual(this.state.selection.projects, projects)) { return; diff --git a/static/app/types/core.tsx b/static/app/types/core.tsx index 4dd44cb9b99303..e00559e03a561d 100644 --- a/static/app/types/core.tsx +++ b/static/app/types/core.tsx @@ -141,7 +141,7 @@ export type IntervalPeriod = ReturnType; /** * Represents a pinned page filter sentinel value */ -export type PinnedPageFilter = 'projects' | 'environments' | 'datetime'; +export type PinnedPageFilter = 'projects' | 'environments' | 'datetime' | 'repository'; export type PageFilters = { /** @@ -163,6 +163,13 @@ export type PageFilters = { projects: number[]; }; +export type CodecovPageFilters = { + /** + * Currently selected repository + */ + repository: string | null; +}; + type InitialState = {type: 'initial'}; type LoadingState = {type: 'loading'}; diff --git a/static/app/views/discover/homepage.spec.tsx b/static/app/views/discover/homepage.spec.tsx index b5da2540a89213..4cb29ade16bdbc 100644 --- a/static/app/views/discover/homepage.spec.tsx +++ b/static/app/views/discover/homepage.spec.tsx @@ -1,5 +1,6 @@ import {LocationFixture} from 'sentry-fixture/locationFixture'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {GetPageFiltersStorageFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {initializeOrg} from 'sentry-test/initializeOrg'; @@ -440,17 +441,18 @@ describe('Discover > Homepage', () => { it('overrides homepage filters with pinned filters if they exist', async () => { ProjectsStore.loadInitialData([ProjectFixture({id: '1'}), ProjectFixture({id: '2'})]); - jest.spyOn(pageFilterUtils, 'getPageFilterStorage').mockReturnValueOnce({ - pinnedFilters: new Set(['projects']), - state: { - project: [2], - environment: [], - start: null, - end: null, - period: '14d', - utc: null, - }, - }); + const state = { + project: [2], + environment: [], + start: null, + end: null, + period: '14d', + utc: null, + repository: null, + }; + jest + .spyOn(pageFilterUtils, 'getPageFilterStorage') + .mockReturnValueOnce(GetPageFiltersStorageFixture({state})); render( { beforeEach(() => { jest.mocked(useLocation).mockReturnValue(LocationFixture()); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '14d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [2], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.clearAllMocks(); }); diff --git a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx index 2191f2d5dd4c78..ddbee13caaef4b 100644 --- a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx +++ b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx @@ -1,5 +1,6 @@ import {QueryClientProvider} from '@tanstack/react-query'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -62,23 +63,17 @@ describe('useProgressiveQuery', function () { url: '/test', body: 'test', }); - - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '14d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [2], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); }); it('makes a single request when the feature flag is disabled', function () { @@ -279,22 +274,17 @@ describe('useProgressiveQuery', function () { body: 'test', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '14d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [2], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); }); it('takes in a callback that determines if we can trigger the high accuracy request', async function () { diff --git a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx index a5e332461aaf45..c583988a4ea08a 100644 --- a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx +++ b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx @@ -1,6 +1,7 @@ import {QueryClientProvider} from '@tanstack/react-query'; import {LocationFixture} from 'sentry-fixture/locationFixture'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -36,22 +37,17 @@ describe('useMultiQueryTimeseries', () => { beforeEach(() => { jest.mocked(useLocation).mockReturnValue(LocationFixture()); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '14d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [2], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.clearAllMocks(); }); diff --git a/static/app/views/insights/browser/resources/components/sampleImages.spec.tsx b/static/app/views/insights/browser/resources/components/sampleImages.spec.tsx index 3eb59496cd4fdd..17ea08eaf04e6b 100644 --- a/static/app/views/insights/browser/resources/components/sampleImages.spec.tsx +++ b/static/app/views/insights/browser/resources/components/sampleImages.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -62,27 +63,11 @@ const setupMocks = () => { const mockProjects = [ProjectFixture()]; ProjectsStore.loadInitialData(mockProjects); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], - }, - }); - + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); jest.mocked(useLocation).mockReturnValue({ pathname: '', search: '', - query: {statsPeriod: '10d'}, + query: {statsPeriod: '14d'}, hash: '', state: undefined, action: 'PUSH', diff --git a/static/app/views/insights/browser/resources/views/resourcesLandingPage.spec.tsx b/static/app/views/insights/browser/resources/views/resourcesLandingPage.spec.tsx index ec61fdfc93b5d5..98336ae9e09850 100644 --- a/static/app/views/insights/browser/resources/views/resourcesLandingPage.spec.tsx +++ b/static/app/views/insights/browser/resources/views/resourcesLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -132,22 +133,18 @@ describe('ResourcesLandingPage', function () { }); const setupMocks = () => { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx b/static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx index 2777336aa6bab3..4590364e3c94ce 100644 --- a/static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx +++ b/static/app/views/insights/browser/webVitals/components/charts/performanceScoreBreakdownChart.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -24,23 +25,17 @@ describe('PerformanceScoreBreakdownChartWidget', function () { action: 'PUSH', key: '', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); - + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/releases/stats/`, body: [], diff --git a/static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.spec.tsx b/static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.spec.tsx index 6d47952ece4837..471c57f15e206a 100644 --- a/static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.spec.tsx +++ b/static/app/views/insights/browser/webVitals/components/tables/pagePerformanceTable.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {RouterFixture} from 'sentry-fixture/routerFixture'; @@ -26,22 +27,18 @@ describe('PagePerformanceTable', function () { beforeEach(function () { jest.mocked(useLocation).mockReturnValue(router.location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); ProjectsStore.loadInitialData([ ProjectFixture({ diff --git a/static/app/views/insights/browser/webVitals/components/webVitalMeters.spec.tsx b/static/app/views/insights/browser/webVitals/components/webVitalMeters.spec.tsx index 13979c16ce6322..10bd27314462aa 100644 --- a/static/app/views/insights/browser/webVitals/components/webVitalMeters.spec.tsx +++ b/static/app/views/insights/browser/webVitals/components/webVitalMeters.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -33,22 +34,7 @@ describe('WebVitalMeters', function () { action: 'PUSH', key: '', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); }); it('renders web vital meters with interaction to next paint', async () => { diff --git a/static/app/views/insights/browser/webVitals/components/webVitalsDetailPanel.spec.tsx b/static/app/views/insights/browser/webVitals/components/webVitalsDetailPanel.spec.tsx index cb8049cde0389b..6a01a3ee2e7eee 100644 --- a/static/app/views/insights/browser/webVitals/components/webVitalsDetailPanel.spec.tsx +++ b/static/app/views/insights/browser/webVitals/components/webVitalsDetailPanel.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -24,22 +25,7 @@ describe('WebVitalsDetailPanel', function () { action: 'PUSH', key: '', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); eventsMock = MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/events/`, diff --git a/static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx b/static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx index 0b12b831bca263..4cb11b2262b288 100644 --- a/static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx +++ b/static/app/views/insights/browser/webVitals/views/pageOverview.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -26,22 +27,7 @@ describe('PageOverview', function () { action: 'PUSH', key: '', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); eventsMock = MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/events/`, body: { diff --git a/static/app/views/insights/browser/webVitals/views/webVitalsLandingPage.spec.tsx b/static/app/views/insights/browser/webVitals/views/webVitalsLandingPage.spec.tsx index 78e036b68e5724..26a3f1924a0d9a 100644 --- a/static/app/views/insights/browser/webVitals/views/webVitalsLandingPage.spec.tsx +++ b/static/app/views/insights/browser/webVitals/views/webVitalsLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -32,22 +33,7 @@ describe('WebVitalsLandingPage', function () { action: 'PUSH', key: '', }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); eventsMock = MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/events/`, diff --git a/static/app/views/insights/cache/views/cacheLandingPage.spec.tsx b/static/app/views/insights/cache/views/cacheLandingPage.spec.tsx index 80caccd383affb..a48a56bd36c3a7 100644 --- a/static/app/views/insights/cache/views/cacheLandingPage.spec.tsx +++ b/static/app/views/insights/cache/views/cacheLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import { @@ -31,22 +32,17 @@ const requestMocks = { describe('CacheLandingPage', function () { const organization = OrganizationFixture({features: ['insights-addon-modules']}); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/common/components/fullSpanDescription.spec.tsx b/static/app/views/insights/common/components/fullSpanDescription.spec.tsx index 75df64db45e015..8fd4f2a69f5db2 100644 --- a/static/app/views/insights/common/components/fullSpanDescription.spec.tsx +++ b/static/app/views/insights/common/components/fullSpanDescription.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -19,23 +20,7 @@ describe('FullSpanDescription', function () { const project = ProjectFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); - + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); const groupId = '2ed2abf6ce7e3577'; const spanId = 'abfed2aabf'; const eventId = '65c7d8647b8a76ef8f4c05d41deb7860'; diff --git a/static/app/views/insights/common/components/modulePageProviders.spec.tsx b/static/app/views/insights/common/components/modulePageProviders.spec.tsx index 2360d492b8f47b..3787083c8421f0 100644 --- a/static/app/views/insights/common/components/modulePageProviders.spec.tsx +++ b/static/app/views/insights/common/components/modulePageProviders.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -13,22 +14,7 @@ jest.mock('sentry/views/insights/common/utils/useHasDataTrackAnalytics'); describe('ModulePageProviders', () => { beforeEach(() => { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); }); afterEach(() => { diff --git a/static/app/views/insights/common/components/modulesOnboarding.spec.tsx b/static/app/views/insights/common/components/modulesOnboarding.spec.tsx index 2948927020e4ef..788d14fb193c73 100644 --- a/static/app/views/insights/common/components/modulesOnboarding.spec.tsx +++ b/static/app/views/insights/common/components/modulesOnboarding.spec.tsx @@ -1,3 +1,4 @@ +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -22,22 +23,18 @@ describe('ModulesOnboarding', () => { ProjectsStore.loadInitialData([project]); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [Number(project.id)], + }; + + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); render( @@ -58,22 +55,7 @@ describe('ModulesOnboarding', () => { body: [project], }); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [Number(project.id)], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); render( @@ -89,22 +71,18 @@ describe('ModulesOnboarding', () => { project.hasInsightsCaches = true; ProjectsStore.loadInitialData([project]); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [Number(project.id)], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [Number(project.id)], + }; + + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); render( diff --git a/static/app/views/insights/common/components/spanDescription.spec.tsx b/static/app/views/insights/common/components/spanDescription.spec.tsx index 115af8f1389d8a..9d3d034250b806 100644 --- a/static/app/views/insights/common/components/spanDescription.spec.tsx +++ b/static/app/views/insights/common/components/spanDescription.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -19,22 +20,7 @@ describe('DatabaseSpanDescription', function () { const project = ProjectFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); const groupId = '2ed2abf6ce7e3577'; const spanId = 'abfed2aabf'; diff --git a/static/app/views/insights/common/queries/useDiscover.spec.tsx b/static/app/views/insights/common/queries/useDiscover.spec.tsx index 2935087fc24167..652afe4b50e819 100644 --- a/static/app/views/insights/common/queries/useDiscover.spec.tsx +++ b/static/app/views/insights/common/queries/useDiscover.spec.tsx @@ -1,6 +1,7 @@ import type {ReactNode} from 'react'; import {LocationFixture} from 'sentry-fixture/locationFixture'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -35,26 +36,11 @@ describe('useDiscover', () => { describe('useSpanMetrics', () => { const organization = OrganizationFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); jest.mocked(useLocation).mockReturnValue( LocationFixture({ - query: {statsPeriod: '10d'}, + query: {statsPeriod: '14d'}, }) ); @@ -140,7 +126,7 @@ describe('useDiscover', () => { sort: '-epm()', query: `span.group:221aa7ebd216 transaction:/api/details release:0.0.1`, referrer: 'api-spec', - statsPeriod: '10d', + statsPeriod: '14d', }, }) ); @@ -159,26 +145,11 @@ describe('useDiscover', () => { describe('useSpanIndexed', () => { const organization = OrganizationFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); jest.mocked(useLocation).mockReturnValue( LocationFixture({ - query: {statsPeriod: '10d'}, + query: {statsPeriod: '14d'}, }) ); @@ -279,7 +250,7 @@ describe('useDiscover', () => { sort: '-span.group', query: `span.group:221aa7ebd216 measurements.inp:<50 measurements.inp:>0 transaction:/api/details release:0.0.1`, referrer: 'api-spec', - statsPeriod: '10d', + statsPeriod: '14d', }, }) ); diff --git a/static/app/views/insights/common/queries/useDiscoverSeries.spec.tsx b/static/app/views/insights/common/queries/useDiscoverSeries.spec.tsx index 5fb7d246616024..6f3eec70828bd6 100644 --- a/static/app/views/insights/common/queries/useDiscoverSeries.spec.tsx +++ b/static/app/views/insights/common/queries/useDiscoverSeries.spec.tsx @@ -1,5 +1,6 @@ import type {ReactNode} from 'react'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -26,22 +27,17 @@ describe('useSpanMetricsSeries', () => { ); } - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/common/queries/useSpanMetricsTopNSeries.spec.tsx b/static/app/views/insights/common/queries/useSpanMetricsTopNSeries.spec.tsx index 98309694998324..26b4a98c83939b 100644 --- a/static/app/views/insights/common/queries/useSpanMetricsTopNSeries.spec.tsx +++ b/static/app/views/insights/common/queries/useSpanMetricsTopNSeries.spec.tsx @@ -1,5 +1,6 @@ import type {ReactNode} from 'react'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -26,22 +27,17 @@ describe('useSpanMetricsTopNSeries', () => { ); } - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/common/views/spans/selectors/domainSelector.spec.tsx b/static/app/views/insights/common/views/spans/selectors/domainSelector.spec.tsx index 1c2a84507efab2..856d2615e95ee9 100644 --- a/static/app/views/insights/common/views/spans/selectors/domainSelector.spec.tsx +++ b/static/app/views/insights/common/views/spans/selectors/domainSelector.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import { render, @@ -18,22 +19,7 @@ jest.mock('sentry/utils/usePageFilters'); describe('DomainSelector', function () { const organization = OrganizationFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); beforeEach(function () { MockApiClient.addMockResponse({ diff --git a/static/app/views/insights/database/components/noDataMessage.spec.tsx b/static/app/views/insights/database/components/noDataMessage.spec.tsx index 261b9331f0ee14..0bab1001f48985 100644 --- a/static/app/views/insights/database/components/noDataMessage.spec.tsx +++ b/static/app/views/insights/database/components/noDataMessage.spec.tsx @@ -1,4 +1,4 @@ -import {PageFiltersFixture} from 'sentry-fixture/pageFilters'; +import {CodecovPageFiltersFixture, PageFiltersFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {ProjectSdkUpdatesFixture} from 'sentry-fixture/projectSdkUpdates'; @@ -30,6 +30,7 @@ describe('NoDataMessage', () => { usePageFilters.mockImplementation(() => ({ selection: PageFiltersFixture({projects: [2]}), + codecovSelection: CodecovPageFiltersFixture(), isReady: true, shouldPersist: true, pinnedFilters: new Set(), diff --git a/static/app/views/insights/database/views/databaseLandingPage.spec.tsx b/static/app/views/insights/database/views/databaseLandingPage.spec.tsx index 8fc9f4136189fa..02bc83568969aa 100644 --- a/static/app/views/insights/database/views/databaseLandingPage.spec.tsx +++ b/static/app/views/insights/database/views/databaseLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -23,22 +24,17 @@ describe('DatabaseLandingPage', function () { ProjectFixture({hasInsightsDb: true, firstTransactionEvent: true}), ]); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/database/views/databaseSpanSummaryPage.spec.tsx b/static/app/views/insights/database/views/databaseSpanSummaryPage.spec.tsx index a4c8f54740dbb8..488a2976353936 100644 --- a/static/app/views/insights/database/views/databaseSpanSummaryPage.spec.tsx +++ b/static/app/views/insights/database/views/databaseSpanSummaryPage.spec.tsx @@ -1,5 +1,6 @@ import {GroupFixture} from 'sentry-fixture/group'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixture'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -23,22 +24,17 @@ describe('DatabaseSpanSummaryPage', function () { const group = GroupFixture(); const groupId = '1756baf8fd19c116'; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: null, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useParams).mockReturnValue({ groupId, diff --git a/static/app/views/insights/http/components/httpSamplesPanel.spec.tsx b/static/app/views/insights/http/components/httpSamplesPanel.spec.tsx index e9f00c6f7fd294..ba1d46e40ed10a 100644 --- a/static/app/views/insights/http/components/httpSamplesPanel.spec.tsx +++ b/static/app/views/insights/http/components/httpSamplesPanel.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import { render, @@ -19,22 +20,17 @@ describe('HTTPSamplesPanel', () => { let eventsRequestMock: jest.Mock; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/http/queries/useSpanSamples.spec.tsx b/static/app/views/insights/http/queries/useSpanSamples.spec.tsx index f18877f1184bc4..4ea654b762e1e1 100644 --- a/static/app/views/insights/http/queries/useSpanSamples.spec.tsx +++ b/static/app/views/insights/http/queries/useSpanSamples.spec.tsx @@ -1,5 +1,6 @@ import type {ReactNode} from 'react'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {makeTestQueryClient} from 'sentry-test/queryClient'; import {renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -25,23 +26,17 @@ describe('useSpanSamples', () => { ); } - - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: ['prod'], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: ['prod'], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ query: {}, diff --git a/static/app/views/insights/http/views/httpDomainSummaryPage.spec.tsx b/static/app/views/insights/http/views/httpDomainSummaryPage.spec.tsx index 402528be7d9f10..21c8840847da5e 100644 --- a/static/app/views/insights/http/views/httpDomainSummaryPage.spec.tsx +++ b/static/app/views/insights/http/views/httpDomainSummaryPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import { render, @@ -28,22 +29,17 @@ describe('HTTPDomainSummaryPage', function () { let domainMetricsRibbonRequestMock: jest.Mock; let regionFilterRequestMock: jest.Mock; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/http/views/httpLandingPage.spec.tsx b/static/app/views/insights/http/views/httpLandingPage.spec.tsx index f2e064b79f6165..0f529d43edacaa 100644 --- a/static/app/views/insights/http/views/httpLandingPage.spec.tsx +++ b/static/app/views/insights/http/views/httpLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -26,22 +27,17 @@ describe('HTTPLandingPage', function () { let spanListRequestMock!: jest.Mock; let regionFilterRequestMock!: jest.Mock; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); const useLocationMock = jest.mocked(useLocation); diff --git a/static/app/views/insights/mobile/appStarts/components/eventSamples.spec.tsx b/static/app/views/insights/mobile/appStarts/components/eventSamples.spec.tsx index dc327763283e35..a162cfca224213 100644 --- a/static/app/views/insights/mobile/appStarts/components/eventSamples.spec.tsx +++ b/static/app/views/insights/mobile/appStarts/components/eventSamples.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -20,22 +21,18 @@ describe('ScreenLoadEventSamples', function () { let mockEventsRequest!: jest.Mock; beforeEach(function () { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); + jest.mocked(useReleaseSelection).mockReturnValue({ primaryRelease: 'com.example.vu.android@2.10.5', isLoading: false, diff --git a/static/app/views/insights/mobile/appStarts/components/spanOpSelector.spec.tsx b/static/app/views/insights/mobile/appStarts/components/spanOpSelector.spec.tsx index 6eb14ada492a39..e40b95f51fdaa4 100644 --- a/static/app/views/insights/mobile/appStarts/components/spanOpSelector.spec.tsx +++ b/static/app/views/insights/mobile/appStarts/components/spanOpSelector.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; @@ -11,23 +12,17 @@ jest.mock('sentry/utils/usePageFilters'); describe('SpanOpSelector', function () { const organization = OrganizationFixture(); const project = ProjectFixture(); - - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/events/`, diff --git a/static/app/views/insights/mobile/appStarts/components/startDurationWidget.spec.tsx b/static/app/views/insights/mobile/appStarts/components/startDurationWidget.spec.tsx index d4889f4e9e09b7..3f6534b84d0e44 100644 --- a/static/app/views/insights/mobile/appStarts/components/startDurationWidget.spec.tsx +++ b/static/app/views/insights/mobile/appStarts/components/startDurationWidget.spec.tsx @@ -1,6 +1,7 @@ import type {Location} from 'history'; import {LocationFixture} from 'sentry-fixture/locationFixture'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -23,22 +24,17 @@ describe('StartDurationWidget', () => { const project = ProjectFixture(); beforeEach(function () { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/releases/`, body: [ diff --git a/static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.spec.tsx b/static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.spec.tsx index 58bf5c707979a6..e9590605d8e58a 100644 --- a/static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.spec.tsx +++ b/static/app/views/insights/mobile/appStarts/components/tables/spanOperationTable.spec.tsx @@ -1,5 +1,6 @@ import {LocationFixture} from 'sentry-fixture/locationFixture'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -16,22 +17,17 @@ describe('SpanOpSelector', function () { const project = ProjectFixture(); let mockEventsRequest: jest.Mock; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue(LocationFixture()); diff --git a/static/app/views/insights/mobile/appStarts/views/screenSummaryPage.spec.tsx b/static/app/views/insights/mobile/appStarts/views/screenSummaryPage.spec.tsx index b965b569931c9a..e9004a23bbe789 100644 --- a/static/app/views/insights/mobile/appStarts/views/screenSummaryPage.spec.tsx +++ b/static/app/views/insights/mobile/appStarts/views/screenSummaryPage.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor, within} from 'sentry-test/reactTestingLibrary'; @@ -31,22 +32,17 @@ describe('Screen Summary', function () { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); describe('Native Project', function () { let eventsMock: jest.Mock; diff --git a/static/app/views/insights/mobile/common/queries/useCrossPlatformProject.spec.tsx b/static/app/views/insights/mobile/common/queries/useCrossPlatformProject.spec.tsx index 8a8f0e858527fe..5d4c7a1be78952 100644 --- a/static/app/views/insights/mobile/common/queries/useCrossPlatformProject.spec.tsx +++ b/static/app/views/insights/mobile/common/queries/useCrossPlatformProject.spec.tsx @@ -1,4 +1,5 @@ import {LocationFixture} from 'sentry-fixture/locationFixture'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {renderHook} from 'sentry-test/reactTestingLibrary'; @@ -13,22 +14,17 @@ jest.mock('sentry/utils/usePageFilters'); jest.mock('sentry/utils/useLocation'); function mockPageFilters(projects: number[]) { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects, + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects, + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); } describe('useCrossPlatformProject', () => { diff --git a/static/app/views/insights/mobile/screenload/components/eventSamples.spec.tsx b/static/app/views/insights/mobile/screenload/components/eventSamples.spec.tsx index 68b66bcbe6d311..fa2063251c8bbf 100644 --- a/static/app/views/insights/mobile/screenload/components/eventSamples.spec.tsx +++ b/static/app/views/insights/mobile/screenload/components/eventSamples.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -20,22 +21,17 @@ describe('ScreenLoadEventSamples', function () { let mockEventsRequest: jest.Mock; beforeEach(function () { - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useReleaseSelection).mockReturnValue({ primaryRelease: 'com.example.vu.android@2.10.5', isLoading: false, diff --git a/static/app/views/insights/mobile/screenload/components/metricsRibbon.spec.tsx b/static/app/views/insights/mobile/screenload/components/metricsRibbon.spec.tsx index 69bcb745e21b57..54d4966ca0ea17 100644 --- a/static/app/views/insights/mobile/screenload/components/metricsRibbon.spec.tsx +++ b/static/app/views/insights/mobile/screenload/components/metricsRibbon.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -14,22 +15,17 @@ describe('MetricsRibbon', function () { const organization = OrganizationFixture(); const project = ProjectFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/releases/`, diff --git a/static/app/views/insights/mobile/screenload/components/tables/screenLoadSpansTable.spec.tsx b/static/app/views/insights/mobile/screenload/components/tables/screenLoadSpansTable.spec.tsx index 79d215fb65b602..7643fa7f49d3e9 100644 --- a/static/app/views/insights/mobile/screenload/components/tables/screenLoadSpansTable.spec.tsx +++ b/static/app/views/insights/mobile/screenload/components/tables/screenLoadSpansTable.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen, within} from 'sentry-test/reactTestingLibrary'; @@ -25,22 +26,7 @@ describe('ScreenLoadSpansTable', function () { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); let eventsMock: jest.Mock; beforeEach(function () { diff --git a/static/app/views/insights/mobile/screenload/views/screenLoadSpansPage.spec.tsx b/static/app/views/insights/mobile/screenload/views/screenLoadSpansPage.spec.tsx index 9d1d4586bbb085..a6c0aadbfb0319 100644 --- a/static/app/views/insights/mobile/screenload/views/screenLoadSpansPage.spec.tsx +++ b/static/app/views/insights/mobile/screenload/views/screenLoadSpansPage.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor, within} from 'sentry-test/reactTestingLibrary'; @@ -33,22 +34,17 @@ function mockResponses(organization: Organization, project: Project) { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/releases/`, @@ -76,7 +72,7 @@ function mockResponses(organization: Organization, project: Project) { query: 'transaction.op:ui.load release:["com.example.vu.android@2.10.5","com.example.vu.android@2.10.3+42"]', referrer: 'api.starfish.mobile-release-selector', - statsPeriod: '10d', + statsPeriod: '14d', }, body: { meta: {}, diff --git a/static/app/views/insights/mobile/screenload/views/screenloadLandingPage.spec.tsx b/static/app/views/insights/mobile/screenload/views/screenloadLandingPage.spec.tsx index 5be9e3f02e54f6..79ee1add616052 100644 --- a/static/app/views/insights/mobile/screenload/views/screenloadLandingPage.spec.tsx +++ b/static/app/views/insights/mobile/screenload/views/screenloadLandingPage.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -36,22 +37,17 @@ describe('PageloadModule', function () { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); let eventsMock: jest.Mock; beforeEach(function () { @@ -82,7 +78,7 @@ describe('PageloadModule', function () { query: 'transaction.op:ui.load release:["com.example.vu.android@2.10.5","com.example.vu.android@2.10.3+42"]', referrer: 'api.starfish.mobile-release-selector', - statsPeriod: '10d', + statsPeriod: '14d', }, body: { meta: {}, diff --git a/static/app/views/insights/mobile/screens/components/screensOverview.spec.tsx b/static/app/views/insights/mobile/screens/components/screensOverview.spec.tsx index f19015963bebdf..8eb7bd52992f38 100644 --- a/static/app/views/insights/mobile/screens/components/screensOverview.spec.tsx +++ b/static/app/views/insights/mobile/screens/components/screensOverview.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary'; @@ -31,22 +32,17 @@ describe('ScreensOverview', () => { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useCrossPlatformProject).mockReturnValue({ project, diff --git a/static/app/views/insights/mobile/screens/components/screensOverviewTable.spec.tsx b/static/app/views/insights/mobile/screens/components/screensOverviewTable.spec.tsx index 821d41734ecd9b..8bc187c21f8fa0 100644 --- a/static/app/views/insights/mobile/screens/components/screensOverviewTable.spec.tsx +++ b/static/app/views/insights/mobile/screens/components/screensOverviewTable.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -32,22 +33,17 @@ describe('ScreensOverviewTable', () => { } as Location; jest.mocked(useLocation).mockReturnValue(location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); const mockEventView = EventView.fromLocation(location); diff --git a/static/app/views/insights/mobile/screens/views/screenDetailsPage.spec.tsx b/static/app/views/insights/mobile/screens/views/screenDetailsPage.spec.tsx index 6863c7fb20182c..ed1f0a744338e4 100644 --- a/static/app/views/insights/mobile/screens/views/screenDetailsPage.spec.tsx +++ b/static/app/views/insights/mobile/screens/views/screenDetailsPage.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, within} from 'sentry-test/reactTestingLibrary'; @@ -30,22 +31,17 @@ describe('ScreenDetailsPage', function () { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); describe('Tabs', function () { beforeEach(() => { diff --git a/static/app/views/insights/mobile/screens/views/screensLandingPage.spec.tsx b/static/app/views/insights/mobile/screens/views/screensLandingPage.spec.tsx index 1b4211ddcfa28e..3003dc81b88752 100644 --- a/static/app/views/insights/mobile/screens/views/screensLandingPage.spec.tsx +++ b/static/app/views/insights/mobile/screens/views/screensLandingPage.spec.tsx @@ -1,5 +1,6 @@ import type {Location} from 'history'; import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitFor, within} from 'sentry-test/reactTestingLibrary'; @@ -32,22 +33,17 @@ describe('Screens Landing Page', function () { state: undefined, } as Location); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useCrossPlatformProject).mockReturnValue({ project, diff --git a/static/app/views/insights/mobile/ui/components/tables/spanOperationTable.spec.tsx b/static/app/views/insights/mobile/ui/components/tables/spanOperationTable.spec.tsx index cb42a8d8e7b0b3..fc600886a4b791 100644 --- a/static/app/views/insights/mobile/ui/components/tables/spanOperationTable.spec.tsx +++ b/static/app/views/insights/mobile/ui/components/tables/spanOperationTable.spec.tsx @@ -1,3 +1,5 @@ +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; + import {render, screen} from 'sentry-test/reactTestingLibrary'; import usePageFilters from 'sentry/utils/usePageFilters'; @@ -6,22 +8,7 @@ import {Referrer} from 'sentry/views/insights/mobile/ui/referrers'; jest.mock('sentry/utils/usePageFilters'); -jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, -}); +jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); describe('SpanOperationTable', () => { it('renders and fetches the proper data', () => { diff --git a/static/app/views/insights/mobile/ui/components/uiScreens.spec.tsx b/static/app/views/insights/mobile/ui/components/uiScreens.spec.tsx index 54b68c9c224b46..f40ef8b4c17e01 100644 --- a/static/app/views/insights/mobile/ui/components/uiScreens.spec.tsx +++ b/static/app/views/insights/mobile/ui/components/uiScreens.spec.tsx @@ -1,3 +1,4 @@ +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -42,22 +43,17 @@ describe('Performance Mobile UI Screens', () => { beforeEach(() => { MockApiClient.clearMockResponses(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '14d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); }); it('queries for the correct table data', async () => { diff --git a/static/app/views/insights/pages/backend/backendOverviewPage.spec.tsx b/static/app/views/insights/pages/backend/backendOverviewPage.spec.tsx index c5a8260bbf75ba..e9643b146c11f4 100644 --- a/static/app/views/insights/pages/backend/backendOverviewPage.spec.tsx +++ b/static/app/views/insights/pages/backend/backendOverviewPage.spec.tsx @@ -1,5 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; -import {PageFiltersFixture} from 'sentry-fixture/pageFilters'; +import {CodecovPageFiltersFixture, PageFiltersFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -181,6 +181,7 @@ const setupMocks = () => { pinnedFilters: new Set(), shouldPersist: true, selection: pageFilterSelection, + codecovSelection: CodecovPageFiltersFixture(), }); ProjectsStore.loadInitialData(projects); }; diff --git a/static/app/views/insights/pages/frontend/frontendOverviewPage.spec.tsx b/static/app/views/insights/pages/frontend/frontendOverviewPage.spec.tsx index e030b7ec1ae510..82c5174152d14a 100644 --- a/static/app/views/insights/pages/frontend/frontendOverviewPage.spec.tsx +++ b/static/app/views/insights/pages/frontend/frontendOverviewPage.spec.tsx @@ -1,5 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; -import {PageFiltersFixture} from 'sentry-fixture/pageFilters'; +import {CodecovPageFiltersFixture, PageFiltersFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -64,6 +64,7 @@ describe('FrontendOverviewPage', () => { datetime: pageFilterSelection.datetime, environments: [], }, + codecovSelection: CodecovPageFiltersFixture(), }); render(, {organization}); @@ -194,6 +195,7 @@ const setupMocks = () => { pinnedFilters: new Set(), shouldPersist: true, selection: pageFilterSelection, + codecovSelection: CodecovPageFiltersFixture(), }); ProjectsStore.loadInitialData(projects); }; diff --git a/static/app/views/insights/queues/components/messageSpanSamplesPanel.spec.tsx b/static/app/views/insights/queues/components/messageSpanSamplesPanel.spec.tsx index 5f37b6aa3a140e..ecf6a6b6567a5e 100644 --- a/static/app/views/insights/queues/components/messageSpanSamplesPanel.spec.tsx +++ b/static/app/views/insights/queues/components/messageSpanSamplesPanel.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -17,22 +18,17 @@ describe('messageSpanSamplesPanel', () => { let samplesRequestMock: jest.Mock; let spanFieldTagsMock: jest.Mock; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/static/app/views/insights/queues/views/destinationSummaryPage.spec.tsx b/static/app/views/insights/queues/views/destinationSummaryPage.spec.tsx index a6e3247dceab20..a56f85582b4aa0 100644 --- a/static/app/views/insights/queues/views/destinationSummaryPage.spec.tsx +++ b/static/app/views/insights/queues/views/destinationSummaryPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -19,27 +20,12 @@ describe('destinationSummaryPage', () => { }); const project = ProjectFixture({firstTransactionEvent: true}); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); jest.mocked(useLocation).mockReturnValue({ pathname: '', search: '', - query: {statsPeriod: '10d', project: project.id}, + query: {statsPeriod: '14d', project: project.id}, hash: '', state: undefined, action: 'PUSH', diff --git a/static/app/views/insights/queues/views/queuesLandingPage.spec.tsx b/static/app/views/insights/queues/views/queuesLandingPage.spec.tsx index 111970bf4f4160..7ddfa57ae3b9e1 100644 --- a/static/app/views/insights/queues/views/queuesLandingPage.spec.tsx +++ b/static/app/views/insights/queues/views/queuesLandingPage.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -21,27 +22,12 @@ describe('queuesLandingPage', () => { project.firstTransactionEvent = true; project.hasInsightsQueues = true; - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); jest.mocked(useLocation).mockReturnValue({ pathname: '', search: '', - query: {statsPeriod: '10d', project: '1'}, + query: {statsPeriod: '14d', project: '1'}, hash: '', state: undefined, action: 'PUSH', diff --git a/static/app/views/insights/uptime/views/overview.spec.tsx b/static/app/views/insights/uptime/views/overview.spec.tsx index c222ad8bf76315..5b166b88beab9d 100644 --- a/static/app/views/insights/uptime/views/overview.spec.tsx +++ b/static/app/views/insights/uptime/views/overview.spec.tsx @@ -1,4 +1,5 @@ import {LocationFixture} from 'sentry-fixture/locationFixture'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {RouterFixture} from 'sentry-fixture/routerFixture'; import {TeamFixture} from 'sentry-fixture/team'; @@ -26,22 +27,7 @@ describe('Uptime Overview', function () { const project = ProjectFixture(); const team = TeamFixture(); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [], - }, - }); + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture()); beforeEach(function () { OrganizationStore.init(); diff --git a/static/app/views/performance/transactionSummary/transactionSpans/spanSummary/content.spec.tsx b/static/app/views/performance/transactionSummary/transactionSpans/spanSummary/content.spec.tsx index 42a851693bcae1..9c5cd4d42a5558 100644 --- a/static/app/views/performance/transactionSummary/transactionSpans/spanSummary/content.spec.tsx +++ b/static/app/views/performance/transactionSummary/transactionSpans/spanSummary/content.spec.tsx @@ -1,4 +1,5 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; import {ProjectFixture} from 'sentry-fixture/project'; import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; @@ -29,22 +30,17 @@ describe('SpanSummaryPage', function () { ProjectsStore.loadInitialData([project]); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '10d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [parseInt(project.id, 10)], + const selection = { + datetime: { + period: '10d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [parseInt(project.id, 10)], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); let headerDataMock: jest.Mock; let avgDurationChartMock: jest.Mock; diff --git a/static/gsApp/components/performance/quotaExceededAlert.spec.tsx b/static/gsApp/components/performance/quotaExceededAlert.spec.tsx index 1a5d73a705ffce..58e855e91d1598 100644 --- a/static/gsApp/components/performance/quotaExceededAlert.spec.tsx +++ b/static/gsApp/components/performance/quotaExceededAlert.spec.tsx @@ -1,3 +1,5 @@ +import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; + import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription'; import {initializeOrg} from 'sentry-test/initializeOrg'; import {render, screen} from 'sentry-test/reactTestingLibrary'; @@ -28,22 +30,17 @@ describe('Renders QuotaExceededAlert correctly', function () { }); beforeEach(function () { setMockDate(new Date('2024-12-14').getTime()); - jest.mocked(usePageFilters).mockReturnValue({ - isReady: true, - desyncedFilters: new Set(), - pinnedFilters: new Set(), - shouldPersist: true, - selection: { - datetime: { - period: '7d', - start: null, - end: null, - utc: false, - }, - environments: [], - projects: [2], + const selection = { + datetime: { + period: '7d', + start: null, + end: null, + utc: false, }, - }); + environments: [], + projects: [2], + }; + jest.mocked(usePageFilters).mockReturnValue(PageFilterStateFixture({selection})); jest.mocked(useLocation).mockReturnValue({ pathname: '', diff --git a/tests/js/fixtures/pageFilters.ts b/tests/js/fixtures/pageFilters.ts index 83f5e06014fa31..bfc8086b9a2259 100644 --- a/tests/js/fixtures/pageFilters.ts +++ b/tests/js/fixtures/pageFilters.ts @@ -1,4 +1,6 @@ -import type {PageFilters} from 'sentry/types/core'; +import type {PageFilters, CodecovPageFilters} from 'sentry/types/core'; +import type {PageFiltersState} from 'sentry/stores/pageFiltersStore'; +import type {PinnedPageFilter} from 'sentry/types/core'; export function PageFiltersFixture(params: Partial = {}): PageFilters { return { @@ -13,3 +15,38 @@ export function PageFiltersFixture(params: Partial = {}): PageFilte ...params, }; } + +export function CodecovPageFiltersFixture(params: Partial = {}): CodecovPageFilters { + return { + repository: null, + ...params, + }; +} + +export function GetPageFiltersStorageFixture(params = {}) { + return { + pinnedFilters: new Set(['projects']), + state: { + project: [], + environment: [], + start: null, + end: null, + period: '14d', + utc: null, + repository: null, + }, + ...params + }; +} + +export function PageFilterStateFixture(params: Partial = {}) { + return { + isReady: true, + desyncedFilters: new Set(), + pinnedFilters: new Set(), + shouldPersist: true, + selection: PageFiltersFixture(), + codecovSelection: CodecovPageFiltersFixture(), + ...params + } +}