123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import {ProjectFixture} from 'sentry-fixture/project';
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import ProjectUserFeedback from 'sentry/views/settings/projectUserFeedback';
- describe('ProjectUserFeedback', function () {
- const {routerProps, organization, project, routerContext} = initializeOrg();
- const url = `/projects/${organization.slug}/${project.slug}/`;
- beforeEach(function () {
- MockApiClient.clearMockResponses();
- MockApiClient.addMockResponse({
- url,
- method: 'GET',
- body: ProjectFixture(),
- });
- MockApiClient.addMockResponse({
- url: `${url}keys/`,
- method: 'GET',
- body: [],
- });
- });
- it('can toggle sentry branding option', async function () {
- render(
- <ProjectUserFeedback
- {...routerProps}
- organization={organization}
- project={project}
- />,
- {
- context: routerContext,
- }
- );
- const mock = MockApiClient.addMockResponse({
- url,
- method: 'PUT',
- });
- await userEvent.click(
- screen.getByRole('checkbox', {name: 'Show Sentry Branding in Crash Report Modal'})
- );
- expect(mock).toHaveBeenCalledWith(
- url,
- expect.objectContaining({
- method: 'PUT',
- data: {
- options: {'feedback:branding': true},
- },
- })
- );
- });
- });
- describe('ProjectUserFeedbackProcessing', function () {
- const {routerProps, organization, project, routerContext} = initializeOrg();
- const url = `/projects/${organization.slug}/${project.slug}/`;
- beforeEach(function () {
- MockApiClient.clearMockResponses();
- MockApiClient.addMockResponse({
- url,
- method: 'GET',
- body: ProjectFixture(),
- });
- MockApiClient.addMockResponse({
- url: `${url}keys/`,
- method: 'GET',
- body: [],
- });
- });
- it('can toggle spam detection', async function () {
- render(
- <ProjectUserFeedback
- {...routerProps}
- organization={organization}
- project={project}
- />,
- {
- context: routerContext,
- }
- );
- const mock = MockApiClient.addMockResponse({
- url,
- method: 'PUT',
- });
- await userEvent.click(screen.getByRole('checkbox', {name: 'Enable Spam Detection'}));
- expect(mock).toHaveBeenCalledWith(
- url,
- expect.objectContaining({
- method: 'PUT',
- data: {
- options: {'sentry:feedback_ai_spam_detection': true},
- },
- })
- );
- });
- });
|