notificationSettingsByEntity.spec.tsx 1.4 KB

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