index.spec.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. MockApiClient.addMockResponse({
  34. url: `/organizations/${organization.slug}/builtin-symbol-sources/`,
  35. method: 'GET',
  36. body: [],
  37. });
  38. });
  39. it('renders', async function () {
  40. render(<ProjectDebugFiles {...props} />);
  41. expect(screen.getByText('Debug Information Files')).toBeInTheDocument();
  42. // Uploaded debug files content
  43. expect(
  44. await screen.findByText('Uploaded debug information files')
  45. ).toBeInTheDocument();
  46. expect(screen.getByText('libS.so')).toBeInTheDocument();
  47. });
  48. it('renders empty', async function () {
  49. MockApiClient.addMockResponse({
  50. url: endpoint,
  51. body: [],
  52. });
  53. render(<ProjectDebugFiles {...props} />);
  54. // Uploaded debug files content
  55. expect(
  56. await screen.findByText('There are no debug symbols for this project.')
  57. ).toBeInTheDocument();
  58. });
  59. it('deletes the file', async function () {
  60. const deleteMock = MockApiClient.addMockResponse({
  61. method: 'DELETE',
  62. url: `/projects/${organization.slug}/${project.slug}/files/dsyms/?id=${
  63. DebugFileFixture().id
  64. }`,
  65. });
  66. render(<ProjectDebugFiles {...props} />);
  67. renderGlobalModal();
  68. // Delete button
  69. await userEvent.click(await screen.findByTestId('delete-dif'));
  70. // Confirm Modal
  71. await screen.findByRole('dialog');
  72. await userEvent.click(screen.getByTestId('confirm-button'));
  73. expect(deleteMock).toHaveBeenCalled();
  74. });
  75. it('display error if request for dsyms fails', async function () {
  76. MockApiClient.addMockResponse({
  77. url: endpoint,
  78. body: [DebugFileFixture()],
  79. statusCode: 400,
  80. });
  81. render(<ProjectDebugFiles {...props} />);
  82. expect(await screen.findByText(/There was an error/)).toBeInTheDocument();
  83. expect(screen.getByRole('button', {name: 'Retry'})).toBeInTheDocument();
  84. });
  85. it('display error if request for symbol sources fails', async function () {
  86. MockApiClient.addMockResponse({
  87. url: `/organizations/${organization.slug}/builtin-symbol-sources/`,
  88. method: 'GET',
  89. body: [],
  90. statusCode: 400,
  91. });
  92. render(
  93. <ProjectDebugFiles
  94. {...props}
  95. organization={{...organization, features: ['symbol-sources']}}
  96. />
  97. );
  98. expect(await screen.findByText(/There was an error/)).toBeInTheDocument();
  99. expect(screen.getByRole('button', {name: 'Retry'})).toBeInTheDocument();
  100. });
  101. });