Browse Source

test: Fix testing-library/prefer-presence-queries violations (#82772)

Ryan Albrecht 2 months ago
parent
commit
4fbe8e1b5f

+ 0 - 1
eslint.config.mjs

@@ -963,7 +963,6 @@ export default typescript.config([
       'testing-library/no-container': 'warn', // TODO(ryan953): Fix the violations, then delete this line
       'testing-library/no-node-access': 'warn', // TODO(ryan953): Fix the violations, then delete this line
       'testing-library/no-render-in-lifecycle': 'warn', // TODO(ryan953): Fix the violations, then delete this line
-      'testing-library/prefer-presence-queries': 'warn', // TODO(ryan953): Fix the violations, then delete this line
       'testing-library/prefer-query-by-disappearance': 'warn', // TODO(ryan953): Fix the violations, then delete this line
       'testing-library/prefer-screen-queries': 'warn', // TODO(ryan953): Fix the violations, then delete this line
     },

+ 2 - 2
static/app/components/actions/archive.spec.tsx

@@ -82,10 +82,10 @@ describe('ArchiveActions', () => {
     render(<ArchiveActions onUpdate={onUpdate} disableArchiveUntilOccurrence={false} />);
     await userEvent.click(screen.getByRole('button', {name: 'Archive options'}));
     expect(
-      screen.queryByRole('menuitemradio', {name: 'Until this occurs again\u2026'})
+      screen.getByRole('menuitemradio', {name: 'Until this occurs again\u2026'})
     ).toBeInTheDocument();
     expect(
-      screen.queryByRole('menuitemradio', {
+      screen.getByRole('menuitemradio', {
         name: 'Until this affects an additional\u2026',
       })
     ).toBeInTheDocument();

+ 1 - 1
static/app/components/deprecatedDropdownMenu.spec.tsx

@@ -113,7 +113,7 @@ describe('dropdownMenuDeprecated', function () {
     await userEvent.click(screen.getByTestId('menu'));
     expect(menuClick).toHaveBeenCalled();
 
-    expect(screen.queryByRole('listbox')).toBeInTheDocument();
+    expect(screen.getByRole('listbox')).toBeInTheDocument();
   });
 
   it('always rendered menus should attach document event listeners only when opened', async function () {

+ 1 - 1
static/app/components/deprecatedSmartSearchBar/index.spec.tsx

@@ -420,7 +420,7 @@ describe('SmartSearchBar', function () {
     await userEvent.keyboard('{ArrowRight}');
     // Should show "Tags" and "Operator Helpers" but NOT "Values"
     expect(await screen.findByText('Keys')).toBeInTheDocument();
-    expect(screen.queryByText('Operator Helpers')).toBeInTheDocument();
+    expect(screen.getByText('Operator Helpers')).toBeInTheDocument();
     expect(screen.queryByText('Values')).not.toBeInTheDocument();
 
     // Set cursor after the ":"

+ 1 - 1
static/app/components/discover/quickContextCommitRow.spec.tsx

@@ -76,7 +76,7 @@ describe('Quick Context Commit Row', () => {
     const pullRequestLink = screen.getByText(
       /feat\(quick-context-commit-row\): Added new component/
     );
-    expect(screen.queryByTestId('quick-context-commit-row-pr-link')).toBeInTheDocument();
+    expect(screen.getByTestId('quick-context-commit-row-pr-link')).toBeInTheDocument();
     expect(pullRequestLink).toBeInTheDocument();
     expect(pullRequestLink).toHaveAttribute(
       'href',

+ 1 - 1
static/app/components/events/autofix/autofixRootCause.spec.tsx

@@ -66,7 +66,7 @@ describe('AutofixRootCause', function () {
       />
     );
 
-    expect(screen.queryByRole('link', {name: 'GitHub'})).toBeInTheDocument();
+    expect(screen.getByRole('link', {name: 'GitHub'})).toBeInTheDocument();
     expect(screen.queryByRole('link', {name: 'GitHub'})).toHaveAttribute(
       'href',
       'https://github.com/test_owner/test_repo/blob/main/src/file.py'

+ 1 - 1
static/app/components/events/featureFlags/eventFeatureFlagList.spec.tsx

@@ -223,7 +223,7 @@ describe('EventFeatureFlagList', function () {
     expect(search).not.toBeInTheDocument();
     expect(screen.getByRole('button', {name: 'Set Up Integration'})).toBeInTheDocument();
     expect(
-      screen.queryByText('No feature flags were found for this event')
+      screen.getByText('No feature flags were found for this event')
     ).toBeInTheDocument();
   });
 

+ 1 - 1
static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.spec.tsx

@@ -457,7 +457,7 @@ describe('SpanEvidenceKeyValueList', () => {
         screen.getByTestId(/span-evidence-key-value-list.repeating-spans/)
       ).toHaveTextContent('/book/[Parameters]');
 
-      expect(screen.queryByRole('cell', {name: 'Parameters'})).toBeInTheDocument();
+      expect(screen.getByRole('cell', {name: 'Parameters'})).toBeInTheDocument();
 
       const parametersKeyValue = screen.getByTestId(
         'span-evidence-key-value-list.parameters'

+ 3 - 3
static/app/components/events/interfaces/threads.spec.tsx

@@ -915,9 +915,9 @@ describe('Threads', function () {
         expect(screen.getByRole('radio', {name: 'Full Stack Trace'})).not.toBeChecked();
         expect(screen.getByRole('button', {name: 'Options'})).toBeInTheDocument();
 
-        expect(screen.queryByText('Threads')).toBeInTheDocument();
-        expect(screen.queryByText('Thread State')).toBeInTheDocument();
-        expect(screen.queryByText('Thread Tags')).toBeInTheDocument();
+        expect(screen.getByText('Threads')).toBeInTheDocument();
+        expect(screen.getByText('Thread State')).toBeInTheDocument();
+        expect(screen.getByText('Thread Tags')).toBeInTheDocument();
 
         // Stack Trace
         expect(screen.getByRole('heading', {name: 'EXC_BAD_ACCESS'})).toBeInTheDocument();

+ 2 - 2
static/app/components/events/viewHierarchy/index.spec.tsx

@@ -78,7 +78,7 @@ describe('View Hierarchy', function () {
   it('can expand and collapse by clicking the icon', async function () {
     render(<ViewHierarchy viewHierarchy={MOCK_DATA} project={project} />);
 
-    expect(screen.queryByText('Text')).toBeInTheDocument();
+    expect(screen.getByText('Text')).toBeInTheDocument();
 
     await userEvent.click(
       within(screen.getByLabelText('Nested Container - nested')).getByRole('button', {
@@ -90,7 +90,7 @@ describe('View Hierarchy', function () {
 
     await userEvent.click(screen.getByRole('button', {name: 'Expand'}));
 
-    expect(screen.queryByText('Text')).toBeInTheDocument();
+    expect(screen.getByText('Text')).toBeInTheDocument();
   });
 
   it('can navigate with keyboard shortcuts after a selection', async function () {

Some files were not shown because too many files changed in this diff