Browse Source

ref(fixtures): Refactor Organization fixture to TS (#55287)

Ryan Albrecht 1 year ago
parent
commit
2f355af34b

+ 0 - 44
fixtures/js-stubs/organization.js

@@ -1,44 +0,0 @@
-import {OrgRoleList, TeamRoleList} from './roleList';
-
-export function Organization(params = {}) {
-  const slug = params.slug ?? 'org-slug';
-  return {
-    id: '3',
-    slug,
-    name: 'Organization Name',
-    links: {
-      organizationUrl: `https://${slug}.sentry.io`,
-      regionUrl: 'https://us.sentry.io',
-    },
-    access: [
-      'org:read',
-      'org:write',
-      'org:admin',
-      'org:integrations',
-      'project:read',
-      'project:write',
-      'project:releases',
-      'project:admin',
-      'team:read',
-      'team:write',
-      'team:admin',
-      'alerts:read',
-      'alerts:write',
-    ],
-    status: {
-      id: 'active',
-      name: 'active',
-    },
-    experiments: {},
-    scrapeJavaScript: true,
-    features: [],
-    onboardingTasks: [],
-    teams: [],
-    projects: [],
-    isDynamicallySampled: true,
-    ...params,
-
-    orgRoleList: OrgRoleList(),
-    teamRoleList: TeamRoleList(),
-  };
-}

+ 81 - 0
fixtures/js-stubs/organization.tsx

@@ -0,0 +1,81 @@
+import type {Organization as TOrganization} from 'sentry/types';
+
+import {OrgRoleList, TeamRoleList} from './roleList';
+
+export function Organization(params: Partial<TOrganization> = {}): TOrganization {
+  const slug = params.slug ?? 'org-slug';
+  return {
+    id: '3',
+    slug,
+    name: 'Organization Name',
+    links: {
+      organizationUrl: `https://${slug}.sentry.io`,
+      regionUrl: 'https://us.sentry.io',
+    },
+    access: [
+      'org:read',
+      'org:write',
+      'org:admin',
+      'org:integrations',
+      'project:read',
+      'project:write',
+      'project:releases',
+      'project:admin',
+      'team:read',
+      'team:write',
+      'team:admin',
+      'alerts:read',
+      'alerts:write',
+    ],
+    status: {
+      id: 'active',
+      name: 'active',
+    },
+    experiments: {},
+    scrapeJavaScript: true,
+    features: [],
+    onboardingTasks: [],
+    aiSuggestedSolution: false,
+    alertsMemberWrite: false,
+    allowJoinRequests: false,
+    allowSharedIssues: false,
+    attachmentsRole: '',
+    availableRoles: [],
+    avatar: {
+      avatarType: 'default',
+      avatarUuid: null,
+    },
+    codecovAccess: false,
+    dataScrubber: false,
+    dataScrubberDefaults: false,
+    dateCreated: new Date().toISOString(),
+    debugFilesRole: '',
+    defaultRole: '',
+    enhancedPrivacy: false,
+    eventsMemberAdmin: false,
+    githubOpenPRBot: false,
+    githubPRBot: false,
+    isDefault: false,
+    isDynamicallySampled: true,
+    isEarlyAdopter: false,
+    openMembership: false,
+    pendingAccessRequests: 0,
+    quota: {
+      accountLimit: null,
+      maxRate: null,
+      maxRateInterval: null,
+      projectLimit: null,
+    },
+    relayPiiConfig: null,
+    require2FA: false,
+    safeFields: [],
+    scrubIPAddresses: false,
+    sensitiveFields: [],
+    storeCrashReports: 0,
+    trustedRelays: [],
+    ...params,
+
+    orgRoleList: OrgRoleList(),
+    teamRoleList: TeamRoleList(),
+  };
+}

+ 4 - 1
static/app/components/avatar/index.spec.tsx

@@ -132,7 +132,10 @@ describe('Avatar', function () {
     });
 
     it('can display an organization Avatar', function () {
-      const organization = TestStubs.Organization({slug: 'test-organization'});
+      const organization = TestStubs.Organization({
+        slug: 'test-organization',
+        avatar: {avatarType: 'letter_avatar'},
+      });
 
       render(<AvatarComponent organization={organization} />);
 

+ 1 - 1
static/app/views/onboarding/createSampleEventButton.spec.tsx

@@ -112,7 +112,7 @@ describe('CreateSampleEventButton', function () {
     expect(trackAnalytics).toHaveBeenCalledWith(
       'sample_event.created',
       expect.objectContaining({
-        organization: org,
+        organization: expect.objectContaining(org),
         project_id: project.id,
         interval: 1000,
         retries: 1,