mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-12288] add unit tests for environment aware logic
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { fakeEnvironmentList } from '../../common';
|
||||
import { ApplicationInstanceModel } from '../models/application-instance.model';
|
||||
|
||||
export const fakeApplicationInstance: ApplicationInstanceModel[] = [
|
||||
@@ -22,3 +23,9 @@ export const fakeApplicationInstance: ApplicationInstanceModel[] = [
|
||||
{ name: 'application-new-2', createdAt: '2018-09-21T12:31:39.000Z', status: 'Pending', theme: 'theme-2', icon: 'favorite_border' },
|
||||
{ name: 'application-new-3', createdAt: '2018-09-21T12:31:39.000Z', status: 'Pending' }
|
||||
];
|
||||
|
||||
export const fakeApplicationInstanceWithEnvironment: ApplicationInstanceModel[] = [
|
||||
{ name: 'application-new-1', environmentId: fakeEnvironmentList[0].id, createdAt: '2018-09-21T12:31:39.000Z', status: 'Running', theme: 'theme-2', icon: 'favorite_border' },
|
||||
{ name: 'application-new-2', environmentId: fakeEnvironmentList[1].id,createdAt: '2018-09-21T12:31:39.000Z', status: 'Pending', theme: 'theme-2', icon: 'favorite_border' },
|
||||
{ name: 'application-new-3', environmentId: fakeEnvironmentList[2].id,createdAt: '2018-09-21T12:31:39.000Z', status: 'Pending' }
|
||||
];
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { Environment } from '../interface/environment.interface';
|
||||
|
||||
export const fakeEnvironmentList: Environment[] = [
|
||||
{
|
||||
id: 'test-env-1',
|
||||
name: 'test-env-name-1'
|
||||
},
|
||||
{
|
||||
id: 'test-env-2',
|
||||
name: 'test-env-name-2'
|
||||
},
|
||||
{
|
||||
id: 'test-env-3',
|
||||
name: 'test-env-name-3'
|
||||
}
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './public-api';
|
||||
@@ -0,0 +1,19 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './date-range-filter.mock';
|
||||
export * from './environment.mock';
|
||||
@@ -16,3 +16,4 @@
|
||||
*/
|
||||
|
||||
export * from './interface/index';
|
||||
export * from './mock/index';
|
||||
|
||||
+11
-1
@@ -30,7 +30,7 @@ import { ProcessFiltersCloudModule } from '../process-filters-cloud.module';
|
||||
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
|
||||
import { ProcessFilterCloudService } from '../services/process-filter-cloud.service';
|
||||
import { AppsProcessCloudService } from '../../../app/services/apps-process-cloud.service';
|
||||
import { fakeApplicationInstance } from './../../../app/mock/app-model.mock';
|
||||
import { fakeApplicationInstance, fakeApplicationInstanceWithEnvironment } from './../../../app/mock/app-model.mock';
|
||||
import moment from 'moment';
|
||||
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
||||
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
|
||||
@@ -41,6 +41,7 @@ import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud.model';
|
||||
import { mockAppVersions } from '../mock/process-filters-cloud.mock';
|
||||
import { DATE_FORMAT_CLOUD } from '../../../models/date-format-cloud.model';
|
||||
import { fakeEnvironmentList } from '../../../common/mock/environment.mock';
|
||||
|
||||
describe('EditProcessFilterCloudComponent', () => {
|
||||
let component: EditProcessFilterCloudComponent;
|
||||
@@ -1161,4 +1162,13 @@ describe('EditProcessFilterCloudComponent', () => {
|
||||
expect(component.initiatorOptions).toEqual([{ username: 'user1' }, { username: 'user2' }]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add environment name to each application selector option label', () => {
|
||||
component.environmentList = fakeEnvironmentList;
|
||||
component.environmentId = fakeEnvironmentList[0].id;
|
||||
|
||||
getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment));
|
||||
component.getRunningApplications();
|
||||
expect(component.applicationNames[0].label).toBe('application-new-1 (test-env-name-1)');
|
||||
});
|
||||
});
|
||||
|
||||
+7
-5
@@ -65,9 +65,6 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
||||
@Input()
|
||||
id: string;
|
||||
|
||||
@Input()
|
||||
environmentId: string;
|
||||
|
||||
/** List of process filter properties to display */
|
||||
@Input()
|
||||
filterProperties = DEFAULT_PROCESS_FILTER_PROPERTIES;
|
||||
@@ -80,6 +77,11 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
||||
@Input()
|
||||
actions = DEFAULT_ACTIONS;
|
||||
|
||||
/** Environment ID of the application. */
|
||||
@Input()
|
||||
environmentId: string;
|
||||
|
||||
/** List of environments. */
|
||||
@Input()
|
||||
environmentList: Environment[] = [];
|
||||
|
||||
@@ -422,8 +424,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
|
||||
});
|
||||
}
|
||||
|
||||
private getEnvironmentName(environmentId: string) {
|
||||
return this.environmentList.find((env: any) => env['id'] === environmentId).name;
|
||||
private getEnvironmentName(environmentId: string): string {
|
||||
return this.environmentList.find((env: any) => env['id'] === environmentId)?.name;
|
||||
}
|
||||
|
||||
getProcessDefinitions() {
|
||||
|
||||
+4
-2
@@ -68,9 +68,11 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
@Input()
|
||||
id: string;
|
||||
|
||||
/** Environment ID of the application. */
|
||||
@Input()
|
||||
environmentId: string;
|
||||
|
||||
/** List of environments. */
|
||||
@Input()
|
||||
environmentList: Environment[] = [];
|
||||
|
||||
@@ -261,8 +263,8 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
});
|
||||
}
|
||||
|
||||
private getEnvironmentName(environmentId: string) {
|
||||
return this.environmentList.find((env: any) => env['id'] === environmentId).name;
|
||||
private getEnvironmentName(environmentId: string): string {
|
||||
return this.environmentList.find((env: any) => env['id'] === environmentId)?.name;
|
||||
}
|
||||
|
||||
getProcessDefinitions() {
|
||||
|
||||
+15
-1
@@ -26,7 +26,7 @@ import { TASK_FILTERS_SERVICE_TOKEN } from '../../../../services/cloud-token.ser
|
||||
import { LocalPreferenceCloudService } from '../../../../services/local-preference-cloud.service';
|
||||
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
|
||||
import { AppsProcessCloudService } from '../../../../app/services/apps-process-cloud.service';
|
||||
import { fakeApplicationInstance } from '../../../../app/mock/app-model.mock';
|
||||
import { fakeApplicationInstance, fakeApplicationInstanceWithEnvironment } from '../../../../app/mock/app-model.mock';
|
||||
import { TaskFiltersCloudModule } from '../../task-filters-cloud.module';
|
||||
import { ServiceTaskFilterCloudService } from '../../services/service-task-filter-cloud.service';
|
||||
import { TaskCloudService } from '../../../services/task-cloud.service';
|
||||
@@ -36,6 +36,8 @@ import { EditServiceTaskFilterCloudComponent } from './edit-service-task-filter-
|
||||
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
import { ProcessDefinitionCloud } from '../../../../models/process-definition-cloud.model';
|
||||
import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component';
|
||||
import { fakeEnvironmentList } from 'lib/process-services-cloud/src/lib/common/mock/environment.mock';
|
||||
import { mockApplicationTaskFilterProperties } from '../../mock/edit-task-filter-cloud.mock';
|
||||
|
||||
describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
let component: EditServiceTaskFilterCloudComponent;
|
||||
@@ -750,4 +752,16 @@ describe('EditServiceTaskFilterCloudComponent', () => {
|
||||
expect(restoreDefaultFiltersSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should add environment name to each application selector option label', () => {
|
||||
component.appName = fakeApplicationInstance[0].name;
|
||||
component.environmentList = fakeEnvironmentList;
|
||||
component.environmentId = fakeEnvironmentList[0].id;
|
||||
|
||||
getRunningApplicationsSpy.and.returnValue(of(fakeApplicationInstanceWithEnvironment));
|
||||
spyOn(component, 'createTaskFilterProperties').and.returnValue(mockApplicationTaskFilterProperties);
|
||||
|
||||
const filteredProperties = component.createAndFilterProperties();
|
||||
expect(filteredProperties[0].options[0].label).toBe('application-new-1 (test-env-name-1)');
|
||||
});
|
||||
});
|
||||
|
||||
+25
@@ -108,3 +108,28 @@ export const mockCreatedDateFilter = {
|
||||
to: '_createdTo'
|
||||
}
|
||||
};
|
||||
|
||||
export const mockApplicationsSelectorOptions = [
|
||||
{
|
||||
label: 'application-new-1 (test-env-name-1)',
|
||||
value: 'application-new-1'
|
||||
},
|
||||
{
|
||||
label: 'application-new-1 (test-env-name-1)',
|
||||
value: 'application-new-1'
|
||||
},
|
||||
{
|
||||
label: 'application-new-1 (test-env-name-1)',
|
||||
value: 'application-new-1'
|
||||
}
|
||||
];
|
||||
|
||||
export const mockApplicationTaskFilterProperties = [
|
||||
{
|
||||
label: 'test-label',
|
||||
type: 'select',
|
||||
key: 'appName',
|
||||
value: mockApplicationsSelectorOptions[0].value,
|
||||
options: mockApplicationsSelectorOptions
|
||||
}
|
||||
];
|
||||
|
||||
+1
@@ -89,6 +89,7 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent<ProcessLi
|
||||
@Input()
|
||||
name: string = '';
|
||||
|
||||
/** Filter the tasks to display only the ones with this environment ID. */
|
||||
@Input()
|
||||
environmentId: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user