mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -168,16 +168,22 @@ export class FilePlansApi extends BaseApi {
|
|||||||
*/
|
*/
|
||||||
getFilePlanRoles(filePlanId: string, parameters?: FilePlanRoleParameters): Promise<FilePlanRolePaging> {
|
getFilePlanRoles(filePlanId: string, parameters?: FilePlanRoleParameters): Promise<FilePlanRolePaging> {
|
||||||
throwIfNotDefined(filePlanId, 'filePlanId');
|
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({
|
return this.get({
|
||||||
path: '/file-plans/{filePlanId}/roles',
|
path: '/file-plans/{filePlanId}/roles',
|
||||||
pathParams: {
|
pathParams: {
|
||||||
filePlanId
|
filePlanId
|
||||||
},
|
},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
where: parameters?.where?.capabilityNames
|
where: whereConditions.length ? `(${whereConditions.join(' and ')})` : undefined
|
||||||
? `(capabilityName in (${parameters.where.capabilityNames.map((value) => "'" + value + "'").join(', ')}))`
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
## Properties
|
## Properties
|
||||||
| Name | Type |
|
| Name | Type |
|
||||||
|---------------------|----------|
|
|---------------------|----------|
|
||||||
|
| **personId** | string |
|
||||||
| **capabilityNames** | string[] |
|
| **capabilityNames** | string[] |
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,5 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export interface FilePlanRoleParametersWhere {
|
export interface FilePlanRoleParametersWhere {
|
||||||
|
personId?: string;
|
||||||
capabilityNames?: string[];
|
capabilityNames?: string[];
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,8 @@ describe('FilePlansApi', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getFilePlanRoles', () => {
|
describe('getFilePlanRoles', () => {
|
||||||
|
const filePlanId = 'filePlanId123';
|
||||||
|
|
||||||
let expectedRolePaging: FilePlanRolePaging;
|
let expectedRolePaging: FilePlanRolePaging;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -101,7 +103,6 @@ describe('FilePlansApi', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get file plan roles', (done) => {
|
it('should get file plan roles', (done) => {
|
||||||
const filePlanId = 'filePlanId123';
|
|
||||||
filePlansApiMock.get200FilePlanRoles(filePlanId);
|
filePlansApiMock.get200FilePlanRoles(filePlanId);
|
||||||
|
|
||||||
filePlansApi.getFilePlanRoles(filePlanId).then((rolePaging) => {
|
filePlansApi.getFilePlanRoles(filePlanId).then((rolePaging) => {
|
||||||
@@ -111,7 +112,6 @@ describe('FilePlansApi', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get file plan roles with filtering by capability names', (done) => {
|
it('should get file plan roles with filtering by capability names', (done) => {
|
||||||
const filePlanId = 'filePlanId123';
|
|
||||||
filePlansApiMock.get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId);
|
filePlansApiMock.get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId);
|
||||||
|
|
||||||
filePlansApi
|
filePlansApi
|
||||||
@@ -125,5 +125,36 @@ describe('FilePlansApi', () => {
|
|||||||
done();
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -21,21 +21,37 @@ import { FilePlanRolePaging } from '@alfresco/js-api';
|
|||||||
|
|
||||||
export class FilePlansMock extends BaseMock {
|
export class FilePlansMock extends BaseMock {
|
||||||
get200FilePlanRoles(filePlanId: string): void {
|
get200FilePlanRoles(filePlanId: string): void {
|
||||||
nock(this.host, { encodedQueryParams: true })
|
this.nock200FilePlanRoles(filePlanId).query({}).reply(200, this.mockFilePlanRolePaging());
|
||||||
.get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`)
|
|
||||||
.query({})
|
|
||||||
.reply(200, this.mockFilePlanRolePaging());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId: string): void {
|
get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId: string): void {
|
||||||
nock(this.host, { encodedQueryParams: true })
|
this.nock200FilePlanRoles(filePlanId)
|
||||||
.get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`)
|
|
||||||
.query({
|
.query({
|
||||||
where: "(capabilityName in ('capability1', 'capability2'))"
|
where: "(capabilityName in ('capability1', 'capability2'))"
|
||||||
})
|
})
|
||||||
.reply(200, this.mockFilePlanRolePaging());
|
.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 {
|
private mockFilePlanRolePaging(): FilePlanRolePaging {
|
||||||
return {
|
return {
|
||||||
list: {
|
list: {
|
||||||
|
Reference in New Issue
Block a user