useProjectCreationAccess.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {renderHook} from 'sentry-test/reactTestingLibrary';
  3. import {useProjectCreationAccess} from './useProjectCreationAccess';
  4. describe('ProjectCreationAccess', function () {
  5. const organization = OrganizationFixture();
  6. it('passes project creation eligibility for org-manager', function () {
  7. const {result} = renderHook(useProjectCreationAccess, {
  8. initialProps: {organization},
  9. });
  10. expect(result.current.canCreateProject).toBeTruthy();
  11. });
  12. it('passes for members if org has team-roles', function () {
  13. const experiment_org = OrganizationFixture({
  14. access: ['org:read', 'team:read', 'project:read'],
  15. features: ['team-roles'],
  16. });
  17. const {result} = renderHook(useProjectCreationAccess, {
  18. initialProps: {organization: experiment_org},
  19. });
  20. expect(result.current.canCreateProject).toBeTruthy();
  21. });
  22. it('fails for members if org does not have team-roles', function () {
  23. const no_team_role_org = OrganizationFixture({
  24. access: ['org:read', 'team:read', 'project:read'],
  25. });
  26. const {result} = renderHook(useProjectCreationAccess, {
  27. initialProps: {organization: no_team_role_org},
  28. });
  29. expect(result.current.canCreateProject).toBeFalsy();
  30. });
  31. });