create.spec.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {DashboardFixture} from 'sentry-fixture/dashboard';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {initializeOrg} from 'sentry-test/initializeOrg';
  5. import {
  6. render,
  7. renderGlobalModal,
  8. screen,
  9. userEvent,
  10. } from 'sentry-test/reactTestingLibrary';
  11. import ProjectsStore from 'sentry/stores/projectsStore';
  12. import CreateDashboard from 'sentry/views/dashboards/create';
  13. describe('Dashboards > Create', function () {
  14. const organization = OrganizationFixture({
  15. features: ['dashboards-basic', 'dashboards-edit', 'discover-query'],
  16. });
  17. describe('new dashboards', function () {
  18. let initialData;
  19. const projects = [ProjectFixture()];
  20. beforeEach(function () {
  21. ProjectsStore.init();
  22. ProjectsStore.loadInitialData(projects);
  23. initialData = initializeOrg({
  24. organization,
  25. project: undefined,
  26. projects: [],
  27. router: {},
  28. });
  29. MockApiClient.addMockResponse({
  30. url: '/organizations/org-slug/tags/',
  31. body: [],
  32. });
  33. MockApiClient.addMockResponse({
  34. url: '/organizations/org-slug/projects/',
  35. body: [ProjectFixture()],
  36. });
  37. MockApiClient.addMockResponse({
  38. url: '/organizations/org-slug/dashboards/',
  39. body: [DashboardFixture([], {id: 'default-overview', title: 'Default'})],
  40. });
  41. MockApiClient.addMockResponse({
  42. url: '/organizations/org-slug/events-stats/',
  43. body: {data: []},
  44. });
  45. MockApiClient.addMockResponse({
  46. url: '/organizations/org-slug/dashboards/widgets/',
  47. method: 'POST',
  48. body: [],
  49. });
  50. MockApiClient.addMockResponse({
  51. url: '/organizations/org-slug/users/',
  52. method: 'GET',
  53. body: [],
  54. });
  55. MockApiClient.addMockResponse({
  56. url: '/organizations/org-slug/eventsv2/',
  57. body: {data: []},
  58. });
  59. });
  60. afterEach(function () {
  61. MockApiClient.clearMockResponses();
  62. });
  63. // eslint-disable-next-line
  64. it.skip('can create with new widget', async function () {
  65. MockApiClient.addMockResponse({
  66. url: '/organizations/org-slug/dashboards/',
  67. method: 'POST',
  68. body: DashboardFixture([], {id: '1', title: 'Custom Errors'}),
  69. });
  70. render(
  71. <CreateDashboard
  72. organization={initialData.organization}
  73. params={{orgId: 'org-slug'}}
  74. router={initialData.router}
  75. location={initialData.router.location}
  76. {...initialData.router}
  77. />,
  78. {context: initialData.routerContext}
  79. );
  80. renderGlobalModal({context: initialData.routerContext});
  81. await userEvent.click(await screen.findByTestId('widget-add'));
  82. // Add a custom widget to the dashboard
  83. await userEvent.click(await screen.findByText('Custom Widget'));
  84. await userEvent.click(screen.getByTestId('widget-title-input'));
  85. await userEvent.paste('Widget Title');
  86. await userEvent.click(screen.getByText('Save'));
  87. // Committing dashboard should complete without throwing error
  88. await userEvent.click(screen.getByText('Save and Finish'));
  89. });
  90. });
  91. });