create.spec.tsx 3.0 KB

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