create.spec.tsx 3.0 KB

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