Browse Source

ref(tests): Refactor `ref-` class name from `Toasts` (#14568)

Use `data-test-id` attribute instead.
Billy Vong 5 years ago
parent
commit
56c5f4dd59

+ 4 - 0
src/sentry/static/sentry/app/components/alerts/toastIndicator.jsx

@@ -92,9 +92,13 @@ function ToastIndicator({indicator, onDismiss, className, ...props}) {
   } else if (type === 'error') {
     icon = <InlineSvg src="icon-circle-close" size="24px" />;
   }
+
+  // TODO(billy): Remove ref- className after removing usage from getsentry
+
   return (
     <Toast
       onClick={handleClick}
+      data-test-id={type ? `toast-${type}` : 'toast'}
       className={cx(className, 'ref-toast', `ref-${type}`)}
       {...props}
     >

+ 2 - 3
src/sentry/static/sentry/app/components/indicators.jsx

@@ -1,6 +1,5 @@
 import {PoseGroup} from 'react-pose';
 import {ThemeProvider} from 'emotion-theming';
-import {cx} from 'emotion';
 import PropTypes from 'prop-types';
 import React from 'react';
 import Reflux from 'reflux';
@@ -40,10 +39,10 @@ class Indicators extends React.Component {
   };
 
   render() {
-    const {items, className, ...props} = this.props;
+    const {items, ...props} = this.props;
 
     return (
-      <Toasts {...props} className={cx(className, 'ref-toasts')}>
+      <Toasts {...props}>
         {items.map((indicator, i) => {
           // We purposefully use `i` as key here because of transitions
           // Toasts can now queue up, so when we change from [firstToast] -> [secondToast],

+ 3 - 3
tests/acceptance/test_api.py

@@ -42,12 +42,12 @@ class ApiApplicationTest(AcceptanceTestCase):
 
         self.browser.click('[href="/settings/account/api/applications/"]')
         self.browser.wait_until_not(".loading")
-        self.browser.click_when_visible(".ref-toast")
-        self.browser.wait_until_not(".ref-toast")
+        self.browser.click_when_visible('[data-test-id="toast-success"]')
+        self.browser.wait_until_not('[data-test-id="toast-success"]')
         self.browser.snapshot("api applications - single application")
 
         self.browser.get(self.path)
         self.browser.wait_until_not(".loading")
         self.browser.click_when_visible('[aria-label="Remove"]')
-        self.browser.wait_until_not(".ref-toast")
+        self.browser.wait_until_not('[data-test-id="toast-loading"]')
         self.browser.wait_until_test_id("empty-message")

+ 1 - 1
tests/acceptance/test_organization_settings.py

@@ -60,5 +60,5 @@ class OrganizationSettingsTest(AcceptanceTestCase):
         self.browser.wait_until(".modal")
         self.browser.click('.modal [data-test-id="confirm-modal"]')
         self.browser.wait_until_not(".modal")
-        self.browser.wait_until(".ref-toast.ref-error")
+        self.browser.wait_until_test_id("toast-error")
         self.load_organization_helper("setting 2fa without 2fa enabled")