releaseActivity.spec.jsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  3. import GroupStore from 'sentry/stores/groupStore';
  4. import ProjectsStore from 'sentry/stores/projectsStore';
  5. import {ReleaseContext} from 'sentry/views/releases/detail';
  6. import ReleaseDetailsActivity from 'sentry/views/releases/detail/activity';
  7. import {ReleaseActivityType} from 'sentry/views/releases/detail/activity/types';
  8. import {RouteContext} from 'sentry/views/routeContext';
  9. describe('ReleaseActivity', () => {
  10. const {organization, project, router, routerContext} = initializeOrg({
  11. organization: {
  12. features: ['active-release-monitor-alpha'],
  13. },
  14. });
  15. const release = TestStubs.Release({version: '1.0.0'});
  16. const group = TestStubs.Group();
  17. const activities = [
  18. {
  19. type: ReleaseActivityType.CREATED,
  20. dateAdded: new Date().toISOString(),
  21. data: {},
  22. },
  23. {
  24. type: ReleaseActivityType.DEPLOYED,
  25. dateAdded: new Date().toISOString(),
  26. data: {environment: 'production'},
  27. },
  28. {
  29. type: ReleaseActivityType.ISSUE,
  30. dateAdded: new Date().toISOString(),
  31. data: {group},
  32. },
  33. ];
  34. beforeEach(() => {
  35. GroupStore.init();
  36. act(() => ProjectsStore.loadInitialData(organization.projects));
  37. });
  38. afterEach(() => {
  39. MockApiClient.clearMockResponses();
  40. GroupStore.teardown();
  41. ProjectsStore.teardown();
  42. });
  43. it('renders active release activity', async () => {
  44. MockApiClient.addMockResponse({
  45. url: `/projects/${organization.slug}/${project.slug}/releases/${release.version}/activity/`,
  46. body: activities,
  47. });
  48. render(
  49. <ReleaseContext.Provider value={{release, project}}>
  50. <RouteContext.Provider
  51. value={{
  52. location: router.location,
  53. params: {orgId: organization.slug, release: release.version},
  54. router,
  55. routes: [],
  56. }}
  57. >
  58. <ReleaseDetailsActivity />
  59. </RouteContext.Provider>
  60. </ReleaseContext.Provider>,
  61. {organization, context: routerContext}
  62. );
  63. expect(await screen.findByText('Release Created')).toBeInTheDocument();
  64. expect(screen.getByText('Deployed to production')).toBeInTheDocument();
  65. expect(screen.getByText(group.culprit)).toBeInTheDocument();
  66. expect(
  67. screen.getByText(
  68. 'Waiting for new issues in this release to notify release participants ...'
  69. )
  70. ).toBeInTheDocument();
  71. });
  72. });