index.spec.tsx 2.0 KB

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