123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
- import DataSecrecy from 'sentry/views/settings/components/dataSecrecy';
- jest.mock('sentry/actionCreators/indicator');
- describe('DataSecrecy', function () {
- const {organization} = initializeOrg({
- organization: {features: ['data-secrecy']},
- });
- beforeEach(function () {
- MockApiClient.clearMockResponses();
- jest.clearAllMocks();
- });
- it('renders default state with no waiver', async function () {
- MockApiClient.addMockResponse({
- url: `/organizations/${organization.slug}/data-secrecy/`,
- body: null,
- });
- render(<DataSecrecy />, {organization: organization});
- await waitFor(() => {
- expect(screen.getByText('Support Access')).toBeInTheDocument();
- });
- organization.allowSuperuserAccess = false;
- await waitFor(() => {
- expect(
- screen.getByText(/sentry employees do not have access to your organization/i)
- ).toBeInTheDocument();
- });
- });
- it('renders default state with waiver', async function () {
- MockApiClient.addMockResponse({
- url: `/organizations/${organization.slug}/data-secrecy/`,
- body: null,
- });
- render(<DataSecrecy />, {organization: organization});
- await waitFor(() => {
- expect(screen.getByText('Support Access')).toBeInTheDocument();
- });
- organization.allowSuperuserAccess = true;
- await waitFor(() => {
- expect(
- screen.getByText(/sentry employees do not have access to your organization/i)
- ).toBeInTheDocument();
- });
- });
- it('renders no access state with waiver present', async function () {
- MockApiClient.addMockResponse({
- url: `/organizations/${organization.slug}/data-secrecy/`,
- body: {
- accessStart: '2022-08-29T01:05:00+00:00',
- accessEnd: '2023-08-29T01:05:00+00:00',
- },
- });
- render(<DataSecrecy />, {organization: organization});
- await waitFor(() => {
- expect(screen.getByText('Support Access')).toBeInTheDocument();
- });
- organization.allowSuperuserAccess = false;
- // we should see no access message
- await waitFor(() => {
- expect(
- screen.getByText(
- /sentry employees will not have access to your organization unless granted permission/i
- )
- ).toBeInTheDocument();
- });
- });
- it('renders current waiver state', async function () {
- MockApiClient.addMockResponse({
- url: `/organizations/${organization.slug}/data-secrecy/`,
- body: {
- accessStart: '2023-08-29T01:05:00+00:00',
- accessEnd: '2024-08-29T01:05:00+00:00',
- },
- });
- organization.allowSuperuserAccess = false;
- render(<DataSecrecy />, {organization: organization});
- await waitFor(() => {
- const accessMessage = screen.getByText(
- /Sentry employees has access to your organization until/i
- );
- expect(accessMessage).toBeInTheDocument();
- });
- });
- });
|