view.spec.tsx 1.8 KB

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