index.spec.tsx 2.0 KB

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