Просмотр исходного кода

ref(tsc): convert User,Member and AccessRequest fixtures to tsx (#52375)

Jonas 1 год назад
Родитель
Сommit
c7fb2c1480

+ 0 - 12
fixtures/js-stubs/accessRequest.js

@@ -1,12 +0,0 @@
-import {Member} from './member';
-import {Team} from './team';
-
-export function AccessRequest(params = {}) {
-  return {
-    id: '123',
-    member: Member(),
-    team: Team(),
-    requester: null,
-    ...params,
-  };
-}

+ 15 - 0
fixtures/js-stubs/accessRequest.tsx

@@ -0,0 +1,15 @@
+import {AccessRequest as AccessRequestType} from 'sentry/types';
+
+import {Member} from './member';
+import {Team} from './team';
+
+export function AccessRequest(
+  params: Partial<AccessRequestType> = {}
+): AccessRequestType {
+  return {
+    id: '123',
+    member: Member(),
+    team: Team(),
+    ...params,
+  };
+}

+ 14 - 1
fixtures/js-stubs/member.js → fixtures/js-stubs/member.tsx

@@ -1,6 +1,8 @@
+import type {Member as MemberType} from 'sentry/types';
+
 import {User} from './user';
 
-export function Member(params = {}) {
+export function Member(params: Partial<MemberType> = {}): MemberType {
   return {
     id: '1',
     email: 'sentry1@test.com',
@@ -12,10 +14,21 @@ export function Member(params = {}) {
     roleName: 'Member',
     pending: false,
     expired: false,
+    dateCreated: '2020-01-01T00:00:00.000Z',
+    invite_link: null,
+    inviterName: null,
+    isOnlyOwner: false,
+    orgRoleList: [],
+    projects: [],
+    roles: [],
+    teamRoleList: [],
+    teams: [],
     flags: {
       'sso:linked': false,
       'idp:provisioned': false,
       'idp:role-restricted': false,
+      'member-limit:restricted': false,
+      'sso:invalid': false,
     },
     user: User(),
     inviteStatus: 'approved',

+ 0 - 16
fixtures/js-stubs/team.js

@@ -1,16 +0,0 @@
-export function Team(params = {}) {
-  return {
-    id: '1',
-    slug: 'team-slug',
-    name: 'Team Name',
-    access: ['team:read'],
-    orgRole: null, // TODO(cathy): Rename this
-    teamRole: null,
-    isMember: true,
-    memberCount: 0,
-    flags: {
-      'idp:provisioned': false,
-    },
-    ...params,
-  };
-}

+ 24 - 0
fixtures/js-stubs/team.tsx

@@ -0,0 +1,24 @@
+import {uuid4} from '@sentry/utils';
+
+import type {Team as TeamType} from 'sentry/types';
+
+export function Team(params: Partial<TeamType> = {}): TeamType {
+  return {
+    id: '1',
+    slug: 'team-slug',
+    name: 'Team Name',
+    access: ['team:read'],
+    orgRole: null, // TODO(cathy): Rename this
+    teamRole: null,
+    isMember: true,
+    memberCount: 0,
+    avatar: {avatarType: 'letter_avatar', avatarUuid: uuid4()},
+    flags: {
+      'idp:provisioned': false,
+    },
+    externalTeams: [],
+    hasAccess: false,
+    isPending: false,
+    ...params,
+  };
+}

+ 0 - 17
fixtures/js-stubs/user.js

@@ -1,17 +0,0 @@
-export function User(params = {}) {
-  return {
-    id: '1',
-    username: 'foo@example.com',
-    email: 'foo@example.com',
-    name: 'Foo Bar',
-    isAuthenticated: true,
-    options: {
-      timezone: 'UTC',
-    },
-    hasPasswordAuth: true,
-    flags: {
-      newsletter_consent_prompt: false,
-    },
-    ...params,
-  };
-}

+ 39 - 0
fixtures/js-stubs/user.tsx

@@ -0,0 +1,39 @@
+import type {User as UserType} from 'sentry/types';
+
+export function User(params: Partial<UserType> = {}): UserType {
+  return {
+    id: '1',
+    username: 'foo@example.com',
+    email: 'foo@example.com',
+    name: 'Foo Bar',
+    isAuthenticated: true,
+    options: {
+      clock24Hours: false,
+      timezone: 'UTC',
+      language: 'en',
+      theme: 'system',
+      avatarType: 'letter_avatar',
+      stacktraceOrder: -1,
+    },
+    ip_address: '127.0.0.1',
+    hasPasswordAuth: true,
+    authenticators: [],
+    canReset2fa: false,
+    dateJoined: '2020-01-01T00:00:00.000Z',
+    emails: [],
+    experiments: [],
+    has2fa: false,
+    identities: [],
+    isActive: false,
+    isManaged: false,
+    isStaff: false,
+    isSuperuser: false,
+    lastActive: '2020-01-01T00:00:00.000Z',
+    lastLogin: '2020-01-01T00:00:00.000Z',
+    permissions: new Set(),
+    flags: {
+      newsletter_consent_prompt: false,
+    },
+    ...params,
+  };
+}

+ 2 - 0
static/app/components/idBadge/userBadge.spec.tsx

@@ -42,6 +42,7 @@ describe('UserBadge', function () {
       name: null,
       email: null,
       username: null,
+      ip_address: null,
       ipAddress: '127.0.0.1',
     });
     render(<UserBadge user={ipUser} />);
@@ -55,6 +56,7 @@ describe('UserBadge', function () {
       name: null,
       email: null,
       username: null,
+      ip_address: null,
       ipAddress: null,
     });
     render(<UserBadge user={idUser} />);

+ 3 - 3
static/app/types/user.tsx

@@ -33,8 +33,7 @@ type UserEnrolledAuthenticator = {
   type: Authenticator['id'];
 };
 
-export type User = Omit<AvatarUser, 'options'> & {
-  authenticators: UserEnrolledAuthenticator[];
+export interface User extends Omit<AvatarUser, 'options'> {
   canReset2fa: boolean;
   dateJoined: string;
   emails: {
@@ -63,7 +62,8 @@ export type User = Omit<AvatarUser, 'options'> & {
     timezone: string;
   };
   permissions: Set<string>;
-};
+  authenticators?: UserEnrolledAuthenticator[];
+}
 
 // XXX(epurkhiser): we should understand how this is diff from User['emails]
 // above

+ 1 - 1
static/app/views/settings/organizationMembers/organizationMemberDetail.spec.jsx

@@ -438,7 +438,7 @@ describe('OrganizationMemberDetail', function () {
     const noAccess = TestStubs.Member({
       ...fields,
       id: '4',
-      user: TestStubs.User({has2fa: false}),
+      user: TestStubs.User({has2fa: false, authenticators: undefined}),
     });
 
     const no2fa = TestStubs.Member({

Некоторые файлы не были показаны из-за большого количества измененных файлов