notificationSettings.spec.tsx 2.1 KB

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