view.spec.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/dashboards/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.addMockResponse({
  28. url: `/organizations/${initialData.organization.slug}/dashboards/1/visit/`,
  29. statusCode: 200,
  30. method: 'POST',
  31. });
  32. render(
  33. <ViewEditDashboard
  34. location={TestStubs.location(location)}
  35. organization={initialData.organization}
  36. router={initialData.router}
  37. params={{
  38. orgId: initialData.organization.slug,
  39. dashboardId: '1',
  40. }}
  41. route={{}}
  42. routes={[]}
  43. routeParams={{}}
  44. >
  45. {() => undefined}
  46. </ViewEditDashboard>
  47. );
  48. expect(browserHistory.replace).toHaveBeenCalledWith(
  49. expect.objectContaining({
  50. pathname: '/',
  51. query: {
  52. end: null,
  53. environment: 'canary',
  54. period: '7d',
  55. project: '11111',
  56. start: null,
  57. statsPeriod: '7d',
  58. utc: null,
  59. },
  60. })
  61. );
  62. });
  63. });