notificationSettingsByEntity.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {OrganizationFixture} 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 = OrganizationFixture();
  12. const otherOrganization = OrganizationFixture({
  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. handleEditNotificationOption={jest.fn()}
  34. entityType={'project' as const}
  35. />
  36. );
  37. expect(await screen.findByText(otherOrganization.name)).toBeInTheDocument();
  38. expect(projectsMock).toHaveBeenCalledTimes(1);
  39. });
  40. });