Browse Source

test(ui): Prevent flake in sudo modal test (#69533)

Scott Cooper 10 months ago
parent
commit
75d7f605f8
1 changed files with 9 additions and 15 deletions
  1. 9 15
      static/app/components/modals/sudoModal.spec.tsx

+ 9 - 15
static/app/components/modals/sudoModal.spec.tsx

@@ -64,18 +64,9 @@ describe('Sudo Modal', function () {
     const {routerProps} = initializeOrg({router: {params: {}}});
     setHasPasswordAuth(true);
 
-    render(
-      <App {...routerProps}>
-        <div>placeholder content</div>
-      </App>
-    );
-
     const successCb = jest.fn();
     const errorCb = jest.fn();
 
-    // No Modal
-    expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
-
     // Should return w/ `sudoRequired`
     new MockApiClient().request('/organizations/org-slug/', {
       method: 'DELETE',
@@ -83,6 +74,12 @@ describe('Sudo Modal', function () {
       error: errorCb,
     });
 
+    render(
+      <App {...routerProps}>
+        <div>placeholder content</div>
+      </App>
+    );
+
     // Should have Modal + input
     expect(await screen.findByRole('dialog')).toBeInTheDocument();
 
@@ -134,18 +131,15 @@ describe('Sudo Modal', function () {
     const {routerProps} = initializeOrg({router: {params: {}}});
     setHasPasswordAuth(false);
 
+    // Should return w/ `sudoRequired` and trigger the modal to open
+    new MockApiClient().request('/organizations/org-slug/', {method: 'DELETE'});
+
     render(
       <App {...routerProps}>
         <div>placeholder content</div>
       </App>
     );
 
-    // No Modal
-    expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
-
-    // Should return w/ `sudoRequired` and trigger the modal to open
-    new MockApiClient().request('/organizations/org-slug/', {method: 'DELETE'});
-
     // Should have Modal + input
     expect(await screen.findByRole('dialog')).toBeInTheDocument();
     expect(screen.queryByLabelText('Password')).not.toBeInTheDocument();