notificationSettingsV2.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {SELF_NOTIFICATION_SETTINGS_TYPES} from 'sentry/views/settings/account/notifications/constants';
  4. import {NOTIFICATION_SETTING_FIELDS} from 'sentry/views/settings/account/notifications/fields2';
  5. import NotificationSettings from 'sentry/views/settings/account/notifications/notificationSettingsV2';
  6. function renderMockRequests({}: {}) {
  7. MockApiClient.addMockResponse({
  8. url: '/users/me/notifications/',
  9. method: 'GET',
  10. body: {
  11. personalActivityNotifications: true,
  12. selfAssignOnResolve: true,
  13. weeklyReports: true,
  14. },
  15. });
  16. }
  17. describe('NotificationSettings', function () {
  18. it('should render', async function () {
  19. const {routerContext, organization} = initializeOrg();
  20. renderMockRequests({});
  21. render(<NotificationSettings organizations={[organization]} />, {
  22. context: routerContext,
  23. });
  24. // There are 8 notification setting Selects/Toggles.
  25. for (const field of [
  26. 'alerts',
  27. 'workflow',
  28. 'deploy',
  29. 'approval',
  30. 'reports',
  31. 'email',
  32. ...SELF_NOTIFICATION_SETTINGS_TYPES,
  33. ]) {
  34. expect(
  35. await screen.findByText(String(NOTIFICATION_SETTING_FIELDS[field].label))
  36. ).toBeInTheDocument();
  37. }
  38. expect(screen.getByText('Issue Alerts')).toBeInTheDocument();
  39. });
  40. it('renders quota section with feature flag', async function () {
  41. const {routerContext, organization} = initializeOrg({
  42. organization: {
  43. features: ['slack-overage-notifications'],
  44. },
  45. });
  46. renderMockRequests({});
  47. render(<NotificationSettings organizations={[organization]} />, {
  48. context: routerContext,
  49. });
  50. // There are 9 notification setting Selects/Toggles.
  51. for (const field of [
  52. 'alerts',
  53. 'workflow',
  54. 'deploy',
  55. 'approval',
  56. 'reports',
  57. 'email',
  58. 'quota',
  59. ...SELF_NOTIFICATION_SETTINGS_TYPES,
  60. ]) {
  61. expect(
  62. await screen.findByText(String(NOTIFICATION_SETTING_FIELDS[field].label))
  63. ).toBeInTheDocument();
  64. }
  65. expect(screen.getByText('Issue Alerts')).toBeInTheDocument();
  66. });
  67. });