permissionsObserver.spec.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. />
  15. </Form>
  16. );
  17. });
  18. it('defaults to no-access for all resources not passed', () => {
  19. expect(model.getValue('Team--permission')).toBe('no-access');
  20. expect(model.getValue('Event--permission')).toBe('no-access');
  21. expect(model.getValue('Member--permission')).toBe('no-access');
  22. });
  23. it('converts a raw list of scopes into permissions', () => {
  24. expect(model.getValue('Project--permission')).toBe('write');
  25. expect(model.getValue('Release--permission')).toBe('admin');
  26. expect(model.getValue('Organization--permission')).toBe('admin');
  27. });
  28. it('selects the highest ranking scope to convert to permission', () => {
  29. expect(model.getValue('Project--permission')).toBe('write');
  30. });
  31. });