projectSourceMapsArtifacts.spec.tsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import {ProjectSourceMapsArtifacts} from 'sentry/views/settings/projectSourceMaps/projectSourceMapsArtifacts';
  5. function renderReleaseBundlesMockRequests({
  6. orgSlug,
  7. projectSlug,
  8. empty,
  9. }: {
  10. orgSlug: string;
  11. projectSlug: string;
  12. empty?: boolean;
  13. }) {
  14. const files = MockApiClient.addMockResponse({
  15. url: `/projects/${orgSlug}/${projectSlug}/releases/bea7335dfaebc0ca6e65a057/files/`,
  16. body: empty ? [] : [TestStubs.SourceMapArtifact()],
  17. });
  18. return {files};
  19. }
  20. function renderDebugIdBundlesMockRequests({
  21. orgSlug,
  22. projectSlug,
  23. empty,
  24. }: {
  25. orgSlug: string;
  26. projectSlug: string;
  27. empty?: boolean;
  28. }) {
  29. const artifactBundles = MockApiClient.addMockResponse({
  30. url: `/projects/${orgSlug}/${projectSlug}/artifact-bundles/7227e105-744e-4066-8c69-3e5e344723fc/files/`,
  31. body: empty ? [] : TestStubs.SourceMapsDebugIDBundlesArtifacts(),
  32. });
  33. return {artifactBundles};
  34. }
  35. describe('ProjectSourceMapsArtifacts', function () {
  36. describe('Release Bundles', function () {
  37. it('renders default state', async function () {
  38. const {organization, route, project, router, routerContext} = initializeOrg({
  39. ...initializeOrg(),
  40. router: {
  41. location: {
  42. query: {},
  43. },
  44. params: {},
  45. },
  46. });
  47. ConfigStore.config = {
  48. ...ConfigStore.config,
  49. user: {...ConfigStore.config.user, isSuperuser: true},
  50. };
  51. renderReleaseBundlesMockRequests({
  52. orgSlug: organization.slug,
  53. projectSlug: project.slug,
  54. });
  55. render(
  56. <ProjectSourceMapsArtifacts
  57. location={routerContext.context.location}
  58. project={project}
  59. route={route}
  60. routeParams={{orgId: organization.slug, projectId: project.slug}}
  61. router={router}
  62. routes={[]}
  63. params={{
  64. orgId: organization.slug,
  65. projectId: project.slug,
  66. bundleId: 'bea7335dfaebc0ca6e65a057',
  67. }}
  68. />,
  69. {context: routerContext, organization}
  70. );
  71. // Title
  72. expect(screen.getByRole('heading')).toHaveTextContent(
  73. 'Release Artifact (bea7335dfaebc0ca6e65a057)'
  74. );
  75. // Search bar
  76. expect(screen.getByPlaceholderText('Filter by Path')).toBeInTheDocument();
  77. // Path
  78. expect(
  79. await screen.findByText('https://example.com/AcceptOrganizationInvite.js')
  80. ).toBeInTheDocument();
  81. // Time
  82. expect(screen.getByText(/in 3 year/)).toBeInTheDocument();
  83. // File size
  84. expect(screen.getByText('8.1 KiB')).toBeInTheDocument();
  85. // Chip
  86. await userEvent.hover(screen.getByText('none'));
  87. expect(await screen.findByText('No distribution set')).toBeInTheDocument();
  88. // Download button
  89. expect(screen.getByRole('button', {name: 'Download Artifact'})).toHaveAttribute(
  90. 'href',
  91. '/projects/org-slug/project-slug/releases/bea7335dfaebc0ca6e65a057/files/5678/?download=1'
  92. );
  93. });
  94. it('renders empty state', async function () {
  95. const {organization, route, project, router, routerContext} = initializeOrg({
  96. ...initializeOrg(),
  97. router: {
  98. location: {
  99. query: {},
  100. },
  101. params: {},
  102. },
  103. });
  104. renderReleaseBundlesMockRequests({
  105. orgSlug: organization.slug,
  106. projectSlug: project.slug,
  107. empty: true,
  108. });
  109. render(
  110. <ProjectSourceMapsArtifacts
  111. location={routerContext.context.location}
  112. project={project}
  113. route={route}
  114. routeParams={{orgId: organization.slug, projectId: project.slug}}
  115. router={router}
  116. routes={[]}
  117. params={{
  118. orgId: organization.slug,
  119. projectId: project.slug,
  120. bundleId: 'bea7335dfaebc0ca6e65a057',
  121. }}
  122. />,
  123. {context: routerContext, organization}
  124. );
  125. expect(
  126. await screen.findByText('There are no artifacts in this archive.')
  127. ).toBeInTheDocument();
  128. });
  129. });
  130. describe('Debug ID Bundles', function () {
  131. it('renders default state', async function () {
  132. const {organization, route, project, router, routerContext} = initializeOrg({
  133. ...initializeOrg(),
  134. router: {
  135. location: {
  136. pathname: `/settings/${initializeOrg().organization.slug}/projects/${
  137. initializeOrg().project.slug
  138. }/source-maps/debug-id-bundles/7227e105-744e-4066-8c69-3e5e344723fc/`,
  139. query: {},
  140. },
  141. params: {},
  142. },
  143. });
  144. ConfigStore.config = {
  145. ...ConfigStore.config,
  146. user: {...ConfigStore.config.user, isSuperuser: true},
  147. };
  148. renderDebugIdBundlesMockRequests({
  149. orgSlug: organization.slug,
  150. projectSlug: project.slug,
  151. });
  152. render(
  153. <ProjectSourceMapsArtifacts
  154. location={routerContext.context.location}
  155. project={project}
  156. route={route}
  157. routeParams={{orgId: organization.slug, projectId: project.slug}}
  158. router={router}
  159. routes={[]}
  160. params={{
  161. orgId: organization.slug,
  162. projectId: project.slug,
  163. bundleId: '7227e105-744e-4066-8c69-3e5e344723fc',
  164. }}
  165. />,
  166. {context: routerContext, organization}
  167. );
  168. // Title
  169. expect(screen.getByRole('heading')).toHaveTextContent(
  170. 'Debug Id Bundle Artifact (7227e105-744e-4066-8c69-3e5e344723fc)'
  171. );
  172. // Search bar
  173. expect(screen.getByPlaceholderText('Filter by Path or ID')).toBeInTheDocument();
  174. // Path
  175. expect(await screen.findByText('files/_/_/main.js')).toBeInTheDocument();
  176. // Bundle Id
  177. expect(
  178. screen.getByText('69ac68eb-cc62-44c0-a5dc-b67f219a3696')
  179. ).toBeInTheDocument();
  180. // Type
  181. expect(screen.getByText('Minified')).toBeInTheDocument();
  182. // Download Button
  183. expect(screen.getByRole('button', {name: 'Download Artifact'})).toHaveAttribute(
  184. 'href',
  185. '/projects/org-slug/project-slug/artifact-bundles/7227e105-744e-4066-8c69-3e5e344723fc/files/ZmlsZXMvXy9fL21haW4uanM=/?download=1'
  186. );
  187. });
  188. it('renders empty state', async function () {
  189. const {organization, route, project, router, routerContext} = initializeOrg({
  190. ...initializeOrg(),
  191. router: {
  192. location: {
  193. pathname: `/settings/${initializeOrg().organization.slug}/projects/${
  194. initializeOrg().project.slug
  195. }/source-maps/debug-id-bundles/7227e105-744e-4066-8c69-3e5e344723fc/`,
  196. query: {},
  197. },
  198. params: {},
  199. },
  200. });
  201. renderDebugIdBundlesMockRequests({
  202. orgSlug: organization.slug,
  203. projectSlug: project.slug,
  204. empty: true,
  205. });
  206. render(
  207. <ProjectSourceMapsArtifacts
  208. location={routerContext.context.location}
  209. project={project}
  210. route={route}
  211. routeParams={{orgId: organization.slug, projectId: project.slug}}
  212. router={router}
  213. routes={[]}
  214. params={{
  215. orgId: organization.slug,
  216. projectId: project.slug,
  217. bundleId: '7227e105-744e-4066-8c69-3e5e344723fc',
  218. }}
  219. />,
  220. {context: routerContext, organization}
  221. );
  222. expect(
  223. await screen.findByText('There are no artifacts in this bundle.')
  224. ).toBeInTheDocument();
  225. });
  226. });
  227. });