/*! * @license * Copyright © 2005-2026 Hyland Software, Inc. and its affiliates. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { EcmAuthMock, FilePlansMock } from '../mockObjects'; import { resetGlobalMockAgent } from '../mockObjects/base.mock'; import { AlfrescoApi, FilePlanRolePaging, FilePlansApi } from '../../src'; import assert from 'assert'; import { describe, it, beforeEach, afterEach } from 'node:test'; describe('FilePlansApi', () => { let filePlansApiMock: FilePlansMock; let filePlansApi: FilePlansApi; beforeEach(async () => { const hostEcm = 'https://127.0.0.1:8080'; const authResponseMock = new EcmAuthMock(hostEcm); authResponseMock.get201Response(); filePlansApiMock = new FilePlansMock(hostEcm); const alfrescoApi = new AlfrescoApi({ hostEcm }); filePlansApi = new FilePlansApi(alfrescoApi); await alfrescoApi.login('admin', 'admin'); }); afterEach(() => { resetGlobalMockAgent(); }); describe('getFilePlanRoles', () => { const filePlanId = 'filePlanId123'; let expectedRolePaging: FilePlanRolePaging; beforeEach(() => { expectedRolePaging = { list: { pagination: { count: 2, hasMoreItems: false, totalItems: 2, skipCount: 0, maxItems: 100 }, entries: [ { entry: { displayLabel: 'Role One', groupShortName: 'group short name 1', name: 'role1', roleGroupName: 'role group name 1', capabilities: [ { index: 0, name: 'capability1', title: 'Capability One', group: { id: 'group1', title: 'Group One' } }, { index: 1, name: 'capability2', title: 'Capability Two', group: { id: 'group2', title: 'Group Two' } } ] } }, { entry: { displayLabel: 'Role Two', groupShortName: 'group short name 2', name: 'role2', roleGroupName: 'role group name 2', capabilities: [ { index: 0, name: 'capability3', title: 'Capability Three', group: { id: 'group3', title: 'Group Three' } } ] } } ] } }; }); it('should get file plan roles', async () => { filePlansApiMock.get200FilePlanRoles(filePlanId); const rolePaging = await filePlansApi.getFilePlanRoles(filePlanId); assert.deepStrictEqual(rolePaging, expectedRolePaging); }); it('should get file plan roles with filtering by capability names', async () => { filePlansApiMock.get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId); const rolePaging = await filePlansApi.getFilePlanRoles(filePlanId, { where: { capabilityNames: ['capability1', 'capability2'] } }); assert.deepStrictEqual(rolePaging, expectedRolePaging); }); it('should get file plan roles with filtering by person id', async () => { filePlansApiMock.get200FilePlanRolesWithFilteringByPersonId(filePlanId); const rolePaging = await filePlansApi.getFilePlanRoles(filePlanId, { where: { personId: 'someUser' } }); assert.deepStrictEqual(rolePaging, expectedRolePaging); }); it('should get file plan roles with filtering by capability names', async () => { filePlansApiMock.get200FilePlanRolesWithFilteringByPersonIdAndCapabilityNames(filePlanId); const rolePaging = await filePlansApi.getFilePlanRoles(filePlanId, { where: { personId: 'someUser', capabilityNames: ['capability1', 'capability2'] } }); assert.deepStrictEqual(rolePaging, expectedRolePaging); }); }); });