organizationsDetails.spec.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import OrganizationDetails from 'app/views/organizationDetails';
  4. describe('OrganizationDetails', function() {
  5. beforeEach(function() {
  6. MockApiClient.clearMockResponses();
  7. MockApiClient.addMockResponse({
  8. url: '/broadcasts/',
  9. body: [],
  10. });
  11. MockApiClient.addMockResponse({
  12. url: '/organizations/org-slug/environments/',
  13. body: [],
  14. });
  15. });
  16. describe('render()', function() {
  17. describe('pending deletion', () => {
  18. it('should render a restoration prompt', async function() {
  19. MockApiClient.addMockResponse({
  20. url: '/organizations/org-slug/',
  21. body: TestStubs.Organization({
  22. slug: 'org-slug',
  23. status: {
  24. id: 'pending_deletion',
  25. name: 'pending deletion',
  26. },
  27. }),
  28. });
  29. let tree = mount(
  30. <OrganizationDetails params={{orgId: 'org-slug'}} location={{}} />,
  31. TestStubs.routerContext()
  32. );
  33. await tick();
  34. await tick();
  35. tree.update();
  36. expect(tree.text()).toContain('Deletion Scheduled');
  37. expect(tree.text()).toContain(
  38. 'Would you like to cancel this process and restore the organization back to the original state?'
  39. );
  40. expect(tree.find('button[aria-label="Restore Organization"]')).toHaveLength(1);
  41. });
  42. it('should render a restoration prompt without action for members', async function() {
  43. MockApiClient.addMockResponse({
  44. url: '/organizations/org-slug/',
  45. body: TestStubs.Organization({
  46. slug: 'org-slug',
  47. access: [],
  48. status: {
  49. id: 'pending_deletion',
  50. name: 'pending deletion',
  51. },
  52. }),
  53. });
  54. let tree = mount(
  55. <OrganizationDetails params={{orgId: 'org-slug'}} location={{}} />,
  56. TestStubs.routerContext()
  57. );
  58. await tick();
  59. await tick();
  60. tree.update();
  61. expect(tree.text()).toContain(
  62. [
  63. 'The org-slug organization is currently scheduled for deletion.',
  64. 'If this is a mistake, contact an organization owner and ask them to restore this organization.',
  65. ].join('')
  66. );
  67. expect(tree.find('button[aria-label="Restore Organization"]')).toHaveLength(0);
  68. });
  69. });
  70. describe('deletion in progress', () => {
  71. beforeEach(() => {
  72. MockApiClient.addMockResponse({
  73. url: '/organizations/org-slug/',
  74. body: TestStubs.Organization({
  75. slug: 'org-slug',
  76. status: {
  77. id: 'deletion_in_progress',
  78. name: 'deletion in progress',
  79. },
  80. }),
  81. });
  82. });
  83. it('should render a deletion in progress prompt', async function() {
  84. let tree = mount(
  85. <OrganizationDetails params={{orgId: 'org-slug'}} location={{}} />
  86. );
  87. await tick();
  88. await tick();
  89. tree.update();
  90. expect(tree.text()).toContain(
  91. 'The org-slug organization is currently in the process of being deleted from Sentry'
  92. );
  93. expect(tree.find('button[aria-label="Restore Organization"]')).toHaveLength(0);
  94. });
  95. });
  96. });
  97. });