view.spec.tsx 1.8 KB

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