permissionsObserver.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import Form from 'sentry/components/forms/form';
  3. import FormModel from 'sentry/components/forms/model';
  4. import PermissionsObserver from 'sentry/views/settings/organizationDeveloperSettings/permissionsObserver';
  5. describe('PermissionsObserver', () => {
  6. let model;
  7. beforeEach(() => {
  8. model = new FormModel();
  9. render(
  10. <Form model={model}>
  11. <PermissionsObserver
  12. scopes={['project:read', 'project:write', 'project:releases', 'org:admin']}
  13. events={['issue']}
  14. newApp={false}
  15. />
  16. </Form>
  17. );
  18. });
  19. it('defaults to no-access for all resources not passed', () => {
  20. expect(model.getValue('Team--permission')).toBe('no-access');
  21. expect(model.getValue('Event--permission')).toBe('no-access');
  22. expect(model.getValue('Member--permission')).toBe('no-access');
  23. });
  24. it('converts a raw list of scopes into permissions', () => {
  25. expect(model.getValue('Project--permission')).toBe('write');
  26. expect(model.getValue('Release--permission')).toBe('admin');
  27. expect(model.getValue('Organization--permission')).toBe('admin');
  28. });
  29. it('selects the highest ranking scope to convert to permission', () => {
  30. expect(model.getValue('Project--permission')).toBe('write');
  31. });
  32. });