index.spec.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
  3. import DataSecrecy from 'sentry/views/settings/components/dataSecrecy';
  4. jest.mock('sentry/actionCreators/indicator');
  5. describe('DataSecrecy', function () {
  6. const {organization} = initializeOrg({
  7. organization: {features: ['data-secrecy']},
  8. });
  9. beforeEach(function () {
  10. MockApiClient.clearMockResponses();
  11. jest.clearAllMocks();
  12. });
  13. it('renders default state with no waiver', async function () {
  14. MockApiClient.addMockResponse({
  15. url: `/organizations/${organization.slug}/data-secrecy/`,
  16. body: null,
  17. });
  18. render(<DataSecrecy />, {organization: organization});
  19. await waitFor(() => {
  20. expect(screen.getByText('Support Access')).toBeInTheDocument();
  21. });
  22. organization.allowSuperuserAccess = false;
  23. await waitFor(() => {
  24. expect(
  25. screen.getByText(/sentry employees do not have access to your organization/i)
  26. ).toBeInTheDocument();
  27. });
  28. });
  29. it('renders default state with waiver', async function () {
  30. MockApiClient.addMockResponse({
  31. url: `/organizations/${organization.slug}/data-secrecy/`,
  32. body: null,
  33. });
  34. render(<DataSecrecy />, {organization: organization});
  35. await waitFor(() => {
  36. expect(screen.getByText('Support Access')).toBeInTheDocument();
  37. });
  38. organization.allowSuperuserAccess = true;
  39. await waitFor(() => {
  40. expect(
  41. screen.getByText(/sentry employees do not have access to your organization/i)
  42. ).toBeInTheDocument();
  43. });
  44. });
  45. it('renders no access state with waiver present', async function () {
  46. MockApiClient.addMockResponse({
  47. url: `/organizations/${organization.slug}/data-secrecy/`,
  48. body: {
  49. accessStart: '2022-08-29T01:05:00+00:00',
  50. accessEnd: '2023-08-29T01:05:00+00:00',
  51. },
  52. });
  53. render(<DataSecrecy />, {organization: organization});
  54. await waitFor(() => {
  55. expect(screen.getByText('Support Access')).toBeInTheDocument();
  56. });
  57. organization.allowSuperuserAccess = false;
  58. // we should see no access message
  59. await waitFor(() => {
  60. expect(
  61. screen.getByText(
  62. /sentry employees will not have access to your organization unless granted permission/i
  63. )
  64. ).toBeInTheDocument();
  65. });
  66. });
  67. it('renders current waiver state', async function () {
  68. MockApiClient.addMockResponse({
  69. url: `/organizations/${organization.slug}/data-secrecy/`,
  70. body: {
  71. accessStart: '2023-08-29T01:05:00+00:00',
  72. accessEnd: '2024-08-29T01:05:00+00:00',
  73. },
  74. });
  75. organization.allowSuperuserAccess = false;
  76. render(<DataSecrecy />, {organization: organization});
  77. await waitFor(() => {
  78. const accessMessage = screen.getByText(
  79. /Sentry employees has access to your organization until/i
  80. );
  81. expect(accessMessage).toBeInTheDocument();
  82. });
  83. });
  84. });