feat: Added additional types.
Signed-off-by: Marley Powell <Marley.Powell@exclaimer.com>
This commit is contained in:
@@ -215,6 +215,7 @@ function convertReviewer(
|
||||
return {
|
||||
id: identityRef.id,
|
||||
displayName: identityRef.displayName,
|
||||
uniqueName: identityRef.uniqueName,
|
||||
imageUrl: getAvatarUrl(identityRef),
|
||||
isRequired: identityRef.isRequired,
|
||||
isContainer: identityRef.isContainer,
|
||||
|
||||
@@ -145,6 +145,7 @@ export interface DashboardPullRequest {
|
||||
export interface Reviewer {
|
||||
id?: string;
|
||||
displayName?: string;
|
||||
uniqueName?: string;
|
||||
imageUrl?: string;
|
||||
isRequired?: boolean;
|
||||
isContainer?: boolean;
|
||||
@@ -164,6 +165,8 @@ export interface CreatedBy {
|
||||
displayName?: string;
|
||||
uniqueName?: string;
|
||||
imageUrl?: string;
|
||||
teamIds?: string[];
|
||||
teamNames?: string[];
|
||||
}
|
||||
|
||||
export interface Repository {
|
||||
|
||||
@@ -19,33 +19,7 @@ import {
|
||||
PullRequestVoteStatus,
|
||||
Reviewer,
|
||||
} from '@backstage/plugin-azure-devops-common';
|
||||
import {
|
||||
arrayExtract,
|
||||
getCreatedByUserFilter,
|
||||
getPullRequestGroups,
|
||||
reviewerFilter,
|
||||
} from './utils';
|
||||
|
||||
describe('getCreatedByUserFilter', () => {
|
||||
it('should filter if pull request is created by user', () => {
|
||||
const userEmail = 'user1@backstage.com';
|
||||
const pr = {
|
||||
createdBy: { uniqueName: userEmail },
|
||||
} as DashboardPullRequest;
|
||||
const result = getCreatedByUserFilter(userEmail)(pr);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should not filter if pull request is not created by user', () => {
|
||||
const userEmail1 = 'user1@backstage.com';
|
||||
const userEmail2 = 'user2@backstage.com';
|
||||
const pr = {
|
||||
createdBy: { uniqueName: userEmail1 },
|
||||
} as DashboardPullRequest;
|
||||
const result = getCreatedByUserFilter(userEmail2)(pr);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
import { arrayExtract, getPullRequestGroups, reviewerFilter } from './utils';
|
||||
|
||||
describe('reviewerFilter', () => {
|
||||
it('should return false if reviewer has no vote and is not required', () => {
|
||||
@@ -128,7 +102,11 @@ describe('getPullRequestGroups', () => {
|
||||
];
|
||||
|
||||
const configs = [
|
||||
{ title: 'Created by me', filter: getCreatedByUserFilter(userEmail) },
|
||||
{
|
||||
title: 'Created by me',
|
||||
filter: (pullRequest: DashboardPullRequest): boolean =>
|
||||
pullRequest.createdBy?.uniqueName === userEmail,
|
||||
},
|
||||
{ title: 'Other PRs', filter: (_: unknown) => true, simplified: true },
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user