notificationSettingsByEntity.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {Organization} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import NotificationSettingsByEntity from 'sentry/views/settings/account/notifications/notificationSettingsByEntity';
  5. describe('NotificationSettingsByEntity', function () {
  6. afterEach(() => {
  7. MockApiClient.clearMockResponses();
  8. jest.clearAllMocks();
  9. });
  10. it('should default to the subdomain org', async function () {
  11. const organization = Organization();
  12. const otherOrganization = Organization({
  13. id: '2',
  14. slug: 'other-org',
  15. name: 'other org',
  16. });
  17. ConfigStore.set('customerDomain', {
  18. ...ConfigStore.get('customerDomain')!,
  19. subdomain: otherOrganization.slug,
  20. });
  21. const projectsMock = MockApiClient.addMockResponse({
  22. url: `/organizations/${otherOrganization.slug}/projects/`,
  23. method: 'GET',
  24. body: [],
  25. });
  26. render(
  27. <NotificationSettingsByEntity
  28. organizations={[organization, otherOrganization]}
  29. notificationType="alerts"
  30. notificationOptions={[]}
  31. handleRemoveNotificationOption={jest.fn()}
  32. handleAddNotificationOption={jest.fn()}
  33. entityType={'project' as const}
  34. />
  35. );
  36. expect(await screen.findByText(otherOrganization.name)).toBeInTheDocument();
  37. expect(projectsMock).toHaveBeenCalledTimes(1);
  38. });
  39. });