Browse Source

ref(tests): drop dead code (#32067)

* ref(tests): drop dead code

* ref(tests): more dead code
Jonas 3 years ago
parent
commit
b6feaedc1a

+ 2 - 1
static/app/components/globalSelectionLink.tsx

@@ -65,8 +65,9 @@ function GlobalSelectionLink(props: Props) {
     queryStringObject = {...queryStringObject, ...to.query};
   }
 
+  const queryString = qs.stringify(queryStringObject);
   const url =
-    (typeof to === 'string' ? to : to.pathname) + '?' + qs.stringify(queryStringObject);
+    (typeof to === 'string' ? to : to.pathname) + (queryString ? `?${queryString}` : '');
 
   return <a {...props} href={url} />;
 }

+ 4 - 10
tests/js/spec/components/acl/featureDisabled.spec.jsx

@@ -3,15 +3,12 @@ import {fireEvent, mountWithTheme, screen} from 'sentry-test/reactTestingLibrary
 import FeatureDisabled from 'sentry/components/acl/featureDisabled';
 
 describe('FeatureDisabled', function () {
-  const routerContext = TestStubs.routerContext();
-
   it('renders', function () {
     mountWithTheme(
       <FeatureDisabled
         features={['organization:my-features']}
         featureName="Some Feature"
-      />,
-      {context: routerContext}
+      />
     );
 
     expect(
@@ -27,8 +24,7 @@ describe('FeatureDisabled', function () {
         message={customMessage}
         features={['organization:my-features']}
         featureName="Some Feature"
-      />,
-      {context: routerContext}
+      />
     );
 
     expect(screen.getByText(customMessage)).toBeInTheDocument();
@@ -41,8 +37,7 @@ describe('FeatureDisabled', function () {
         alert={customAlert}
         features={['organization:my-features']}
         featureName="Some Feature"
-      />,
-      {context: routerContext}
+      />
     );
     expect(customAlert).toHaveBeenCalled();
   });
@@ -53,8 +48,7 @@ describe('FeatureDisabled', function () {
         alert
         features={['organization:my-features']}
         featureName="Some Feature"
-      />,
-      {context: routerContext}
+      />
     );
     fireEvent.click(screen.getByText('Help'));
     expect(

+ 4 - 13
tests/js/spec/components/actions/ignore.spec.jsx

@@ -4,17 +4,12 @@ import {mountGlobalModal} from 'sentry-test/modal';
 import IgnoreActions from 'sentry/components/actions/ignore';
 
 describe('IgnoreActions', function () {
-  const routerContext = TestStubs.routerContext();
-
   describe('disabled', function () {
     let component, button;
     const spy = jest.fn();
 
     beforeEach(function () {
-      component = mountWithTheme(
-        <IgnoreActions onUpdate={spy} disabled />,
-        routerContext
-      );
+      component = mountWithTheme(<IgnoreActions onUpdate={spy} disabled />);
       button = component.find('IgnoreButton');
     });
 
@@ -32,10 +27,7 @@ describe('IgnoreActions', function () {
     let component;
     const spy = jest.fn();
     beforeEach(function () {
-      component = mountWithTheme(
-        <IgnoreActions onUpdate={spy} isIgnored />,
-        routerContext
-      );
+      component = mountWithTheme(<IgnoreActions onUpdate={spy} isIgnored />);
     });
 
     it('displays ignored view', function () {
@@ -56,7 +48,7 @@ describe('IgnoreActions', function () {
     const spy = jest.fn();
 
     beforeEach(function () {
-      component = mountWithTheme(<IgnoreActions onUpdate={spy} />, routerContext);
+      component = mountWithTheme(<IgnoreActions onUpdate={spy} />);
     });
 
     it('calls spy with ignore details when clicked', function () {
@@ -73,8 +65,7 @@ describe('IgnoreActions', function () {
 
     beforeEach(function () {
       component = mountWithTheme(
-        <IgnoreActions onUpdate={spy} shouldConfirm confirmMessage="confirm me" />,
-        routerContext
+        <IgnoreActions onUpdate={spy} shouldConfirm confirmMessage="confirm me" />
       );
       button = component.find('IgnoreButton');
     });

+ 7 - 14
tests/js/spec/components/actions/resolve.spec.jsx

@@ -20,8 +20,7 @@ describe('ResolveActions', function () {
           hasRelease={false}
           orgSlug="org-1"
           projectSlug="proj-1"
-        />,
-        TestStubs.routerContext()
+        />
       );
       button = component.find('ResolveButton').first();
     });
@@ -48,8 +47,7 @@ describe('ResolveActions', function () {
           hasRelease={false}
           orgSlug="org-1"
           projectSlug="proj-1"
-        />,
-        TestStubs.routerContext()
+        />
       );
     });
 
@@ -82,8 +80,7 @@ describe('ResolveActions', function () {
           orgSlug="org-1"
           projectSlug="proj-1"
           isResolved
-        />,
-        TestStubs.routerContext()
+        />
       );
     });
 
@@ -111,8 +108,7 @@ describe('ResolveActions', function () {
           projectSlug="proj-1"
           isResolved
           isAutoResolved
-        />,
-        TestStubs.routerContext()
+        />
       );
 
       component.find('button[aria-label="Unresolve"]').simulate('click');
@@ -130,8 +126,7 @@ describe('ResolveActions', function () {
           hasRelease={false}
           orgSlug="org-1"
           projectSlug="proj-1"
-        />,
-        TestStubs.routerContext()
+        />
       );
     });
 
@@ -163,8 +158,7 @@ describe('ResolveActions', function () {
             shouldConfirm
             confirmMessage="Are you sure???"
           />
-        </Fragment>,
-        TestStubs.routerContext()
+        </Fragment>
       );
     });
 
@@ -203,8 +197,7 @@ describe('ResolveActions', function () {
           projectSlug="project-slug"
           onUpdate={onUpdate}
         />
-      </Fragment>,
-      TestStubs.routerContext()
+      </Fragment>
     );
 
     await selectDropdownMenuItem({

+ 8 - 22
tests/js/spec/components/activity/note/input.spec.jsx

@@ -4,8 +4,6 @@ import {mountWithTheme} from 'sentry-test/enzyme';
 import NoteInput from 'sentry/components/activity/note/input';
 
 describe('NoteInput', function () {
-  const routerContext = TestStubs.routerContext();
-
   describe('New item', function () {
     const props = {
       group: {project: {}, id: 'groupId'},
@@ -14,15 +12,12 @@ describe('NoteInput', function () {
     };
 
     it('renders', function () {
-      mountWithTheme(<NoteInput {...props} />, routerContext);
+      mountWithTheme(<NoteInput {...props} />);
     });
 
     it('submits when meta + enter is pressed', function () {
       const onCreate = jest.fn();
-      const wrapper = mountWithTheme(
-        <NoteInput {...props} onCreate={onCreate} />,
-        routerContext
-      );
+      const wrapper = mountWithTheme(<NoteInput {...props} onCreate={onCreate} />);
 
       const input = wrapper.find('textarea');
 
@@ -34,10 +29,7 @@ describe('NoteInput', function () {
 
     it('submits when ctrl + enter is pressed', function () {
       const onCreate = jest.fn();
-      const wrapper = mountWithTheme(
-        <NoteInput {...props} onCreate={onCreate} />,
-        routerContext
-      );
+      const wrapper = mountWithTheme(<NoteInput {...props} onCreate={onCreate} />);
 
       const input = wrapper.find('textarea');
 
@@ -49,10 +41,7 @@ describe('NoteInput', function () {
 
     it('does not submit when nothing is entered', function () {
       const onCreate = jest.fn();
-      const wrapper = mountWithTheme(
-        <NoteInput {...props} onCreate={onCreate} />,
-        routerContext
-      );
+      const wrapper = mountWithTheme(<NoteInput {...props} onCreate={onCreate} />);
 
       const input = wrapper.find('textarea');
       input.simulate('keyDown', {key: 'Enter', metaKey: true});
@@ -62,8 +51,7 @@ describe('NoteInput', function () {
     it('handles errors', function () {
       const errorJSON = {detail: {message: '', code: 401, extra: ''}};
       const wrapper = mountWithTheme(
-        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />,
-        routerContext
+        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />
       );
 
       const input = wrapper.find('textarea');
@@ -78,8 +66,7 @@ describe('NoteInput', function () {
     it('has a disabled submit button when no text is entered', function () {
       const errorJSON = {detail: {message: '', code: 401, extra: ''}};
       const wrapper = mountWithTheme(
-        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />,
-        routerContext
+        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />
       );
 
       expect(wrapper.find('button[type="submit"]').prop('disabled')).toBe(true);
@@ -88,8 +75,7 @@ describe('NoteInput', function () {
     it('enables the submit button when text is entered', function () {
       const errorJSON = {detail: {message: '', code: 401, extra: ''}};
       const wrapper = mountWithTheme(
-        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />,
-        routerContext
+        <NoteInput {...props} error={!!errorJSON} errorJSON={errorJSON} />
       );
 
       changeReactMentionsInput(wrapper, 'something');
@@ -108,7 +94,7 @@ describe('NoteInput', function () {
     };
 
     const createWrapper = props =>
-      mountWithTheme(<NoteInput {...defaultProps} {...props} />, routerContext);
+      mountWithTheme(<NoteInput {...defaultProps} {...props} />);
 
     it('edits existing message', function () {
       const onUpdate = jest.fn();

+ 1 - 2
tests/js/spec/components/activity/note/inputWithStorage.spec.jsx

@@ -14,10 +14,9 @@ describe('NoteInputWithStorage', function () {
     memberList: [],
     teams: [],
   };
-  const routerContext = TestStubs.routerContext();
 
   const createWrapper = props =>
-    mountWithTheme(<NoteInputWithStorage {...defaultProps} {...props} />, routerContext);
+    mountWithTheme(<NoteInputWithStorage {...defaultProps} {...props} />);
 
   it('loads draft item from local storage when mounting', function () {
     localStorage.getItem.mockImplementation(() => JSON.stringify({item1: 'saved item'}));

+ 4 - 12
tests/js/spec/components/assigneeSelector.spec.jsx

@@ -102,10 +102,7 @@ describe('AssigneeSelector', function () {
     MemberListStore.state = [];
     MemberListStore.loaded = false;
 
-    assigneeSelector = mountWithTheme(
-      <AssigneeSelectorComponent id={GROUP_1.id} />,
-      TestStubs.routerContext()
-    );
+    assigneeSelector = mountWithTheme(<AssigneeSelectorComponent id={GROUP_1.id} />);
 
     openMenu = () => assigneeSelector.find('DropdownButton').simulate('click');
   });
@@ -117,8 +114,7 @@ describe('AssigneeSelector', function () {
   describe('render with props', function () {
     it('renders members from the prop when present', async function () {
       assigneeSelector = mountWithTheme(
-        <AssigneeSelectorComponent id={GROUP_1.id} memberList={[USER_2, USER_3]} />,
-        TestStubs.routerContext()
+        <AssigneeSelectorComponent id={GROUP_1.id} memberList={[USER_2, USER_3]} />
       );
       MemberListStore.loadInitialData([USER_1]);
       openMenu();
@@ -326,8 +322,7 @@ describe('AssigneeSelector', function () {
     jest.spyOn(GroupStore, 'get').mockImplementation(() => GROUP_2);
     const onAssign = jest.fn();
     assigneeSelector = mountWithTheme(
-      <AssigneeSelectorComponent id={GROUP_2.id} onAssign={onAssign} />,
-      TestStubs.routerContext()
+      <AssigneeSelectorComponent id={GROUP_2.id} onAssign={onAssign} />
     );
     MemberListStore.loadInitialData([USER_1, USER_2, USER_3]);
 
@@ -367,10 +362,7 @@ describe('AssigneeSelector', function () {
 
   it('renders unassigned', async function () {
     jest.spyOn(GroupStore, 'get').mockImplementation(() => GROUP_2);
-    assigneeSelector = mountWithTheme(
-      <AssigneeSelectorComponent id={GROUP_2.id} />,
-      TestStubs.routerContext()
-    );
+    assigneeSelector = mountWithTheme(<AssigneeSelectorComponent id={GROUP_2.id} />);
     const avatarTooltip = mountWithTheme(assigneeSelector.find('Tooltip').prop('title'));
     expect(avatarTooltip.text()).toContain('Unassigned');
   });

+ 3 - 6
tests/js/spec/components/assistant/guideAnchor.spec.jsx

@@ -14,8 +14,6 @@ describe('GuideAnchor', function () {
     },
   ];
 
-  const routerContext = TestStubs.routerContext();
-
   beforeEach(function () {
     ConfigStore.config = {
       user: {
@@ -24,8 +22,8 @@ describe('GuideAnchor', function () {
       },
     };
 
-    wrapper = mountWithTheme(<GuideAnchor target="issue_title" />, routerContext);
-    wrapper2 = mountWithTheme(<GuideAnchor target="exception" />, routerContext);
+    wrapper = mountWithTheme(<GuideAnchor target="issue_title" />);
+    wrapper2 = mountWithTheme(<GuideAnchor target="exception" />);
   });
 
   afterEach(function () {
@@ -118,8 +116,7 @@ describe('GuideAnchor', function () {
     const wrapper3 = mountWithTheme(
       <GuideAnchorWrapper disabled target="exception">
         <div data-test-id="child-div" />
-      </GuideAnchorWrapper>,
-      routerContext
+      </GuideAnchorWrapper>
     );
 
     GuideActions.fetchSucceeded(serverGuide);

+ 5 - 14
tests/js/spec/components/button.spec.tsx

@@ -3,41 +3,33 @@ import {mountWithTheme, screen, userEvent} from 'sentry-test/reactTestingLibrary
 import Button from 'sentry/components/button';
 
 describe('Button', function () {
-  const routerContext = TestStubs.routerContext();
-
   it('renders', function () {
     const {container} = mountWithTheme(<Button priority="primary">Button</Button>);
     expect(container).toSnapshot();
   });
 
   it('renders react-router link', function () {
-    const {container} = mountWithTheme(<Button to="/some/route">Router Link</Button>, {
-      context: routerContext,
-    });
+    const {container} = mountWithTheme(<Button to="/some/route">Router Link</Button>);
     expect(container).toSnapshot();
   });
 
   it('renders normal link', function () {
     const {container} = mountWithTheme(
-      <Button href="/some/relative/url">Normal Link</Button>,
-      {context: routerContext}
+      <Button href="/some/relative/url">Normal Link</Button>
     );
     expect(container).toSnapshot();
   });
 
   it('renders disabled normal link', function () {
     const {container} = mountWithTheme(
-      <Button href="/some/relative/url">Normal Link</Button>,
-      {context: routerContext}
+      <Button href="/some/relative/url">Normal Link</Button>
     );
     expect(container).toSnapshot();
   });
 
   it('calls `onClick` callback', function () {
     const spy = jest.fn();
-    mountWithTheme(<Button onClick={spy}>Click me</Button>, {
-      context: routerContext,
-    });
+    mountWithTheme(<Button onClick={spy}>Click me</Button>);
     userEvent.click(screen.getByText('Click me'));
 
     expect(spy).toHaveBeenCalled();
@@ -48,8 +40,7 @@ describe('Button', function () {
     mountWithTheme(
       <Button onClick={spy} disabled>
         Click me
-      </Button>,
-      {context: routerContext}
+      </Button>
     );
     userEvent.click(screen.getByText('Click me'));
 

+ 2 - 6
tests/js/spec/components/charts/baseChartHeightResize.spec.tsx

@@ -1,4 +1,3 @@
-import {initializeOrg} from 'sentry-test/initializeOrg';
 import {mountWithTheme} from 'sentry-test/reactTestingLibrary';
 
 import BaseChart from 'sentry/components/charts/baseChart';
@@ -23,13 +22,11 @@ const TestContainer = ({children}) => (
 );
 
 describe('BaseChart', function () {
-  const {routerContext} = initializeOrg();
   it('can scale to full parent height when given autoHeightResize', async () => {
     const {container} = mountWithTheme(
       <TestContainer>
         <BaseChart autoHeightResize />
-      </TestContainer>,
-      {context: routerContext}
+      </TestContainer>
     );
 
     expect(container).toSnapshot();
@@ -39,8 +36,7 @@ describe('BaseChart', function () {
     const {container} = mountWithTheme(
       <TestContainer>
         <BaseChart />
-      </TestContainer>,
-      {context: routerContext}
+      </TestContainer>
     );
 
     expect(container).toSnapshot();

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