-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(preprod): Auto-filter installable:true when switching to Distribution view #112533
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
mtopo27
merged 5 commits into
master
from
mtopo27/feat/auto-filter-installable-distribution-view
Apr 13, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
585a54c
feat(preprod): Auto-filter installable:true when switching to Distrib…
mtopo27 d39d819
ref(preprod): Extract getUpdatedQueryForDisplay to deduplicate displa…
mtopo27 df8a09e
ref(preprod): Move installableQueryUtils to views/preprod/utils
mtopo27 41ee7d6
test(preprod): Simplify display-change integration tests
mtopo27 06459b0
fix(preprod): Prevent debounce effect from undoing display-change que…
mtopo27 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
83 changes: 83 additions & 0 deletions
83
static/app/views/preprod/utils/installableQueryUtils.spec.ts
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,83 @@ | ||
| import {PreprodBuildsDisplay} from 'sentry/components/preprod/preprodBuildsDisplay'; | ||
|
|
||
| import { | ||
| addInstallableFilter, | ||
| getUpdatedQueryForDisplay, | ||
| removeInstallableFilter, | ||
| } from './installableQueryUtils'; | ||
|
|
||
| describe('addInstallableFilter', () => { | ||
| it('adds installable:true to an empty query', () => { | ||
| expect(addInstallableFilter('')).toBe('installable:true'); | ||
| }); | ||
|
|
||
| it('appends installable:true to an existing query', () => { | ||
| expect(addInstallableFilter('app_id:com.example')).toBe( | ||
| 'app_id:com.example installable:true' | ||
| ); | ||
| }); | ||
|
|
||
| it('does not double-add if already present', () => { | ||
| expect(addInstallableFilter('installable:true')).toBe('installable:true'); | ||
| }); | ||
|
|
||
| it('does not double-add when mixed with other tokens', () => { | ||
| expect(addInstallableFilter('app_id:com.example installable:true')).toBe( | ||
| 'app_id:com.example installable:true' | ||
| ); | ||
| }); | ||
|
|
||
| it('replaces installable:false with installable:true', () => { | ||
| expect(addInstallableFilter('installable:false')).toBe('installable:true'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('removeInstallableFilter', () => { | ||
| it('removes installable:true from a query', () => { | ||
| expect(removeInstallableFilter('app_id:com.example installable:true')).toBe( | ||
| 'app_id:com.example' | ||
| ); | ||
| }); | ||
|
|
||
| it('returns empty string when only installable:true', () => { | ||
| expect(removeInstallableFilter('installable:true')).toBe(''); | ||
| }); | ||
|
|
||
| it('is a no-op when installable is not present', () => { | ||
| expect(removeInstallableFilter('app_id:com.example')).toBe('app_id:com.example'); | ||
| }); | ||
|
|
||
| it('returns empty string for empty input', () => { | ||
| expect(removeInstallableFilter('')).toBe(''); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getUpdatedQueryForDisplay', () => { | ||
| it('adds installable:true for Distribution display', () => { | ||
| expect(getUpdatedQueryForDisplay('', PreprodBuildsDisplay.DISTRIBUTION)).toBe( | ||
| 'installable:true' | ||
| ); | ||
| }); | ||
|
|
||
| it('removes installable filter for Size display', () => { | ||
| expect( | ||
| getUpdatedQueryForDisplay('installable:true', PreprodBuildsDisplay.SIZE) | ||
| ).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('handles null query', () => { | ||
| expect(getUpdatedQueryForDisplay(null, PreprodBuildsDisplay.DISTRIBUTION)).toBe( | ||
| 'installable:true' | ||
| ); | ||
| }); | ||
|
|
||
| it('preserves other tokens when switching to Distribution', () => { | ||
| expect( | ||
| getUpdatedQueryForDisplay('app_id:com.example', PreprodBuildsDisplay.DISTRIBUTION) | ||
| ).toBe('app_id:com.example installable:true'); | ||
| }); | ||
|
|
||
| it('returns undefined when result is empty', () => { | ||
| expect(getUpdatedQueryForDisplay('', PreprodBuildsDisplay.SIZE)).toBeUndefined(); | ||
| }); | ||
| }); |
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,43 @@ | ||
| import {PreprodBuildsDisplay} from 'sentry/components/preprod/preprodBuildsDisplay'; | ||
| import {MutableSearch} from 'sentry/components/searchSyntax/mutableSearch'; | ||
|
|
||
| const INSTALLABLE_KEY = 'installable'; | ||
| const INSTALLABLE_VALUE = 'true'; | ||
|
|
||
| /** | ||
| * Adds `installable:true` to a search query string if not already present. | ||
| */ | ||
| export function addInstallableFilter(query: string): string { | ||
| const search = new MutableSearch(query); | ||
| const existing = search.getFilterValues(INSTALLABLE_KEY); | ||
| if (existing.includes(INSTALLABLE_VALUE)) { | ||
| return query; | ||
| } | ||
| search.setFilterValues(INSTALLABLE_KEY, [INSTALLABLE_VALUE]); | ||
| return search.formatString(); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the `installable` filter from a search query string. | ||
| */ | ||
| export function removeInstallableFilter(query: string): string { | ||
| const search = new MutableSearch(query); | ||
| search.removeFilter(INSTALLABLE_KEY); | ||
| return search.formatString(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the updated query string for a display change. | ||
| * Distribution display adds `installable:true`; other displays strip it. | ||
| */ | ||
| export function getUpdatedQueryForDisplay( | ||
| currentQuery: string | null, | ||
| display: PreprodBuildsDisplay | ||
| ): string | undefined { | ||
| const trimmed = (currentQuery ?? '').trim(); | ||
| const updated = | ||
| display === PreprodBuildsDisplay.DISTRIBUTION | ||
| ? addInstallableFilter(trimmed) | ||
| : removeInstallableFilter(trimmed); | ||
| return updated || undefined; | ||
| } |
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
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.