view.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. statsPeriod: '7d',
  25. },
  26. };
  27. MockApiClient.warnOnMissingMocks();
  28. render(
  29. <ViewEditDashboard
  30. location={TestStubs.location(location)}
  31. organization={initialData.organization}
  32. router={initialData.router}
  33. params={{
  34. orgId: initialData.organization.slug,
  35. dashboardId: '1',
  36. }}
  37. route={{}}
  38. routes={[]}
  39. routeParams={{}}
  40. >
  41. {() => undefined}
  42. </ViewEditDashboard>
  43. );
  44. expect(browserHistory.replace).toHaveBeenCalledWith(
  45. expect.objectContaining({
  46. pathname: '/',
  47. query: {
  48. end: null,
  49. environment: 'canary',
  50. period: '7d',
  51. project: '11111',
  52. start: null,
  53. statsPeriod: '7d',
  54. utc: null,
  55. },
  56. })
  57. );
  58. });
  59. });