@ieeesa-npm/tenants 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/ieeesa-npm-tenants.mjs +5 -0
- package/esm2022/lib/assets/constants.json +454 -0
- package/esm2022/lib/assets/tenant-validations.mjs +17 -0
- package/esm2022/lib/components/create-modify-group-type/create-modify-group-type.component.mjs +476 -0
- package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +279 -0
- package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +512 -0
- package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +391 -0
- package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +94 -0
- package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +733 -0
- package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +194 -0
- package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +335 -0
- package/esm2022/lib/models/app-type-config.model.mjs +2 -0
- package/esm2022/lib/models/app-type.model.mjs +7 -0
- package/esm2022/lib/models/create-group-type-config.model.mjs +22 -0
- package/esm2022/lib/models/create-group-type.model.mjs +2 -0
- package/esm2022/lib/models/feature-permission-id.model.mjs +8 -0
- package/esm2022/lib/models/features.model.mjs +2 -0
- package/esm2022/lib/models/permission-type.model.mjs +12 -0
- package/esm2022/lib/models/role-menu-action.model.mjs +7 -0
- package/esm2022/lib/models/role-type.model.mjs +2 -0
- package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +7 -0
- package/esm2022/lib/models/roles-and-permissions.model.mjs +2 -0
- package/esm2022/lib/models/route-config.model.mjs +2 -0
- package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +16 -0
- package/esm2022/lib/models/tenant-function-type.model.mjs +12 -0
- package/esm2022/lib/models/tenant.model.mjs +2 -0
- package/esm2022/lib/models/tenants-permission.model.mjs +2 -0
- package/esm2022/lib/models/update-tenant-status.model.mjs +2 -0
- package/esm2022/lib/models/view-tenant-group-types.model.mjs +11 -0
- package/esm2022/lib/services/tenant-applications.service.mjs +618 -0
- package/esm2022/lib/services/tenant-permissions-map.service.mjs +36 -0
- package/esm2022/lib/services/tenant-permissions.service.mjs +38 -0
- package/esm2022/lib/tenant-applications.component.mjs +14 -0
- package/esm2022/lib/tenant-applications.module.mjs +16 -0
- package/esm2022/public-api.mjs +36 -0
- package/fesm2022/ieeesa-npm-tenants.mjs +4233 -0
- package/fesm2022/ieeesa-npm-tenants.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/assets/tenant-validations.d.ts +15 -0
- package/lib/components/create-modify-group-type/create-modify-group-type.component.d.ts +129 -0
- package/lib/components/create-modify-role/create-modify-role.component.d.ts +103 -0
- package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +128 -0
- package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +106 -0
- package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +471 -0
- package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +223 -0
- package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +63 -0
- package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +134 -0
- package/lib/models/app-type-config.model.d.ts +14 -0
- package/lib/models/app-type.model.d.ts +4 -0
- package/lib/models/create-group-type-config.model.d.ts +16 -0
- package/lib/models/create-group-type.model.d.ts +49 -0
- package/lib/models/feature-permission-id.model.d.ts +4 -0
- package/lib/models/features.model.d.ts +15 -0
- package/lib/models/permission-type.model.d.ts +8 -0
- package/lib/models/role-menu-action.model.d.ts +4 -0
- package/lib/models/role-type.model.d.ts +27 -0
- package/lib/models/roles-and-permissions-table-type.model.d.ts +4 -0
- package/lib/models/roles-and-permissions.model.d.ts +119 -0
- package/lib/models/route-config.model.d.ts +4 -0
- package/lib/models/table-column-schema-view-tenant-list.model.d.ts +20 -0
- package/lib/models/tenant-function-type.model.d.ts +9 -0
- package/lib/models/tenant.model.d.ts +51 -0
- package/lib/models/tenants-permission.model.d.ts +9 -0
- package/lib/models/update-tenant-status.model.d.ts +14 -0
- package/lib/models/view-tenant-group-types.model.d.ts +29 -0
- package/lib/services/tenant-applications.service.d.ts +399 -0
- package/lib/services/tenant-permissions-map.service.d.ts +13 -0
- package/lib/services/tenant-permissions.service.d.ts +22 -0
- package/lib/tenant-applications.component.d.ts +5 -0
- package/lib/tenant-applications.module.d.ts +6 -0
- package/package.json +25 -12
- package/{src/public-api.ts → public-api.d.ts} +32 -40
- package/.eslintrc.json +0 -31
- package/ng-package.json +0 -8
- package/src/lib/assets/constants.json +0 -454
- package/src/lib/assets/tenant-validations.ts +0 -18
- package/src/lib/assets/tenants-mock.ts +0 -1240
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +0 -15
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +0 -44
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +0 -574
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +0 -602
- package/src/lib/components/create-modify-role/create-modify-role.component.html +0 -15
- package/src/lib/components/create-modify-role/create-modify-role.component.scss +0 -83
- package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +0 -346
- package/src/lib/components/create-modify-role/create-modify-role.component.ts +0 -321
- package/src/lib/components/create-tenant-application/create-tenant-application.component.html +0 -18
- package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +0 -73
- package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +0 -775
- package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +0 -638
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +0 -22
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +0 -79
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +0 -716
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +0 -504
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +0 -44
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +0 -16
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +0 -115
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +0 -109
- package/src/lib/components/view-tenant-details/view-tenant-details.component.html +0 -195
- package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +0 -163
- package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +0 -1221
- package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +0 -876
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +0 -10
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +0 -44
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +0 -410
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +0 -219
- package/src/lib/components/view-tenants-list/view-tenants-list.component.html +0 -32
- package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +0 -35
- package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +0 -464
- package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +0 -388
- package/src/lib/models/app-type-config.model.ts +0 -14
- package/src/lib/models/app-type.model.ts +0 -5
- package/src/lib/models/create-group-type-config.model.ts +0 -18
- package/src/lib/models/create-group-type.model.ts +0 -46
- package/src/lib/models/feature-permission-id.model.ts +0 -6
- package/src/lib/models/features.model.ts +0 -15
- package/src/lib/models/form-status.model.ts +0 -5
- package/src/lib/models/permission-type.model.ts +0 -9
- package/src/lib/models/role-menu-action.model.ts +0 -5
- package/src/lib/models/role-type.model.ts +0 -34
- package/src/lib/models/roles-and-permissions-table-type.model.ts +0 -5
- package/src/lib/models/roles-and-permissions.model.ts +0 -113
- package/src/lib/models/route-config.model.ts +0 -4
- package/src/lib/models/table-column-schema-view-tenant-list.model.ts +0 -21
- package/src/lib/models/tenant-function-type.model.ts +0 -10
- package/src/lib/models/tenant.model.ts +0 -47
- package/src/lib/models/tenants-permission.model.ts +0 -9
- package/src/lib/models/update-tenant-status.model.ts +0 -12
- package/src/lib/models/view-tenant-group-types.model.ts +0 -34
- package/src/lib/services/tenant-applications.service.spec.ts +0 -1245
- package/src/lib/services/tenant-applications.service.ts +0 -798
- package/src/lib/services/tenant-permissions-map.service.spec.ts +0 -25
- package/src/lib/services/tenant-permissions-map.service.ts +0 -28
- package/src/lib/services/tenant-permissions.service.spec.ts +0 -62
- package/src/lib/services/tenant-permissions.service.ts +0 -49
- package/src/lib/tenant-applications.component.html +0 -0
- package/src/lib/tenant-applications.component.scss +0 -0
- package/src/lib/tenant-applications.component.spec.ts +0 -28
- package/src/lib/tenant-applications.component.ts +0 -12
- package/src/lib/tenant-applications.module.ts +0 -8
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<ieeesa-dynamic-form
|
|
2
|
-
*ngIf="createGroupTypeFormGroup"
|
|
3
|
-
class="ieeesa-create-group-type-form"
|
|
4
|
-
[leftButtonLabel]="leftButtonLabel"
|
|
5
|
-
[rightButtonLabel]="rightButtonLabel"
|
|
6
|
-
[isLegendVisible]="false"
|
|
7
|
-
[colWidth]="colWidth"
|
|
8
|
-
[actionButtonAlign]="actionButtonAlign"
|
|
9
|
-
[formGroups]="createGroupTypeFormGroup"
|
|
10
|
-
[isLeftButtonNeeded]="true"
|
|
11
|
-
(formSubmit)="onCreateModifyGroupTypeFormSubmit($event)"
|
|
12
|
-
(formLeftButtonClicked)="onFormCancel()"
|
|
13
|
-
(formGroupsReference)="getCreateModifyGroupTypeFormGroupRef($event)"
|
|
14
|
-
(formCheckboxSelection)="onCheckboxSelectionChange($event)"
|
|
15
|
-
></ieeesa-dynamic-form>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
@import "styles.scss";
|
|
2
|
-
|
|
3
|
-
$ieeesa-desktop-width90: 90%;
|
|
4
|
-
$ieeesa-mobile-width: 100%;
|
|
5
|
-
.ieeesa-modal-dialog.ieeesa-create-modify-group-type {
|
|
6
|
-
width: 60vw !important;
|
|
7
|
-
.mat-mdc-dialog-container {
|
|
8
|
-
box-shadow: none;
|
|
9
|
-
}
|
|
10
|
-
.ieeesa-modal {
|
|
11
|
-
.mat-mdc-dialog-content {
|
|
12
|
-
padding: 1em !important;
|
|
13
|
-
}
|
|
14
|
-
.ieeesa-dynamic-form {
|
|
15
|
-
&__actions {
|
|
16
|
-
flex-direction: row-reverse;
|
|
17
|
-
gap: 0.5em;
|
|
18
|
-
}
|
|
19
|
-
&__form-field {
|
|
20
|
-
margin-bottom: 1em;
|
|
21
|
-
padding-top: 0px !important;
|
|
22
|
-
.ieeesa-text-area-field {
|
|
23
|
-
&__resize {
|
|
24
|
-
resize: vertical;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
.ieeesa-input-field {
|
|
31
|
-
width: 50%;
|
|
32
|
-
}
|
|
33
|
-
@media (max-width: $ieeesa-mobile-min-width) {
|
|
34
|
-
.ieeesa-dynamic-form {
|
|
35
|
-
&__form-field {
|
|
36
|
-
width: $ieeesa-mobile-width;
|
|
37
|
-
}
|
|
38
|
-
.ieeesa-input-field,
|
|
39
|
-
.mat-mdc-form-field-flex {
|
|
40
|
-
width: $ieeesa-mobile-width !important;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts
DELETED
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import {
|
|
3
|
-
HttpClient,
|
|
4
|
-
HttpErrorResponse,
|
|
5
|
-
HttpHandler,
|
|
6
|
-
} from '@angular/common/http';
|
|
7
|
-
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|
8
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
9
|
-
import {
|
|
10
|
-
FormBuilder,
|
|
11
|
-
FormGroup,
|
|
12
|
-
ReactiveFormsModule,
|
|
13
|
-
Validators,
|
|
14
|
-
} from '@angular/forms';
|
|
15
|
-
import {
|
|
16
|
-
MAT_DIALOG_DATA,
|
|
17
|
-
MatDialog,
|
|
18
|
-
MatDialogModule,
|
|
19
|
-
} from '@angular/material/dialog';
|
|
20
|
-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
21
|
-
import {
|
|
22
|
-
CheckboxOption,
|
|
23
|
-
DynamicFormComponent,
|
|
24
|
-
FormControlType,
|
|
25
|
-
FormModel,
|
|
26
|
-
} from '@ieeesa-npm/presentation';
|
|
27
|
-
import { SharedService } from '@ieeesa-npm/shared';
|
|
28
|
-
import {
|
|
29
|
-
GlobalErrorHandlerService,
|
|
30
|
-
AlertsService,
|
|
31
|
-
AlertType,
|
|
32
|
-
} from '@ieeesa-npm/utility';
|
|
33
|
-
import { GroupTypeValidation } from '@tenants/assets/tenant-validations';
|
|
34
|
-
import { TenantsMocks } from '@tenants/assets/tenants-mock';
|
|
35
|
-
import { TenantFunctionType } from '@tenants/models/tenant-function-type.model';
|
|
36
|
-
import { TenantApplicationsService } from '@tenants/services/tenant-applications.service';
|
|
37
|
-
import { CreateModifyGroupTypeComponent } from './create-modify-group-type.component';
|
|
38
|
-
import { Observable } from 'rxjs';
|
|
39
|
-
|
|
40
|
-
describe('CreateModifyGroupTypeComponent', () => {
|
|
41
|
-
let component: CreateModifyGroupTypeComponent;
|
|
42
|
-
let fixture: ComponentFixture<CreateModifyGroupTypeComponent>;
|
|
43
|
-
let tenantAppService: TenantApplicationsService;
|
|
44
|
-
let globalErrorHandlerService: GlobalErrorHandlerService;
|
|
45
|
-
const formBuilder: FormBuilder = new FormBuilder();
|
|
46
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
47
|
-
const mockFormGroup = formBuilder.group({
|
|
48
|
-
groupType: [
|
|
49
|
-
'Executive Subcommittee',
|
|
50
|
-
[
|
|
51
|
-
Validators.required,
|
|
52
|
-
Validators.maxLength(GroupTypeValidation.descriptionMaxLength),
|
|
53
|
-
],
|
|
54
|
-
],
|
|
55
|
-
description: [
|
|
56
|
-
'Executive Subcommittee description',
|
|
57
|
-
[
|
|
58
|
-
Validators.required,
|
|
59
|
-
Validators.maxLength(GroupTypeValidation.descriptionMaxLength),
|
|
60
|
-
],
|
|
61
|
-
],
|
|
62
|
-
rosterType: [
|
|
63
|
-
{ id: 1, label: 'Individual', checked: true },
|
|
64
|
-
[Validators.required],
|
|
65
|
-
],
|
|
66
|
-
settings: [
|
|
67
|
-
{ id: 1, name: 'Allow Sub-Groups', checked: false, disabled: false },
|
|
68
|
-
[Validators.required],
|
|
69
|
-
],
|
|
70
|
-
appOfficerRoles: [
|
|
71
|
-
{ id: '1', name: 'Chair', checked: false, disabled: false },
|
|
72
|
-
[Validators.required],
|
|
73
|
-
],
|
|
74
|
-
appMemberLevel: [
|
|
75
|
-
{
|
|
76
|
-
id: 1,
|
|
77
|
-
name: 'Voting Member (Principal)',
|
|
78
|
-
checked: false,
|
|
79
|
-
disabled: true,
|
|
80
|
-
},
|
|
81
|
-
[Validators.required],
|
|
82
|
-
],
|
|
83
|
-
isRootGroup: [{ id: 2, label: 'No', checked: true }, [Validators.required]],
|
|
84
|
-
});
|
|
85
|
-
const dialogOptions = {
|
|
86
|
-
heading: 'New Role',
|
|
87
|
-
isCloseNeeded: true,
|
|
88
|
-
componentReference: CreateModifyGroupTypeComponent,
|
|
89
|
-
modalType: 1,
|
|
90
|
-
};
|
|
91
|
-
const mockFormModel: FormModel = {
|
|
92
|
-
formGroup: [
|
|
93
|
-
{
|
|
94
|
-
legend: '',
|
|
95
|
-
controls: [
|
|
96
|
-
{
|
|
97
|
-
type: FormControlType.INPUT,
|
|
98
|
-
controlName: 'groupType',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
type: FormControlType.TEXT_AREA,
|
|
102
|
-
controlName: 'description',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type: FormControlType.RADIO,
|
|
106
|
-
controlName: 'rosterType',
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: FormControlType.CHECKBOX,
|
|
110
|
-
controlName: 'settings',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: FormControlType.CHECKBOX,
|
|
114
|
-
controlName: 'appOfficerRoles',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
type: FormControlType.CHECKBOX,
|
|
118
|
-
controlName: 'appMemberLevel',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
type: FormControlType.RADIO,
|
|
122
|
-
controlName: 'isRootGroup',
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
};
|
|
128
|
-
const mockTenantInfo = {
|
|
129
|
-
appId: 'testAppId',
|
|
130
|
-
appTitle: '',
|
|
131
|
-
appLogo: '',
|
|
132
|
-
appHeading: '',
|
|
133
|
-
appDescription: '',
|
|
134
|
-
status: true,
|
|
135
|
-
features: [
|
|
136
|
-
{
|
|
137
|
-
featureId: '',
|
|
138
|
-
featureName: '',
|
|
139
|
-
isDefault: false,
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
beforeEach(() => {
|
|
144
|
-
TestBed.configureTestingModule({
|
|
145
|
-
imports: [
|
|
146
|
-
CreateModifyGroupTypeComponent,
|
|
147
|
-
CommonModule,
|
|
148
|
-
DynamicFormComponent,
|
|
149
|
-
BrowserAnimationsModule,
|
|
150
|
-
ReactiveFormsModule,
|
|
151
|
-
HttpClientTestingModule,
|
|
152
|
-
MatDialogModule,
|
|
153
|
-
],
|
|
154
|
-
providers: [
|
|
155
|
-
TenantApplicationsService,
|
|
156
|
-
AlertsService,
|
|
157
|
-
{ provide: MAT_DIALOG_DATA, useValue: dialogOptions },
|
|
158
|
-
MatDialog,
|
|
159
|
-
SharedService,
|
|
160
|
-
HttpClient,
|
|
161
|
-
HttpHandler,
|
|
162
|
-
GlobalErrorHandlerService,
|
|
163
|
-
],
|
|
164
|
-
});
|
|
165
|
-
fixture = TestBed.createComponent(CreateModifyGroupTypeComponent);
|
|
166
|
-
component = fixture.componentInstance;
|
|
167
|
-
component.createGroupTypeFormGroup = mockFormModel;
|
|
168
|
-
component.ngOnInit();
|
|
169
|
-
tenantAppService = TestBed.inject(TenantApplicationsService);
|
|
170
|
-
globalErrorHandlerService = TestBed.inject(GlobalErrorHandlerService);
|
|
171
|
-
fixture.detectChanges();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should create', () => {
|
|
175
|
-
expect(component).toBeTruthy();
|
|
176
|
-
});
|
|
177
|
-
describe('#ngOnInit', () => {
|
|
178
|
-
it('should call getSelectedTenantInformation and set appId', () => {
|
|
179
|
-
spyOn(tenantAppService, 'getSelectedTenantInformation').and.returnValue(
|
|
180
|
-
mockTenantInfo
|
|
181
|
-
);
|
|
182
|
-
component.ngOnInit();
|
|
183
|
-
expect(tenantAppService.getSelectedTenantInformation).toHaveBeenCalled();
|
|
184
|
-
expect(component.appId).toBe('testAppId');
|
|
185
|
-
});
|
|
186
|
-
it('should call getTenantFunctionType and set tenantFunctionType', () => {
|
|
187
|
-
spyOn(tenantAppService, 'getTenantFunctionType').and.returnValue(
|
|
188
|
-
TenantFunctionType.CREATE_GROUP_TYPE
|
|
189
|
-
);
|
|
190
|
-
component.ngOnInit();
|
|
191
|
-
expect(tenantAppService.getTenantFunctionType).toHaveBeenCalled();
|
|
192
|
-
expect(component.tenantFunctionType).toBe(
|
|
193
|
-
TenantFunctionType.CREATE_GROUP_TYPE
|
|
194
|
-
);
|
|
195
|
-
});
|
|
196
|
-
it('should call getGroupTypeDetails and set allowedSubGroupTypesOptions', () => {
|
|
197
|
-
spyOn(tenantAppService, 'getGroupTypeDetails').and.returnValue(
|
|
198
|
-
TenantsMocks.mockGroupTypeResponse
|
|
199
|
-
);
|
|
200
|
-
component.ngOnInit();
|
|
201
|
-
expect(tenantAppService.getGroupTypeDetails).toHaveBeenCalled();
|
|
202
|
-
expect(component.allowedSubGroupTypesOptions.length).toBe(2);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
describe('#getRoles', () => {
|
|
206
|
-
it('should call getRoles to load the roles options.', () => {
|
|
207
|
-
const mockUserRoles = {
|
|
208
|
-
status: true,
|
|
209
|
-
message: 'SUCCESS',
|
|
210
|
-
body: [
|
|
211
|
-
{
|
|
212
|
-
roleId: 'ROLE_NESC_edaf1dcc-229f-4d4c-9635-7ac732b4dfd8',
|
|
213
|
-
roleName: 'Admin',
|
|
214
|
-
roleTypeName: 'System',
|
|
215
|
-
roleType: '11',
|
|
216
|
-
viewOrder: 1,
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
roleId: 'ROLE_NESC_cf32e87f-6d03-410f-8670-62fd11da1b44',
|
|
220
|
-
roleName: 'Chair',
|
|
221
|
-
roleTypeName: 'Officer',
|
|
222
|
-
roleType: '22',
|
|
223
|
-
viewOrder: 2,
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
roleId: 'ROLE_NESC_365dac5c-5558-4dad-9406-aa9063d0dbdf',
|
|
227
|
-
roleName: 'Past Chair',
|
|
228
|
-
roleTypeName: 'Officer',
|
|
229
|
-
roleType: '22',
|
|
230
|
-
viewOrder: 2,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
roleId: 'ROLE_NESC_46ea2d1a-8004-485f-b0bc-9237a5ae1eb2',
|
|
234
|
-
roleName: 'Vice Chair',
|
|
235
|
-
roleTypeName: 'Officer',
|
|
236
|
-
roleType: '22',
|
|
237
|
-
viewOrder: 2,
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
roleId: 'ROLE_NESC_68041ee9-3035-4136-9091-db42700a6204',
|
|
241
|
-
roleName: 'Secretory',
|
|
242
|
-
roleTypeName: 'Officer',
|
|
243
|
-
roleType: '22',
|
|
244
|
-
viewOrder: 2,
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
roleId: 'ROLE_NESC_0d0fde04-7bce-429b-af7e-b6ed5f9a2254',
|
|
248
|
-
roleName: 'Voting Member (Principal)',
|
|
249
|
-
roleTypeName: 'Member Level',
|
|
250
|
-
roleType: '33',
|
|
251
|
-
viewOrder: 3,
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
roleId: 'ROLE_NESC_4a3b1ef9-1696-46a1-b9a5-0404e0ac7733',
|
|
255
|
-
roleName: 'Voting Member (Alternate)',
|
|
256
|
-
roleTypeName: 'Member Level',
|
|
257
|
-
roleType: '33',
|
|
258
|
-
viewOrder: 3,
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
roleId: 'ROLE_NESC_3a805b6b-963e-432f-96bf-7797ec7d6eb6',
|
|
262
|
-
roleName: 'Member',
|
|
263
|
-
roleTypeName: 'Member Level',
|
|
264
|
-
roleType: '33',
|
|
265
|
-
viewOrder: 3,
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
};
|
|
269
|
-
spyOn(tenantAppService, 'getRoles').and.returnValue(
|
|
270
|
-
new Observable((subscriber) => {
|
|
271
|
-
subscriber.next(mockUserRoles);
|
|
272
|
-
})
|
|
273
|
-
);
|
|
274
|
-
spyOn(
|
|
275
|
-
component['formUtilityService'],
|
|
276
|
-
'updateFormControlOptions'
|
|
277
|
-
).and.callThrough();
|
|
278
|
-
spyOn(component, 'initializeCreateGroupTypeFormGroup');
|
|
279
|
-
component.getRoles();
|
|
280
|
-
expect(tenantAppService.getRoles).toHaveBeenCalledWith(component.appId);
|
|
281
|
-
expect(component.initializeCreateGroupTypeFormGroup).toHaveBeenCalled();
|
|
282
|
-
expect(component.officerRolesOptions).toEqual(
|
|
283
|
-
TenantsMocks.mockOfficerRoles
|
|
284
|
-
);
|
|
285
|
-
});
|
|
286
|
-
it('should return 3007 error code when fail to load the roles options.', () => {
|
|
287
|
-
const errorResponse = TenantsMocks.mockRolesErrorResponse;
|
|
288
|
-
spyOn(tenantAppService, 'getRoles').and.returnValue(
|
|
289
|
-
new Observable((subscriber) => {
|
|
290
|
-
subscriber.error(errorResponse);
|
|
291
|
-
})
|
|
292
|
-
);
|
|
293
|
-
spyOn(
|
|
294
|
-
component['formUtilityService'],
|
|
295
|
-
'updateFormControlOptions'
|
|
296
|
-
).and.callThrough();
|
|
297
|
-
spyOn(component['sharedService'], 'handleErrors').and.callThrough();
|
|
298
|
-
component.getRoles();
|
|
299
|
-
expect(component.officerRolesOptions).toEqual([]);
|
|
300
|
-
expect(
|
|
301
|
-
component['formUtilityService'].updateFormControlOptions
|
|
302
|
-
).not.toHaveBeenCalled();
|
|
303
|
-
expect(component['sharedService'].handleErrors).toHaveBeenCalledWith(
|
|
304
|
-
errorResponse,
|
|
305
|
-
component?.createGroupTypeScreenTexts?.errors
|
|
306
|
-
);
|
|
307
|
-
});
|
|
308
|
-
it('should return 3019 error code when fail to load the roles options.', () => {
|
|
309
|
-
const mockUserRoles = {
|
|
310
|
-
status: true,
|
|
311
|
-
message: 'SUCCESS',
|
|
312
|
-
body: [
|
|
313
|
-
{
|
|
314
|
-
roleId: 'ROLE_NESC_edaf1dcc-229f-4d4c-9635-7ac732b4dfd8',
|
|
315
|
-
roleName: 'Admin',
|
|
316
|
-
roleTypeName: 'System',
|
|
317
|
-
roleType: '11',
|
|
318
|
-
viewOrder: 1,
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
};
|
|
322
|
-
component.memberLevelOptions = [];
|
|
323
|
-
component.officerRolesOptions = [];
|
|
324
|
-
spyOn(tenantAppService, 'getRoles').and.returnValue(
|
|
325
|
-
new Observable((subscriber) => {
|
|
326
|
-
subscriber.next(mockUserRoles);
|
|
327
|
-
})
|
|
328
|
-
);
|
|
329
|
-
spyOn(component['sharedService'], 'showAlertMessage').and.callThrough();
|
|
330
|
-
component.getRoles();
|
|
331
|
-
expect(component.officerRolesOptions).toEqual([]);
|
|
332
|
-
expect(component.memberLevelOptions).toEqual([]);
|
|
333
|
-
expect(component['sharedService'].showAlertMessage).toHaveBeenCalledWith(
|
|
334
|
-
AlertType.ERROR,
|
|
335
|
-
component?.createGroupTypeScreenTexts?.errors['3019']
|
|
336
|
-
);
|
|
337
|
-
});
|
|
338
|
-
it('should throw error in retrieving roles', () => {
|
|
339
|
-
const mockServerErrorResponse = new HttpErrorResponse({
|
|
340
|
-
error: 'test',
|
|
341
|
-
});
|
|
342
|
-
spyOn(tenantAppService, 'getRoles').and.returnValue(
|
|
343
|
-
new Observable((subscriber) => {
|
|
344
|
-
subscriber.error(mockServerErrorResponse);
|
|
345
|
-
})
|
|
346
|
-
);
|
|
347
|
-
spyOn(globalErrorHandlerService, 'handleError');
|
|
348
|
-
component.getRoles();
|
|
349
|
-
expect(globalErrorHandlerService.handleError).toHaveBeenCalledWith(
|
|
350
|
-
mockServerErrorResponse
|
|
351
|
-
);
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
describe('#getRosterTypes', () => {
|
|
355
|
-
it('should call getRosterTypes to load the roster types options.', () => {
|
|
356
|
-
spyOn(tenantAppService, 'getRosterType').and.returnValue(
|
|
357
|
-
new Observable((subscriber) => {
|
|
358
|
-
subscriber.next(TenantsMocks.mockRosterTypeResponse);
|
|
359
|
-
})
|
|
360
|
-
);
|
|
361
|
-
const getSettingsSpyOn = spyOn(component, 'getSettings');
|
|
362
|
-
component.rosterTypeOptions = [];
|
|
363
|
-
component.getRosterTypes();
|
|
364
|
-
expect(getSettingsSpyOn).toHaveBeenCalled();
|
|
365
|
-
expect(tenantAppService.getRosterType).toHaveBeenCalled();
|
|
366
|
-
expect(component.rosterTypeOptions).toEqual(TenantsMocks.mockRosterType);
|
|
367
|
-
});
|
|
368
|
-
it('should return 2066 error code when fail to get the roster type options.', () => {
|
|
369
|
-
const errorResponse = TenantsMocks.mockRosterOrGroupTypeErrorResponse;
|
|
370
|
-
spyOn(tenantAppService, 'getRosterType').and.returnValue(
|
|
371
|
-
new Observable((subscriber) => {
|
|
372
|
-
subscriber.error(errorResponse);
|
|
373
|
-
})
|
|
374
|
-
);
|
|
375
|
-
spyOn(component['sharedService'], 'handleErrors').and.callThrough();
|
|
376
|
-
component.getRosterTypes();
|
|
377
|
-
expect(component['sharedService'].handleErrors).toHaveBeenCalledWith(
|
|
378
|
-
errorResponse,
|
|
379
|
-
component?.createGroupTypeScreenTexts?.errors
|
|
380
|
-
);
|
|
381
|
-
});
|
|
382
|
-
it('should throw error in retrieving roster type options', () => {
|
|
383
|
-
const mockServerErrorResponse = new HttpErrorResponse({
|
|
384
|
-
error: 'test',
|
|
385
|
-
});
|
|
386
|
-
spyOn(tenantAppService, 'getRosterType').and.returnValue(
|
|
387
|
-
new Observable((subscriber) => {
|
|
388
|
-
subscriber.error(mockServerErrorResponse);
|
|
389
|
-
})
|
|
390
|
-
);
|
|
391
|
-
spyOn(globalErrorHandlerService, 'handleError');
|
|
392
|
-
component.getRosterTypes();
|
|
393
|
-
expect(globalErrorHandlerService.handleError).toHaveBeenCalledWith(
|
|
394
|
-
mockServerErrorResponse
|
|
395
|
-
);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
describe('#getSettings', () => {
|
|
399
|
-
it('should call getSettings to load the settings options.', () => {
|
|
400
|
-
spyOn(tenantAppService, 'getGroupTypeSettings').and.returnValue(
|
|
401
|
-
new Observable((subscriber) => {
|
|
402
|
-
subscriber.next(TenantsMocks.mockGroupTypeSettingResponse);
|
|
403
|
-
})
|
|
404
|
-
);
|
|
405
|
-
component.settingOptions = [];
|
|
406
|
-
component.getSettings();
|
|
407
|
-
expect(tenantAppService.getGroupTypeSettings).toHaveBeenCalled();
|
|
408
|
-
expect(component.settingOptions).toEqual(TenantsMocks.mockSettingOptions);
|
|
409
|
-
});
|
|
410
|
-
it('should return 2066 error code when fail to get the settings options.', () => {
|
|
411
|
-
const errorResponse = TenantsMocks.mockRosterOrGroupTypeErrorResponse;
|
|
412
|
-
spyOn(tenantAppService, 'getGroupTypeSettings').and.returnValue(
|
|
413
|
-
new Observable((subscriber) => {
|
|
414
|
-
subscriber.error(errorResponse);
|
|
415
|
-
})
|
|
416
|
-
);
|
|
417
|
-
spyOn(component['sharedService'], 'handleErrors').and.callThrough();
|
|
418
|
-
component.getSettings();
|
|
419
|
-
expect(component['sharedService'].handleErrors).toHaveBeenCalledWith(
|
|
420
|
-
errorResponse,
|
|
421
|
-
component?.createGroupTypeScreenTexts?.errors
|
|
422
|
-
);
|
|
423
|
-
});
|
|
424
|
-
it('should throw error in retrieving settings options', () => {
|
|
425
|
-
const mockServerErrorResponse = new HttpErrorResponse({
|
|
426
|
-
error: 'test',
|
|
427
|
-
});
|
|
428
|
-
spyOn(tenantAppService, 'getGroupTypeSettings').and.returnValue(
|
|
429
|
-
new Observable((subscriber) => {
|
|
430
|
-
subscriber.error(mockServerErrorResponse);
|
|
431
|
-
})
|
|
432
|
-
);
|
|
433
|
-
spyOn(globalErrorHandlerService, 'handleError');
|
|
434
|
-
component.getSettings();
|
|
435
|
-
expect(globalErrorHandlerService.handleError).toHaveBeenCalledWith(
|
|
436
|
-
mockServerErrorResponse
|
|
437
|
-
);
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
describe('#initializeCreateGroupTypeFormGroup', () => {
|
|
441
|
-
it('should initialize the form group by default values', () => {
|
|
442
|
-
component.rosterTypeOptions = TenantsMocks.mockRosterTypeOptions;
|
|
443
|
-
component.isRootGroupOptions = TenantsMocks.mockIsRootGroupOptions;
|
|
444
|
-
component.initializeCreateGroupTypeFormGroup();
|
|
445
|
-
expect(component.createGroupTypeFormGroup).toBeTruthy();
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
describe('#onCheckboxSelectionChange', () => {
|
|
449
|
-
it('should add new form control when ALLOW_SUB_GROUPS is selected', () => {
|
|
450
|
-
const selectedCheckbox: CheckboxOption = {
|
|
451
|
-
id: 1,
|
|
452
|
-
name: 'Allow Sub-Groups',
|
|
453
|
-
checked: true,
|
|
454
|
-
disabled: false,
|
|
455
|
-
};
|
|
456
|
-
const addNewControlDynamicallySpy = spyOn(
|
|
457
|
-
component['formUtilityService'],
|
|
458
|
-
'addFormControl'
|
|
459
|
-
);
|
|
460
|
-
component.onCheckboxSelectionChange(selectedCheckbox);
|
|
461
|
-
expect(addNewControlDynamicallySpy).toHaveBeenCalled();
|
|
462
|
-
});
|
|
463
|
-
it('should remove the allowSubGroup form control when ALLOW_SUB_GROUPS is unselected', () => {
|
|
464
|
-
const selectedCheckbox: CheckboxOption = {
|
|
465
|
-
id: 1,
|
|
466
|
-
name: 'Allow Sub-Groups',
|
|
467
|
-
checked: false,
|
|
468
|
-
disabled: false,
|
|
469
|
-
};
|
|
470
|
-
const removeControlDynamicallySpy = spyOn(
|
|
471
|
-
component['formUtilityService'],
|
|
472
|
-
'removeFormControl'
|
|
473
|
-
);
|
|
474
|
-
component.allowedSubGroupTypesOptions = TenantsMocks.mockSettingOptions;
|
|
475
|
-
component.onCheckboxSelectionChange(selectedCheckbox);
|
|
476
|
-
expect(removeControlDynamicallySpy).toHaveBeenCalled();
|
|
477
|
-
expect(component.allowedSubGroupTypesOptions).toEqual(
|
|
478
|
-
TenantsMocks.mockSettingOptions
|
|
479
|
-
);
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
describe('#isSettingSelectedByName', () => {
|
|
483
|
-
it('should find the setting option', () => {
|
|
484
|
-
component.settingOptions = JSON.parse(
|
|
485
|
-
JSON.stringify(TenantsMocks.mockSettingOptions)
|
|
486
|
-
);
|
|
487
|
-
component.settingOptions[3].checked = true;
|
|
488
|
-
expect(component.isSettingSelectedByName('Has Classification')).toEqual(
|
|
489
|
-
true
|
|
490
|
-
);
|
|
491
|
-
expect(component.isSettingSelectedByName('Enable Rosters')).toEqual(
|
|
492
|
-
false
|
|
493
|
-
);
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
describe('#getCreateModifyGroupTypeFormGroupRef', () => {
|
|
497
|
-
it('should set createModifyGroupTypeFormGroupRef to the first form in the array', () => {
|
|
498
|
-
const formGroup1 = new FormGroup({});
|
|
499
|
-
const formGroup2 = new FormGroup({});
|
|
500
|
-
const formsArray: FormGroup[] = [formGroup1, formGroup2];
|
|
501
|
-
component.getCreateModifyGroupTypeFormGroupRef(formsArray);
|
|
502
|
-
expect(component.createModifyGroupTypeFormGroupRef).toBe(formGroup1);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
describe('#onCreateModifyGroupTypeFormSubmit', () => {
|
|
506
|
-
it('should call createGroupType API call if form is valid', () => {
|
|
507
|
-
const form = [component.createModifyGroupTypeFormGroupRef];
|
|
508
|
-
spyOn(form[0], 'markAllAsTouched');
|
|
509
|
-
component.allowedSubGroupTypesOptions = JSON.parse(
|
|
510
|
-
JSON.stringify(TenantsMocks.mockAllowedSubGroupTypes)
|
|
511
|
-
);
|
|
512
|
-
component.allowedSubGroupTypesOptions[0].checked = true;
|
|
513
|
-
component.memberLevelOptions = JSON.parse(
|
|
514
|
-
JSON.stringify(TenantsMocks.mockMemberLevel)
|
|
515
|
-
);
|
|
516
|
-
component.officerRolesOptions = JSON.parse(
|
|
517
|
-
JSON.stringify(TenantsMocks.mockOfficerRoles)
|
|
518
|
-
);
|
|
519
|
-
component.memberLevelOptions[0].checked = true;
|
|
520
|
-
component.officerRolesOptions[0].checked = true;
|
|
521
|
-
spyOn(tenantAppService, 'createGroupType').and.returnValue(
|
|
522
|
-
new Observable((subscriber) => {
|
|
523
|
-
subscriber.next(TenantsMocks.mockCreateGroupTypeSuccessResponse);
|
|
524
|
-
})
|
|
525
|
-
);
|
|
526
|
-
const submitFormResponseSpyOn = spyOn(
|
|
527
|
-
component.submitFormResponse,
|
|
528
|
-
'emit'
|
|
529
|
-
);
|
|
530
|
-
const setNewlyCreatedGroupTypeInfoSpyOn = spyOn(
|
|
531
|
-
component['tenantAppService'],
|
|
532
|
-
'setNewlyCreatedGroupTypeInfo'
|
|
533
|
-
);
|
|
534
|
-
component.onCreateModifyGroupTypeFormSubmit(form);
|
|
535
|
-
expect(submitFormResponseSpyOn).toHaveBeenCalled();
|
|
536
|
-
expect(form[0].markAllAsTouched).toHaveBeenCalled();
|
|
537
|
-
expect(setNewlyCreatedGroupTypeInfoSpyOn).toHaveBeenCalled();
|
|
538
|
-
});
|
|
539
|
-
it('should throw error when fail to create group type.', () => {
|
|
540
|
-
const mockServerErrorResponse = new HttpErrorResponse({
|
|
541
|
-
error: 'test',
|
|
542
|
-
});
|
|
543
|
-
spyOn(tenantAppService, 'createGroupType').and.returnValue(
|
|
544
|
-
new Observable((subscriber) => {
|
|
545
|
-
subscriber.error(mockServerErrorResponse);
|
|
546
|
-
})
|
|
547
|
-
);
|
|
548
|
-
spyOn(component['sharedService'], 'handleErrors').and.callThrough();
|
|
549
|
-
component.onCreateModifyGroupTypeFormSubmit([
|
|
550
|
-
component.createModifyGroupTypeFormGroupRef,
|
|
551
|
-
]);
|
|
552
|
-
expect(component['sharedService'].handleErrors).toHaveBeenCalled();
|
|
553
|
-
});
|
|
554
|
-
});
|
|
555
|
-
describe('#onFormCancel', () => {
|
|
556
|
-
it('should emit formCancel event', () => {
|
|
557
|
-
const formCancelEmitSpy = spyOn(
|
|
558
|
-
component.formCancel,
|
|
559
|
-
'emit'
|
|
560
|
-
).and.callThrough();
|
|
561
|
-
component.onFormCancel();
|
|
562
|
-
expect(formCancelEmitSpy).toHaveBeenCalled();
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
describe('#ngOnDestroy', () => {
|
|
566
|
-
it('should unsubscribe on ngOnDestroy', () => {
|
|
567
|
-
spyOn(component.destroy$, 'next');
|
|
568
|
-
spyOn(component.destroy$, 'unsubscribe');
|
|
569
|
-
component.ngOnDestroy();
|
|
570
|
-
expect(component.destroy$.next).toHaveBeenCalledWith(true);
|
|
571
|
-
expect(component.destroy$.unsubscribe).toHaveBeenCalled();
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
});
|