index.spec.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {DebugFileFixture} from 'sentry-fixture/debugFile';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {
  4. render,
  5. renderGlobalModal,
  6. screen,
  7. userEvent,
  8. } from 'sentry-test/reactTestingLibrary';
  9. import ProjectDebugFiles from 'sentry/views/settings/projectDebugFiles';
  10. describe('ProjectDebugFiles', function () {
  11. const {organization, project, router} = initializeOrg();
  12. const props = {
  13. organization,
  14. project,
  15. params: {projectId: project.slug},
  16. location: {
  17. ...router.location,
  18. query: {
  19. query: '',
  20. },
  21. },
  22. route: {},
  23. router,
  24. routes: [],
  25. routeParams: {},
  26. };
  27. const endpoint = `/projects/${organization.slug}/${project.slug}/files/dsyms/`;
  28. beforeEach(function () {
  29. MockApiClient.addMockResponse({
  30. url: endpoint,
  31. body: [DebugFileFixture()],
  32. });
  33. });
  34. it('renders', function () {
  35. render(<ProjectDebugFiles {...props} />);
  36. expect(screen.getByText('Debug Information Files')).toBeInTheDocument();
  37. // Uploaded debug files content
  38. expect(screen.getByText('Uploaded debug information files')).toBeInTheDocument();
  39. expect(screen.getByText('libS.so')).toBeInTheDocument();
  40. });
  41. it('renders empty', function () {
  42. MockApiClient.addMockResponse({
  43. url: endpoint,
  44. body: [],
  45. });
  46. render(<ProjectDebugFiles {...props} />);
  47. // Uploaded debug files content
  48. expect(
  49. screen.getByText('There are no debug symbols for this project.')
  50. ).toBeInTheDocument();
  51. });
  52. it('deletes the file', async function () {
  53. const deleteMock = MockApiClient.addMockResponse({
  54. method: 'DELETE',
  55. url: `/projects/${organization.slug}/${project.slug}/files/dsyms/?id=${
  56. DebugFileFixture().id
  57. }`,
  58. });
  59. render(<ProjectDebugFiles {...props} />);
  60. renderGlobalModal();
  61. // Delete button
  62. await userEvent.click(screen.getByTestId('delete-dif'));
  63. // Confirm Modal
  64. await screen.findByRole('dialog');
  65. await userEvent.click(screen.getByTestId('confirm-button'));
  66. expect(deleteMock).toHaveBeenCalled();
  67. });
  68. });