[MNT-24923] legal hold hold capabilities are not verified properly (#10930)

* [MNT-24923] Added possibility to filter capabilities by person id

* [MNT-24923] Documentation and unit tests
This commit is contained in:
AleksanderSklorz
2025-06-12 14:21:49 +02:00
committed by GitHub
parent 7a568baf72
commit cdc7553915
5 changed files with 67 additions and 12 deletions

View File

@@ -168,16 +168,22 @@ export class FilePlansApi extends BaseApi {
*/
getFilePlanRoles(filePlanId: string, parameters?: FilePlanRoleParameters): Promise<FilePlanRolePaging> {
throwIfNotDefined(filePlanId, 'filePlanId');
const whereConditions: string[] = [];
if (parameters?.where) {
if (parameters.where.personId) {
whereConditions.push(`personId='${parameters.where.personId}'`);
}
if (parameters.where.capabilityNames) {
whereConditions.push(`capabilityName in (${parameters.where.capabilityNames.map((value) => "'" + value + "'").join(', ')})`);
}
}
return this.get({
path: '/file-plans/{filePlanId}/roles',
pathParams: {
filePlanId
},
queryParams: {
where: parameters?.where?.capabilityNames
? `(capabilityName in (${parameters.where.capabilityNames.map((value) => "'" + value + "'").join(', ')}))`
: undefined
where: whereConditions.length ? `(${whereConditions.join(' and ')})` : undefined
}
});
}

View File

@@ -3,6 +3,7 @@
## Properties
| Name | Type |
|---------------------|----------|
| **personId** | string |
| **capabilityNames** | string[] |

View File

@@ -16,5 +16,6 @@
*/
export interface FilePlanRoleParametersWhere {
personId?: string;
capabilityNames?: string[];
}

View File

@@ -35,6 +35,8 @@ describe('FilePlansApi', () => {
});
describe('getFilePlanRoles', () => {
const filePlanId = 'filePlanId123';
let expectedRolePaging: FilePlanRolePaging;
beforeEach(() => {
@@ -101,7 +103,6 @@ describe('FilePlansApi', () => {
});
it('should get file plan roles', (done) => {
const filePlanId = 'filePlanId123';
filePlansApiMock.get200FilePlanRoles(filePlanId);
filePlansApi.getFilePlanRoles(filePlanId).then((rolePaging) => {
@@ -111,7 +112,6 @@ describe('FilePlansApi', () => {
});
it('should get file plan roles with filtering by capability names', (done) => {
const filePlanId = 'filePlanId123';
filePlansApiMock.get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId);
filePlansApi
@@ -125,5 +125,36 @@ describe('FilePlansApi', () => {
done();
});
});
it('should get file plan roles with filtering by person id', (done) => {
filePlansApiMock.get200FilePlanRolesWithFilteringByPersonId(filePlanId);
filePlansApi
.getFilePlanRoles(filePlanId, {
where: {
personId: 'someUser'
}
})
.then((rolePaging) => {
expect(rolePaging).toEqual(expectedRolePaging);
done();
});
});
it('should get file plan roles with filtering by capability names', (done) => {
filePlansApiMock.get200FilePlanRolesWithFilteringByPersonIdAndCapabilityNames(filePlanId);
filePlansApi
.getFilePlanRoles(filePlanId, {
where: {
personId: 'someUser',
capabilityNames: ['capability1', 'capability2']
}
})
.then((rolePaging) => {
expect(rolePaging).toEqual(expectedRolePaging);
done();
});
});
});
});

View File

@@ -21,21 +21,37 @@ import { FilePlanRolePaging } from '@alfresco/js-api';
export class FilePlansMock extends BaseMock {
get200FilePlanRoles(filePlanId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`)
.query({})
.reply(200, this.mockFilePlanRolePaging());
this.nock200FilePlanRoles(filePlanId).query({}).reply(200, this.mockFilePlanRolePaging());
}
get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`)
this.nock200FilePlanRoles(filePlanId)
.query({
where: "(capabilityName in ('capability1', 'capability2'))"
})
.reply(200, this.mockFilePlanRolePaging());
}
get200FilePlanRolesWithFilteringByPersonId(filePlanId: string): void {
this.nock200FilePlanRoles(filePlanId)
.query({
where: "(personId='someUser')"
})
.reply(200, this.mockFilePlanRolePaging());
}
get200FilePlanRolesWithFilteringByPersonIdAndCapabilityNames(filePlanId: string): void {
this.nock200FilePlanRoles(filePlanId)
.query({
where: "(personId='someUser' and capabilityName in ('capability1', 'capability2'))"
})
.reply(200, this.mockFilePlanRolePaging());
}
private nock200FilePlanRoles(filePlanId: string): nock.Interceptor {
return nock(this.host, { encodedQueryParams: true }).get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`);
}
private mockFilePlanRolePaging(): FilePlanRolePaging {
return {
list: {