diff --git a/static/app/views/issueList/overview.spec.tsx b/static/app/views/issueList/overview.spec.tsx index d0fd8ab3948a..3bea5981f09c 100644 --- a/static/app/views/issueList/overview.spec.tsx +++ b/static/app/views/issueList/overview.spec.tsx @@ -346,6 +346,7 @@ describe('IssueList', () => { await waitFor(() => { expect(testRouter.location.query).toEqual({ cursor: '1443575000:0:0', + groupStatsPeriod: 'auto', page: '1', project: '3559', query: DEFAULT_QUERY, @@ -364,6 +365,7 @@ describe('IssueList', () => { await waitFor(() => { expect(testRouter.location.query).toEqual({ cursor: '1443574000:0:0', + groupStatsPeriod: 'auto', page: '2', project: '3559', query: DEFAULT_QUERY, @@ -378,6 +380,7 @@ describe('IssueList', () => { await waitFor(() => { expect(testRouter.location.query).toEqual({ cursor: '1443575000:0:1', + groupStatsPeriod: 'auto', page: '1', project: '3559', query: DEFAULT_QUERY, @@ -512,6 +515,7 @@ describe('IssueList', () => { await waitFor(() => { expect(testRouter.location.query).toEqual({ + groupStatsPeriod: 'auto', project: project.id.toString(), query: 'is:ignored', statsPeriod: '14d', @@ -632,7 +636,39 @@ describe('IssueList', () => { expect(fetchDataMock).toHaveBeenLastCalledWith( '/organizations/org-slug/issues/', expect.objectContaining({ - data: 'collapse=stats&collapse=unhandled&expand=owners&expand=inbox&limit=25&project=99&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&shortIdLookup=1&statsPeriod=14d', + data: 'collapse=stats&collapse=unhandled&expand=owners&expand=inbox&groupStatsPeriod=auto&limit=25&project=99&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&shortIdLookup=1&statsPeriod=14d', + }) + ); + }); + }); + + it('defaults the row graph period to auto so it follows the global time range', async () => { + const {rerender} = render(, { + initialRouterConfig: merge({}, initialRouterConfig, { + location: { + query: { + query: DEFAULT_QUERY, + }, + }, + }), + }); + + act(() => + PageFiltersStore.onInitializeUrlState({ + projects: [99], + environments: [], + datetime: {period: '14d', start: null, end: null, utc: null}, + }) + ); + + rerender(); + + await waitFor(() => { + expect(fetchDataMock).toHaveBeenNthCalledWith( + 2, + '/organizations/org-slug/issues/', + expect.objectContaining({ + data: 'collapse=stats&collapse=unhandled&expand=owners&expand=inbox&groupStatsPeriod=auto&limit=25&project=99&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&shortIdLookup=1&statsPeriod=14d', }) ); }); diff --git a/static/app/views/issueList/overview.tsx b/static/app/views/issueList/overview.tsx index 8a095b7e19e8..b3cd36843f97 100644 --- a/static/app/views/issueList/overview.tsx +++ b/static/app/views/issueList/overview.tsx @@ -81,10 +81,10 @@ import { } from './utils'; const MAX_ITEMS = 25; -// the default period for the graph in each issue row -const DEFAULT_GRAPH_STATS_PERIOD = '24h'; // the allowed period choices for graph in each issue row const DYNAMIC_COUNTS_STATS_PERIODS = new Set(['14d', '24h', 'auto']); +// when no explicit period is chosen, follow the global time range selector +const DEFAULT_GRAPH_STATS_PERIOD = 'auto'; const MAX_ISSUES_COUNT = 100; interface Props { @@ -272,7 +272,9 @@ function IssueListOverviewInner({ } const groupStatsPeriod = getGroupStatsPeriod(); - if (groupStatsPeriod !== DEFAULT_GRAPH_STATS_PERIOD) { + // The backend treats a missing groupStatsPeriod as '24h', so 'auto' + // (follow the global time range) has to be sent explicitly. + if (groupStatsPeriod !== '24h') { params.groupStatsPeriod = groupStatsPeriod; }