index.spec.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import OrganizationStore from 'sentry/stores/organizationStore';
  5. import PageFiltersStore from 'sentry/stores/pageFiltersStore';
  6. import ProjectsStore from 'sentry/stores/projectsStore';
  7. import OrganizationLayout from 'sentry/views/organizationLayout';
  8. jest.mock(
  9. 'sentry/components/sidebar',
  10. () =>
  11. function () {
  12. return <div />;
  13. }
  14. );
  15. describe('OrganizationLayout', function () {
  16. const {routerContext} = initializeOrg();
  17. beforeEach(function () {
  18. OrganizationStore.reset();
  19. ProjectsStore.reset();
  20. PageFiltersStore.reset();
  21. MockApiClient.clearMockResponses();
  22. MockApiClient.addMockResponse({
  23. url: '/organizations/org-slug/broadcasts/',
  24. body: [],
  25. });
  26. MockApiClient.addMockResponse({
  27. url: '/organizations/org-slug/environments/',
  28. body: [],
  29. });
  30. });
  31. describe('deletion states', () => {
  32. it('should render a restoration prompt', async function () {
  33. const organization = OrganizationFixture({
  34. status: {
  35. id: 'pending_deletion',
  36. name: 'pending deletion',
  37. },
  38. });
  39. OrganizationStore.onUpdate(organization);
  40. render(
  41. <OrganizationLayout>
  42. <div />
  43. </OrganizationLayout>,
  44. {context: routerContext, organization}
  45. );
  46. expect(await screen.findByText('Deletion Scheduled')).toBeInTheDocument();
  47. expect(screen.getByLabelText('Restore Organization')).toBeInTheDocument();
  48. expect(
  49. screen.getByText(
  50. 'Would you like to cancel this process and restore the organization back to the original state?'
  51. )
  52. ).toBeInTheDocument();
  53. });
  54. it('should render a restoration prompt without action for members', async function () {
  55. const organization = OrganizationFixture({
  56. access: [],
  57. status: {
  58. id: 'pending_deletion',
  59. name: 'pending deletion',
  60. },
  61. });
  62. OrganizationStore.onUpdate(organization);
  63. render(
  64. <OrganizationLayout>
  65. <div />
  66. </OrganizationLayout>,
  67. {context: routerContext, organization}
  68. );
  69. expect(await screen.findByText('Deletion Scheduled')).toBeInTheDocument();
  70. const mistakeText = screen.getByText(
  71. 'If this is a mistake, contact an organization owner and ask them to restore this organization.'
  72. );
  73. expect(mistakeText).toBeInTheDocument();
  74. expect(screen.queryByLabelText('Restore Organization')).not.toBeInTheDocument();
  75. });
  76. });
  77. it('should render a deletion in progress prompt', async function () {
  78. const organization = OrganizationFixture({
  79. status: {
  80. id: 'deletion_in_progress',
  81. name: 'deletion in progress',
  82. },
  83. });
  84. OrganizationStore.onUpdate(organization);
  85. render(
  86. <OrganizationLayout>
  87. <div />
  88. </OrganizationLayout>,
  89. {context: routerContext, organization}
  90. );
  91. const inProgress = await screen.findByText(
  92. 'currently in the process of being deleted from Sentry.',
  93. {exact: false}
  94. );
  95. expect(inProgress).toBeInTheDocument();
  96. expect(screen.queryByLabelText('Restore Organization')).not.toBeInTheDocument();
  97. });
  98. });