diff --git a/static/app/components/core/compactSelect/compactSelect.tsx b/static/app/components/core/compactSelect/compactSelect.tsx index ffdbaa4899503d..c7f79d9c9c4b08 100644 --- a/static/app/components/core/compactSelect/compactSelect.tsx +++ b/static/app/components/core/compactSelect/compactSelect.tsx @@ -26,16 +26,10 @@ interface BaseSelectProps } export type SingleSelectProps = BaseSelectProps & - DistributiveOmit< - SingleListProps, - 'children' | 'items' | 'grid' | 'compositeIndex' | 'label' - >; + DistributiveOmit, 'children' | 'items' | 'grid' | 'label'>; export type MultipleSelectProps = BaseSelectProps & - DistributiveOmit< - MultipleListProps, - 'children' | 'items' | 'grid' | 'compositeIndex' | 'label' - >; + DistributiveOmit, 'children' | 'items' | 'grid' | 'label'>; export type SelectProps = | SingleSelectProps @@ -126,6 +120,8 @@ export function CompactSelect({ disabled={controlDisabled} grid={grid} size={size} + items={itemsWithKey} + value={value} clearable={clearable} onClear={({overlayState}) => { if (clearable) { @@ -154,11 +150,11 @@ export function CompactSelect({ if ('options' in item) { return (
- {item.options.map(opt => ( + {item.options?.map(opt => ( {opt.label} - ))} + )) ?? null}
); } diff --git a/static/app/components/core/compactSelect/composite.tsx b/static/app/components/core/compactSelect/composite.tsx index cc13a37bcdafbd..471bc44cc8f7f8 100644 --- a/static/app/components/core/compactSelect/composite.tsx +++ b/static/app/components/core/compactSelect/composite.tsx @@ -30,10 +30,7 @@ interface BaseCompositeSelectRegion { */ type SingleCompositeSelectRegion = BaseCompositeSelectRegion & - DistributiveOmit< - SingleListProps, - 'children' | 'items' | 'grid' | 'compositeIndex' | 'size' - >; + DistributiveOmit, 'children' | 'items' | 'grid' | 'size'>; /** * A multiple-selection (multiple options can be selected at the same time) "region" @@ -43,10 +40,7 @@ type SingleCompositeSelectRegion = */ type MultipleCompositeSelectRegion = BaseCompositeSelectRegion & - DistributiveOmit< - MultipleListProps, - 'children' | 'items' | 'grid' | 'compositeIndex' | 'size' - >; + DistributiveOmit, 'children' | 'items' | 'grid' | 'size'>; /** * A "region" inside a composite select. Each "region" is a separated, self-contained @@ -68,7 +62,7 @@ type CompositeSelectChild = | undefined; export interface CompositeSelectProps - extends Omit { + extends Omit { /** * The "regions" inside this composite selector. Each region functions as a separated, * self-contained selectable list (each renders as a `ul` with its own list state) @@ -94,14 +88,12 @@ function CompositeSelect({ - {Children.map(children, (child, index) => { + {Children.map(children, child => { if (!child) { return null; } - return ( - - ); + return ; })} {/* Only displayed when all lists (regions) are empty */} @@ -129,7 +121,6 @@ CompositeSelect.Region = function ( export {CompositeSelect}; type RegionProps = CompositeSelectRegion & { - compositeIndex: SingleListProps['compositeIndex']; grid: SingleListProps['grid']; size: SingleListProps['size']; }; @@ -138,7 +129,6 @@ function Region({ options, isOptionDisabled, size, - compositeIndex, label, ...props }: RegionProps) { @@ -150,7 +140,6 @@ function Region({ items={itemsWithKey} isOptionDisabled={isOptionDisabled} shouldFocusWrap={false} - compositeIndex={compositeIndex} size={size} label={label} > diff --git a/static/app/components/core/compactSelect/control.tsx b/static/app/components/core/compactSelect/control.tsx index d0af9ad9de041e..f1679b2ea9d3bb 100644 --- a/static/app/components/core/compactSelect/control.tsx +++ b/static/app/components/core/compactSelect/control.tsx @@ -31,7 +31,7 @@ import useOverlay from 'sentry/utils/useOverlay'; import usePrevious from 'sentry/utils/usePrevious'; import type {SingleListProps} from './list'; -import type {SelectKey, SelectOption} from './types'; +import type {SelectKey, SelectOptionOrSection} from './types'; // autoFocus react attribute is sync called on render, this causes // layout thrashing and is bad for performance. This thin wrapper function @@ -49,15 +49,6 @@ function nextFrameCallback(cb: () => void) { interface SelectContextValue { overlayIsOpen: boolean; - /** - * Function to be called when a list's selection state changes. We need a complete - * list of all selected options to label the trigger button. The `index` parameter - * identifies the list. - */ - saveSelectedOptions: ( - index: number, - newSelectedOptions: SelectOption | Array> - ) => void; /** * Search string to determine whether an option should be rendered in the select list. */ @@ -70,7 +61,6 @@ interface SelectContextValue { } export const SelectContext = createContext({ - saveSelectedOptions: () => {}, overlayIsOpen: false, search: '', }); @@ -79,10 +69,7 @@ export interface ControlProps extends Omit< React.BaseHTMLAttributes, // omit keys from SingleListProps because those will be passed to instead - | keyof Omit< - SingleListProps, - 'children' | 'items' | 'grid' | 'compositeIndex' | 'label' - > + | keyof Omit, 'children' | 'items' | 'grid' | 'label'> | 'defaultValue' >, Pick< @@ -186,6 +173,7 @@ export interface ControlProps */ searchable?: boolean; size?: FormSize; + /** * Optional replacement for the default trigger button. Note that the replacement must * forward `props` and `ref` its outer wrap, otherwise many accessibility features @@ -233,6 +221,8 @@ export function Control({ menuBody, menuFooter, onOpenChange, + items = [], + value, // Select props size = 'md', @@ -246,7 +236,10 @@ export function Control({ grid = false, children, ...wrapperProps -}: ControlProps) { +}: ControlProps & { + items?: Array>; + value?: SelectKey | SelectKey[] | undefined; +}) { const wrapperRef = useRef(null); /** * Search/filter value, used to filter out the list of displayed elements @@ -285,14 +278,6 @@ export function Control({ }, }); - /** - * Clears selection values - */ - const clearSelection = () => { - setSelectedOptions([]); - onClear?.({overlayState}); - }; - // Manage overlay position const { isOpen: overlayIsOpen, @@ -412,24 +397,6 @@ export function Control({ [search] ); - /** - * A list of selected options across all select regions, to be used to generate the - * trigger label. - */ - const [selectedOptions, setSelectedOptions] = useState< - Array | Array>> - >([]); - const saveSelectedOptions = useCallback( - (index, newSelectedOptions) => { - setSelectedOptions(current => [ - ...current.slice(0, index), - newSelectedOptions, - ...current.slice(index + 1), - ]); - }, - [] - ); - /** * Trigger label, generated from current selection values. If more than one option is * selected, then a count badge will appear. @@ -439,7 +406,13 @@ export function Control({ return triggerLabelProp; } - const options = selectedOptions.flat().filter(Boolean); + const values = Array.isArray(value) ? value : [value]; + const options = items + .flatMap(item => { + if ('options' in item) return item.options?.flat(); + return item; + }) + .filter(item => values.includes(item.value)); if (options.length === 0) { return {t('None')}; @@ -453,7 +426,7 @@ export function Control({ )} ); - }, [triggerLabelProp, selectedOptions]); + }, [triggerLabelProp, value, items]); const {keyboardProps: triggerKeyboardProps} = useKeyboard({ onKeyDown: e => { @@ -467,19 +440,22 @@ export function Control({ }, }); - const showClearButton = useMemo( - () => selectedOptions.flat().length > 0, - [selectedOptions] - ); + const hasSelection = useMemo(() => { + const selectedOptions = Array.isArray(value) + ? value + : value === undefined + ? [] + : [value]; + return selectedOptions.flat().length > 0; + }, [value]); const contextValue = useMemo(() => { return { - saveSelectedOptions, overlayState, overlayIsOpen, search, }; - }, [saveSelectedOptions, overlayState, overlayIsOpen, search]); + }, [overlayState, overlayIsOpen, search]); const theme = useTheme(); @@ -499,67 +475,73 @@ export function Control({ )} - - - {(menuTitle || - menuHeaderTrailingItems || - (clearable && showClearButton)) && ( - - {menuTitle} - - {loading && } - {typeof menuHeaderTrailingItems === 'function' - ? menuHeaderTrailingItems({closeOverlay: overlayState.close}) - : menuHeaderTrailingItems} - {clearable && showClearButton && ( - - {t('Clear')} - - )} - - - )} - {searchable && ( - updateSearch(e.target.value)} - size="xs" - {...searchKeyboardProps} - /> - )} - {typeof menuBody === 'function' - ? menuBody({closeOverlay: overlayState.close}) - : menuBody} - {!hideOptions && {children}} - {menuFooter && ( - - {typeof menuFooter === 'function' - ? menuFooter({ - closeOverlay: overlayState.close, - resetSearch: () => updateSearch(''), - }) - : menuFooter} - - )} - - + {overlayIsOpen && ( + + + {(menuTitle || + menuHeaderTrailingItems || + (clearable && hasSelection)) && ( + + {menuTitle} + + {loading && } + {typeof menuHeaderTrailingItems === 'function' + ? menuHeaderTrailingItems({closeOverlay: overlayState.close}) + : menuHeaderTrailingItems} + {clearable && hasSelection && ( + onClear?.({overlayState})} + size="zero" + borderless + > + {t('Clear')} + + )} + + + )} + {searchable && ( + updateSearch(e.target.value)} + size="xs" + {...searchKeyboardProps} + /> + )} + {typeof menuBody === 'function' + ? menuBody({closeOverlay: overlayState.close}) + : menuBody} + {!hideOptions && {children}} + {menuFooter && ( + + {typeof menuFooter === 'function' + ? menuFooter({ + closeOverlay: overlayState.close, + resetSearch: () => updateSearch(''), + }) + : menuFooter} + + )} + + + )} diff --git a/static/app/components/core/compactSelect/list.tsx b/static/app/components/core/compactSelect/list.tsx index 7e21328130e5d5..21d3c8ccfc9ab5 100644 --- a/static/app/components/core/compactSelect/list.tsx +++ b/static/app/components/core/compactSelect/list.tsx @@ -1,11 +1,4 @@ -import { - createContext, - Fragment, - useContext, - useId, - useLayoutEffect, - useMemo, -} from 'react'; +import {createContext, Fragment, useContext, useId, useMemo} from 'react'; import {useFocusManager} from '@react-aria/focus'; import type {AriaGridListOptions} from '@react-aria/gridlist'; import type {AriaListBoxOptions} from '@react-aria/listbox'; @@ -59,10 +52,6 @@ interface BaseListProps | 'shouldUseVirtualFocus' > { items: Array>; - /** - * This list's index number inside composite select menus. - */ - compositeIndex?: number; /** * Whether to render a grid list rather than a list box. * @@ -161,7 +150,7 @@ export interface MultipleListProps extends BaseListProp * In composite selectors, there may be multiple self-contained lists, each * representing a select "region". */ -function List({ +export function List({ items, value, onChange, @@ -171,14 +160,12 @@ function List({ isOptionDisabled, shouldFocusWrap = true, shouldFocusOnHover = true, - compositeIndex = 0, sizeLimit, sizeLimitMessage, closeOnSelect, ...props }: SingleListProps | MultipleListProps) { - const {overlayState, saveSelectedOptions, search, overlayIsOpen} = - useContext(SelectContext); + const {overlayState, search, overlayIsOpen} = useContext(SelectContext); const hiddenOptions = useMemo( () => getHiddenOptions(items, search, sizeLimit), @@ -203,8 +190,6 @@ function List({ allowDuplicateSelectionEvents: true, onSelectionChange: selection => { const selectedOptions = getSelectedOptions(items, selection); - // Save selected options in SelectContext, to update the trigger label - saveSelectedOptions(compositeIndex, selectedOptions); onChange?.(selectedOptions); if (shouldCloseOnSelect({multiple, closeOnSelect, selectedOptions})) { @@ -225,8 +210,6 @@ function List({ allowDuplicateSelectionEvents: true, onSelectionChange: selection => { const selectedOption = getSelectedOptions(items, selection)[0]!; - // Save selected options in SelectContext, to update the trigger label - saveSelectedOptions(compositeIndex, selectedOption); onChange?.(selectedOption); // Close menu if closeOnSelect is true or undefined (by default single-selection @@ -250,8 +233,6 @@ function List({ hiddenOptions, multiple, clearable, - compositeIndex, - saveSelectedOptions, closeOnSelect, overlayState, ]); @@ -262,15 +243,6 @@ function List({ items, }); - // Register the initialized list state once on mount - useLayoutEffect(() => { - saveSelectedOptions( - compositeIndex, - getSelectedOptions(items, listState.selectionManager.selectedKeys) - ); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [listState.collection]); - // In composite selects, focus should seamlessly move from one region (list) to // another when the ArrowUp/Down key is pressed const focusManager = useFocusManager(); @@ -406,5 +378,3 @@ function List({ ); } - -export {List}; diff --git a/static/app/components/workflowEngine/form/environmentSelector.spec.tsx b/static/app/components/workflowEngine/form/environmentSelector.spec.tsx index bb2be65be0e8af..0151e6de833b8e 100644 --- a/static/app/components/workflowEngine/form/environmentSelector.spec.tsx +++ b/static/app/components/workflowEngine/form/environmentSelector.spec.tsx @@ -1,3 +1,5 @@ +import {useState} from 'react'; + import {initializeOrg} from 'sentry-test/initializeOrg'; import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary'; @@ -16,7 +18,21 @@ describe('EnvironmentSelector', () => { const mockOnChange = jest.fn(); - render(); + function Component() { + const [environment, setEnvironment] = useState(''); + + return ( + { + setEnvironment(value); + mockOnChange(value); + }} + /> + ); + } + + render(); // Open list await userEvent.click(screen.getByRole('button', {name: 'All Environments'})); diff --git a/static/app/views/dashboards/detail.spec.tsx b/static/app/views/dashboards/detail.spec.tsx index a8da89b4830899..552ea5c708e5a8 100644 --- a/static/app/views/dashboards/detail.spec.tsx +++ b/static/app/views/dashboards/detail.spec.tsx @@ -1809,7 +1809,7 @@ describe('Dashboards > Detail', () => { ); await userEvent.click(await screen.findByText('All Releases')); - await userEvent.type(screen.getAllByPlaceholderText('Search\u2026')[2]!, 's'); + await userEvent.type(screen.getByPlaceholderText('Search\u2026'), 's'); await userEvent.click(await screen.findByRole('option', {name: 'search-result'})); // Validate that after search is cleared, search result still appears diff --git a/static/app/views/dashboards/manage/dashboardTable.spec.tsx b/static/app/views/dashboards/manage/dashboardTable.spec.tsx index 37cacddd04431a..0865b2092c30be 100644 --- a/static/app/views/dashboards/manage/dashboardTable.spec.tsx +++ b/static/app/views/dashboards/manage/dashboardTable.spec.tsx @@ -294,7 +294,7 @@ describe('Dashboards - DashboardTable', () => { expect(await screen.findAllByTestId('grid-head-cell')).toHaveLength(5); expect(screen.getByText('Access')).toBeInTheDocument(); - await userEvent.click((await screen.findAllByTestId('edit-access-dropdown'))[0]!); + await userEvent.click(screen.getByText('All')); expect(screen.getAllByPlaceholderText('Search Teams')[0]).toBeInTheDocument(); }); diff --git a/static/app/views/explore/logs/content.spec.tsx b/static/app/views/explore/logs/content.spec.tsx index 2a8c99358996e0..718eaa85ff6693 100644 --- a/static/app/views/explore/logs/content.spec.tsx +++ b/static/app/views/explore/logs/content.spec.tsx @@ -2,7 +2,13 @@ import {createLogFixtures, initializeLogsTest} from 'sentry-fixture/log'; import {ProjectKeysFixture} from 'sentry-fixture/projectKeys'; import {TeamFixture} from 'sentry-fixture/team'; -import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary'; +import { + render, + screen, + userEvent, + waitFor, + within, +} from 'sentry-test/reactTestingLibrary'; import * as useRecentCreatedProjectHook from 'sentry/components/onboarding/useRecentCreatedProject'; import ProjectsStore from 'sentry/stores/projectsStore'; @@ -179,7 +185,9 @@ describe('LogsPage', () => { eventStatsMock.mockClear(); await userEvent.click(screen.getByRole('button', {name: 'Expand sidebar'})); - await userEvent.click(screen.getByRole('button', {name: '\u2014'})); + + const editorColumn = screen.getAllByTestId('editor-column')[0]!; + await userEvent.click(within(editorColumn).getByRole('button', {name: '\u2014'})); await userEvent.click(screen.getByRole('option', {name: 'severity'})); await userEvent.click(screen.getByRole('tab', {name: 'Aggregates'})); diff --git a/static/app/views/explore/logs/logsToolbar.spec.tsx b/static/app/views/explore/logs/logsToolbar.spec.tsx index 40a68283710377..e06d7b9b69fe05 100644 --- a/static/app/views/explore/logs/logsToolbar.spec.tsx +++ b/static/app/views/explore/logs/logsToolbar.spec.tsx @@ -1,6 +1,6 @@ import type {ReactNode} from 'react'; -import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; +import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary'; import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent'; import {LogsQueryParamsProvider} from 'sentry/views/explore/logs/logsQueryParamsProvider'; @@ -200,7 +200,8 @@ describe('LogsToolbar', () => { expect(mode).toEqual(Mode.SAMPLES); - await userEvent.click(screen.getByRole('button', {name: '\u2014'})); + const editorColumn = screen.getAllByTestId('editor-column')[0]!; + await userEvent.click(within(editorColumn).getByRole('button', {name: '\u2014'})); await userEvent.click(screen.getByRole('option', {name: 'message'})); expect(router.location.query.aggregateField).toEqual( [{groupBy: 'message'}, {yAxes: ['count(message)']}].map(aggregateField => @@ -210,7 +211,7 @@ describe('LogsToolbar', () => { expect(mode).toEqual(Mode.AGGREGATE); - await userEvent.click(screen.getByRole('button', {name: 'message'})); + await userEvent.click(within(editorColumn).getByRole('button', {name: 'message'})); await userEvent.click(screen.getByRole('option', {name: 'severity'})); expect(router.location.query.aggregateField).toEqual( [{groupBy: 'severity'}, {yAxes: ['count(message)']}].map(aggregateField => @@ -233,7 +234,8 @@ describe('LogsToolbar', () => { ); - await userEvent.click(screen.getByRole('button', {name: '\u2014'})); + const editorColumn = screen.getAllByTestId('editor-column')[0]!; + await userEvent.click(within(editorColumn).getByRole('button', {name: '\u2014'})); await userEvent.click(screen.getByRole('option', {name: 'message'})); await userEvent.click(screen.getByRole('button', {name: 'Add Group'})); diff --git a/static/app/views/explore/spans/spansTab.spec.tsx b/static/app/views/explore/spans/spansTab.spec.tsx index d743cad308eca4..a57216993a49c7 100644 --- a/static/app/views/explore/spans/spansTab.spec.tsx +++ b/static/app/views/explore/spans/spansTab.spec.tsx @@ -191,7 +191,10 @@ describe('SpansTabContent', () => { // Add a group by, and leave one unselected await userEvent.click(aggregates); - await userEvent.click(within(groupBy).getByRole('button', {name: '\u2014'})); + + const editorColumn = screen.getAllByTestId('editor-column')[0]!; + + await userEvent.click(within(editorColumn).getByRole('button', {name: '\u2014'})); await userEvent.click(within(groupBy).getByRole('option', {name: 'project'})); expect(groupBys).toEqual(['project']); diff --git a/static/app/views/explore/tables/aggregateColumnEditorModal.spec.tsx b/static/app/views/explore/tables/aggregateColumnEditorModal.spec.tsx index 3cf05bf6106d7a..741b45328c49ed 100644 --- a/static/app/views/explore/tables/aggregateColumnEditorModal.spec.tsx +++ b/static/app/views/explore/tables/aggregateColumnEditorModal.spec.tsx @@ -263,7 +263,12 @@ describe('AggregateColumnEditorModal', () => { 'span.op', 'span.self_time', ]; - await userEvent.click(screen.getByRole('button', {name: 'Group By geo.country'})); + + const row = screen.getAllByTestId('editor-row')[0]!; + + await userEvent.click( + within(row).getByRole('button', {name: 'Group By geo.country'}) + ); const groupByOptions = await screen.findAllByRole('option'); groupByOptions.forEach((option, i) => { expect(option).toHaveTextContent(options[i]!); diff --git a/static/app/views/explore/tables/columnEditorModal.spec.tsx b/static/app/views/explore/tables/columnEditorModal.spec.tsx index 4428cd690f3f57..0ca360cc133797 100644 --- a/static/app/views/explore/tables/columnEditorModal.spec.tsx +++ b/static/app/views/explore/tables/columnEditorModal.spec.tsx @@ -1,4 +1,10 @@ -import {act, renderGlobalModal, screen, userEvent} from 'sentry-test/reactTestingLibrary'; +import { + act, + renderGlobalModal, + screen, + userEvent, + within, +} from 'sentry-test/reactTestingLibrary'; import {openModal} from 'sentry/actionCreators/modal'; import type {TagCollection} from 'sentry/types/group'; @@ -134,7 +140,12 @@ describe('ColumnEditorModal', () => { ['span.duration', 'number'], ['span.op', 'string'], ]; - await userEvent.click(screen.getByRole('button', {name: 'Column \u2014'})); + + const projectColumn = screen.getAllByTestId('editor-column')[2]!; + + await userEvent.click( + within(projectColumn).getByRole('button', {name: 'Column \u2014'}) + ); const columnOptions = await screen.findAllByRole('option'); columnOptions.forEach((option, i) => { expect(option).toHaveTextContent(options[i]![0]); @@ -182,7 +193,12 @@ describe('ColumnEditorModal', () => { ['span.duration', 'number'], ['span.op', 'string'], ]; - await userEvent.click(screen.getByRole('button', {name: 'Column project string'})); + + const projectColumn = screen.getAllByTestId('editor-column')[1]!; + + await userEvent.click( + within(projectColumn).getByRole('button', {name: 'Column project string'}) + ); const columnOptions = await screen.findAllByRole('option'); columnOptions.forEach((option, i) => { expect(option).toHaveTextContent(options[i]![0]); diff --git a/static/app/views/explore/toolbar/index.spec.tsx b/static/app/views/explore/toolbar/index.spec.tsx index 0a7b5d787dc8fc..b7f3ec3bbc4fc1 100644 --- a/static/app/views/explore/toolbar/index.spec.tsx +++ b/static/app/views/explore/toolbar/index.spec.tsx @@ -304,16 +304,17 @@ describe('ExploreToolbar', () => { let options: HTMLElement[]; const section = screen.getByTestId('section-group-by'); + const spanOpColumn = screen.getAllByTestId('editor-column')[0]!; expect(groupBys).toEqual(['']); - await userEvent.click(within(section).getByRole('button', {name: '\u2014'})); + await userEvent.click(within(spanOpColumn).getByRole('button', {name: '\u2014'})); options = await within(section).findAllByRole('option'); expect(options.length).toBeGreaterThan(0); await userEvent.click(within(section).getByRole('option', {name: 'span.op'})); expect(groupBys).toEqual(['span.op']); - await userEvent.click(within(section).getByRole('button', {name: 'span.op'})); + await userEvent.click(within(spanOpColumn).getByRole('button', {name: 'span.op'})); options = await within(section).findAllByRole('option'); expect(options.length).toBeGreaterThan(0); await userEvent.click(within(section).getByRole('option', {name: 'project'})); @@ -322,7 +323,12 @@ describe('ExploreToolbar', () => { await userEvent.click(within(section).getByRole('button', {name: 'Add Group'})); expect(groupBys).toEqual(['project', '']); - await userEvent.click(within(section).getByRole('button', {name: '\u2014'})); + const projectColumn = screen.getAllByTestId('editor-column')[1]!; + await userEvent.click( + within(projectColumn).getByRole('button', { + name: '\u2014', + }) + ); options = await within(section).findAllByRole('option'); expect(options.length).toBeGreaterThan(0); await userEvent.click( @@ -356,8 +362,9 @@ describe('ExploreToolbar', () => { expect(groupBys).toEqual(['']); const section = screen.getByTestId('section-group-by'); + const editorColumn = screen.getAllByTestId('editor-column')[0]!; - await userEvent.click(within(section).getByRole('button', {name: '\u2014'})); + await userEvent.click(within(editorColumn).getByRole('button', {name: '\u2014'})); await userEvent.click(within(section).getByRole('option', {name: 'span.op'})); expect(mode).toEqual(Mode.AGGREGATE); 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 b3692e99304b6e..47c8b1dd1de4e2 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,13 +1,7 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; import {PageFilterStateFixture} from 'sentry-fixture/pageFilters'; -import { - render, - screen, - userEvent, - waitFor, - waitForElementToBeRemoved, -} from 'sentry-test/reactTestingLibrary'; +import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary'; import selectEvent from 'sentry-test/selectEvent'; import usePageFilters from 'sentry/utils/usePageFilters'; @@ -55,8 +49,6 @@ describe('DomainSelector', () => { it('allows selecting a domain', async () => { render(); - await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); - await selectEvent.openMenu(screen.getByText('All')); expect(screen.getByText('sentry_user')).toBeInTheDocument(); @@ -85,8 +77,6 @@ describe('DomainSelector', () => { render(); expect(fetchMoreResponse).not.toHaveBeenCalled(); - await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator')); - await selectEvent.openMenu(screen.getByText('All')); await userEvent.type(screen.getByRole('textbox'), 'p'); diff --git a/static/app/views/insights/database/components/databaseSystemSelector.spec.tsx b/static/app/views/insights/database/components/databaseSystemSelector.spec.tsx index c94d0896dfad36..64acea1f0be98a 100644 --- a/static/app/views/insights/database/components/databaseSystemSelector.spec.tsx +++ b/static/app/views/insights/database/components/databaseSystemSelector.spec.tsx @@ -219,7 +219,6 @@ describe('DatabaseSystemSelector', () => { expect(dropdownOptionLabels[1]).toHaveTextContent('MongoDB'); await userEvent.click(dropdownOptionLabels[0]!); - expect(dropdownSelector).toHaveTextContent('SystemPostgreSQL'); expect(mockSetState).toHaveBeenCalledWith('postgresql'); expect(mockNavigate).toHaveBeenCalledWith({ action: 'POP', diff --git a/static/app/views/settings/organizationAuditLog/auditLogView.spec.tsx b/static/app/views/settings/organizationAuditLog/auditLogView.spec.tsx index 957e6e23372a7d..0849ce0f14a413 100644 --- a/static/app/views/settings/organizationAuditLog/auditLogView.spec.tsx +++ b/static/app/views/settings/organizationAuditLog/auditLogView.spec.tsx @@ -30,8 +30,9 @@ describe('OrganizationAuditLog', () => { render(); expect(await screen.findByRole('heading')).toHaveTextContent('Audit Log'); - // Check that both textboxes are present (date selector search and event selector) - expect(screen.getAllByRole('textbox')).toHaveLength(2); + // Check that both date selector search and event selector are present + expect(screen.getByText('All time')).toBeInTheDocument(); + expect(screen.getByText('Select Action:')).toBeInTheDocument(); expect(screen.getByText('Member')).toBeInTheDocument(); expect(screen.getByText('Action')).toBeInTheDocument(); expect(screen.getByText('IP')).toBeInTheDocument(); diff --git a/static/app/views/settings/project/projectTeams.spec.tsx b/static/app/views/settings/project/projectTeams.spec.tsx index b4f429e887756f..99add240f33830 100644 --- a/static/app/views/settings/project/projectTeams.spec.tsx +++ b/static/app/views/settings/project/projectTeams.spec.tsx @@ -294,7 +294,7 @@ describe('ProjectTeams', () => { expect(await screen.findByText('Project Teams for project-slug')).toBeInTheDocument(); // Add new team - await userEvent.click(screen.getAllByRole('button', {name: 'Add Team'})[1]!); + await userEvent.click(screen.getByRole('button', {name: 'Add Team'})); await userEvent.click(screen.getByRole('button', {name: 'Create Team'}));