fix-18035

Signed-off-by: npiyush97 <npiyush35@gmail.com>
This commit is contained in:
npiyush97
2023-06-02 12:30:25 +05:30
parent 54acb45982
commit f31fd1f8fd
3 changed files with 73 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-gitlab': minor
---
added test if user does not have name or profile picture,variable default to undefined
@@ -264,6 +264,48 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
is_admin: false,
note: '',
},
{
id: 2,
username: 'test2',
name: '',
state: 'active',
avatar_url: '',
web_url: 'https://gitlab.example/test2',
created_at: '2023-01-19T07:27:03.333Z',
bio: '',
location: null,
public_email: null,
skype: '',
linkedin: '',
twitter: '',
website_url: '',
organization: null,
job_title: '',
pronouns: null,
bot: false,
work_information: null,
followers: 0,
following: 0,
is_followed: false,
local_time: null,
last_sign_in_at: '2023-01-19T07:27:49.601Z',
confirmed_at: '2023-01-19T07:27:02.905Z',
last_activity_on: '2023-01-19',
email: 'test@example.com',
theme_id: 1,
color_scheme_id: 1,
projects_limit: 100000,
current_sign_in_at: '2023-01-19T09:09:10.676Z',
identities: [],
can_create_group: true,
can_create_project: true,
two_factor_enabled: false,
external: false,
private_profile: false,
commit_email: 'test@example.com',
is_admin: false,
note: '',
},
];
return res(ctx.json(response));
}),
@@ -374,6 +416,31 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
},
locationKey: 'GitlabOrgDiscoveryEntityProvider:test-id',
},
{
entity: {
apiVersion: 'backstage.io/v1alpha1',
kind: 'User',
metadata: {
annotations: {
'backstage.io/managed-by-location':
'url:https://test-gitlab/test2',
'backstage.io/managed-by-origin-location':
'url:https://test-gitlab/test2',
'test-gitlab/user-login': 'https://gitlab.example/test2',
},
name: 'test2',
},
spec: {
memberOf: [],
profile: {
displayName: undefined,
email: 'test@example.com',
picture: undefined,
},
},
},
locationKey: 'GitlabOrgDiscoveryEntityProvider:test-id',
},
{
entity: {
apiVersion: 'backstage.io/v1alpha1',
@@ -319,7 +319,7 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider {
},
spec: {
profile: {
displayName: user.name,
displayName: user.name || undefined,
picture: user.avatar_url || undefined,
},
memberOf: [],