]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20649 Split frontend bulk change test in two to avoid flakyness
author7PH <benjamin.raymond@sonarsource.com>
Thu, 5 Oct 2023 15:47:22 +0000 (17:47 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 6 Oct 2023 20:02:52 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx

index 1f08341020f7c3109b0df75a23be45fb0f31443c..a85a356c4a0ff112c9467a3d54052ff74a90f13a 100644 (file)
@@ -243,8 +243,7 @@ describe('issues app', () => {
       expect(ui.issueItem8.get()).toBeInTheDocument();
     });
 
-    // Improve this to include all the bulk change fonctionality
-    it('should be able to bulk change', async () => {
+    it('should be able to select issues for bulk change', async () => {
       jest.useRealTimers();
       const user = userEvent.setup();
       const currentUser = mockLoggedInUser({
@@ -257,21 +256,38 @@ describe('issues app', () => {
       // Check that the bulk button has correct behavior
       expect(screen.getByRole('button', { name: 'bulk_change' })).toBeDisabled();
 
+      // Select all issues
       await act(async () => {
         await user.click(screen.getByRole('checkbox', { name: 'issues.select_all_issues' }));
       });
-
       expect(
         screen.getByRole('button', { name: 'issues.bulk_change_X_issues.10' }),
       ).toBeInTheDocument();
+
+      // Open bulk change modal and close it
       await user.click(screen.getByRole('button', { name: 'issues.bulk_change_X_issues.10' }));
       await user.click(screen.getByRole('button', { name: 'cancel' }));
       expect(screen.getByRole('button', { name: 'issues.bulk_change_X_issues.10' })).toHaveFocus();
-      await user.click(screen.getByRole('checkbox', { name: 'issues.select_all_issues' }));
 
-      // Check that we bulk change the selected issue
-      const issueBoxFixThat = within(screen.getByRole('region', { name: 'Fix that' }));
+      // Unselect all
+      await act(async () => {
+        await user.click(screen.getByRole('checkbox', { name: 'issues.select_all_issues' }));
+      });
+      expect(screen.getByRole('button', { name: 'bulk_change' })).toBeDisabled();
+    });
+
+    it('should be able to bulk change', async () => {
+      jest.useRealTimers();
+      const user = userEvent.setup();
+      const currentUser = mockLoggedInUser({
+        dismissedNotices: { [NoticeType.ISSUE_GUIDE]: true },
+      });
+      issuesHandler.setIsAdmin(true);
+      issuesHandler.setCurrentUser(currentUser);
+      renderIssueApp(currentUser);
 
+      // Check that we bulk change the selected issue
+      const issueBoxFixThat = within(await screen.findByRole('region', { name: 'Fix that' }));
       await user.click(
         screen.getByRole('checkbox', { name: 'issues.action_select.label.Fix that' }),
       );