view.spec.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {browserHistory} from 'react-router';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render} from 'sentry-test/reactTestingLibrary';
  4. import ViewEditDashboard from 'sentry/views/dashboardsV2/view';
  5. describe('Dashboards > ViewEditDashboard', function () {
  6. const initialData = initializeOrg();
  7. it('removes widget params from url and preserves selection params', function () {
  8. const location = {
  9. pathname: '/',
  10. query: {
  11. environment: 'canary',
  12. period: '7d',
  13. project: '11111',
  14. start: null,
  15. end: null,
  16. utc: null,
  17. displayType: 'line',
  18. interval: '5m',
  19. queryConditions: '',
  20. queryFields: 'count()',
  21. queryNames: '',
  22. queryOrderby: '',
  23. title: 'test',
  24. },
  25. };
  26. render(
  27. <ViewEditDashboard
  28. location={TestStubs.location(location)}
  29. organization={initialData.organization}
  30. router={initialData.router}
  31. params={{
  32. orgId: initialData.organization.slug,
  33. dashboardId: '1',
  34. }}
  35. route={{}}
  36. routes={[]}
  37. routeParams={{}}
  38. >
  39. {() => undefined}
  40. </ViewEditDashboard>
  41. );
  42. expect(browserHistory.replace).toHaveBeenCalledWith(
  43. expect.objectContaining({
  44. pathname: '/',
  45. query: {
  46. end: null,
  47. environment: 'canary',
  48. period: '7d',
  49. project: '11111',
  50. start: null,
  51. utc: null,
  52. },
  53. })
  54. );
  55. });
  56. });