-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(dashboards): temporary filters broken when changing values #104482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DominikB2014
merged 9 commits into
master
from
dominikbuszowiecki/browse-177-global-filter-change-on-query-details-page-has-no-effect-on
Dec 8, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1befac4
handle temporary filters when changing values
DominikB2014 365dd7a
update remove logic
DominikB2014 d908a59
add tests
DominikB2014 7df88df
tests
DominikB2014 59a2f78
add remove filter logic to numeric filters
DominikB2014 828b93e
fix
DominikB2014 7c4531c
add tests
DominikB2014 842d629
deduplicate
DominikB2014 2f9c008
code review
DominikB2014 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| // create a basic test for filters bar | ||
|
|
||
| import {LocationFixture} from 'sentry-fixture/locationFixture'; | ||
| import {OrganizationFixture} from 'sentry-fixture/organization'; | ||
| import {ReleaseFixture} from 'sentry-fixture/release'; | ||
| import {TagsFixture} from 'sentry-fixture/tags'; | ||
|
|
||
| import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary'; | ||
|
|
||
| import type {Organization} from 'sentry/types/organization'; | ||
| import {FieldKind} from 'sentry/utils/fields'; | ||
| import FiltersBar, {type FiltersBarProps} from 'sentry/views/dashboards/filtersBar'; | ||
| import { | ||
| DashboardFilterKeys, | ||
| WidgetType, | ||
| type GlobalFilter, | ||
| } from 'sentry/views/dashboards/types'; | ||
| import {PrebuiltDashboardId} from 'sentry/views/dashboards/utils/prebuiltConfigs'; | ||
|
|
||
| describe('FiltersBar', () => { | ||
| let organization: Organization; | ||
|
|
||
| beforeEach(() => { | ||
| mockNetworkRequests(); | ||
|
|
||
| organization = OrganizationFixture({ | ||
| features: ['dashboards-basic', 'dashboards-edit', 'dashboards-global-filters'], | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| MockApiClient.clearMockResponses(); | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| const renderFilterBar = (overrides: Partial<FiltersBarProps> = {}) => { | ||
| const props: FiltersBarProps = { | ||
| filters: {}, | ||
| hasUnsavedChanges: false, | ||
| isEditingDashboard: false, | ||
| isPreview: false, | ||
| location: LocationFixture(), | ||
| onDashboardFilterChange: () => {}, | ||
| ...overrides, | ||
| }; | ||
|
|
||
| return render(<FiltersBar {...props} />, {organization}); | ||
| }; | ||
|
|
||
| it('should render basic global filter', async () => { | ||
| const newLocation = LocationFixture({ | ||
| query: { | ||
| [DashboardFilterKeys.GLOBAL_FILTER]: JSON.stringify({ | ||
| dataset: WidgetType.SPANS, | ||
| tag: {key: 'browser.name', name: 'Browser Name', kind: FieldKind.FIELD}, | ||
| value: `browser.name:[Chrome]`, | ||
| } satisfies GlobalFilter), | ||
| }, | ||
| }); | ||
| renderFilterBar({location: newLocation}); | ||
| await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); | ||
| expect( | ||
| screen.getByRole('button', {name: /browser\.name.*Chrome/i}) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render save button with unsaved changes', async () => { | ||
| const newLocation = LocationFixture({ | ||
| query: { | ||
| [DashboardFilterKeys.GLOBAL_FILTER]: JSON.stringify({ | ||
| dataset: WidgetType.SPANS, | ||
| tag: {key: 'browser.name', name: 'Browser Name', kind: FieldKind.FIELD}, | ||
| value: `browser.name:[Chrome]`, | ||
| } satisfies GlobalFilter), | ||
| }, | ||
| }); | ||
| renderFilterBar({location: newLocation, hasUnsavedChanges: true}); | ||
| await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); | ||
| expect(screen.getByRole('button', {name: 'Save'})).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', {name: 'Cancel'})).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should not render save button with temporary filter', async () => { | ||
| const newLocation = LocationFixture({ | ||
| query: { | ||
| [DashboardFilterKeys.GLOBAL_FILTER]: JSON.stringify({ | ||
| dataset: WidgetType.SPANS, | ||
| tag: {key: 'browser.name', name: 'Browser Name', kind: FieldKind.FIELD}, | ||
| value: `browser.name:[Chrome]`, | ||
| isTemporary: true, | ||
| } satisfies GlobalFilter), | ||
| }, | ||
| }); | ||
|
|
||
| renderFilterBar({location: newLocation}); | ||
| await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); | ||
| expect( | ||
| screen.getByRole('button', {name: /browser\.name.*Chrome/i}) | ||
| ).toBeInTheDocument(); | ||
| expect(screen.queryByRole('button', {name: 'Save'})).not.toBeInTheDocument(); | ||
| expect(screen.queryByRole('button', {name: 'Cancel'})).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should not render save button on prebuilt dashboard', async () => { | ||
| const newLocation = LocationFixture({ | ||
| query: { | ||
| [DashboardFilterKeys.GLOBAL_FILTER]: JSON.stringify({ | ||
| dataset: WidgetType.SPANS, | ||
| tag: {key: 'browser.name', name: 'Browser Name', kind: FieldKind.FIELD}, | ||
| value: `browser.name:[Chrome]`, | ||
| } satisfies GlobalFilter), | ||
| }, | ||
| }); | ||
| renderFilterBar({ | ||
| location: newLocation, | ||
| prebuiltDashboardId: PrebuiltDashboardId.FRONTEND_SESSION_HEALTH, | ||
| }); | ||
| await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); | ||
| expect( | ||
| screen.getByRole('button', {name: /browser\.name.*Chrome/i}) | ||
| ).toBeInTheDocument(); | ||
| expect(screen.queryByRole('button', {name: 'Save'})).not.toBeInTheDocument(); | ||
| expect(screen.queryByRole('button', {name: 'Cancel'})).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| const mockNetworkRequests = () => { | ||
| MockApiClient.addMockResponse({ | ||
| url: '/organizations/org-slug/releases/', | ||
| body: [ReleaseFixture()], | ||
| }); | ||
| MockApiClient.addMockResponse({ | ||
| url: '/organizations/org-slug/tags/', | ||
| body: TagsFixture(), | ||
| }); | ||
| MockApiClient.addMockResponse({ | ||
| url: `/organizations/org-slug/measurements-meta/`, | ||
| body: { | ||
| 'measurements.custom.measurement': { | ||
| functions: ['p99'], | ||
| }, | ||
| 'measurements.another.custom.measurement': { | ||
| functions: ['p99'], | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const mockSearchResponse = [ | ||
| { | ||
| key: 'browser.name', | ||
| value: 'Chrome', | ||
| name: 'Chrome', | ||
| first_seen: null, | ||
| last_seen: null, | ||
| times_seen: null, | ||
| }, | ||
| { | ||
| key: 'browser.name', | ||
| value: 'Firefox', | ||
| name: 'Firefox', | ||
| first_seen: null, | ||
| last_seen: null, | ||
| times_seen: null, | ||
| }, | ||
| ]; | ||
|
|
||
| MockApiClient.addMockResponse({ | ||
| url: `/organizations/org-slug/trace-items/attributes/browser.name/values/`, | ||
| body: mockSearchResponse, | ||
| match: [MockApiClient.matchQuery({attributeType: 'string'})], | ||
| }); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.