@ieeesa-npm/tenants 0.4.2 → 0.4.4
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/.eslintrc.json +31 -0
- package/ng-package.json +8 -0
- package/package.json +12 -25
- package/src/lib/assets/constants.json +454 -0
- package/src/lib/assets/tenant-validations.ts +18 -0
- package/src/lib/assets/tenants-mock.ts +1240 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.html +15 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.scss +44 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.spec.ts +574 -0
- package/src/lib/components/create-modify-group-type/create-modify-group-type.component.ts +602 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.html +15 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.scss +83 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.spec.ts +346 -0
- package/src/lib/components/create-modify-role/create-modify-role.component.ts +321 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.html +18 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.scss +73 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.spec.ts +775 -0
- package/src/lib/components/create-tenant-application/create-tenant-application.component.ts +638 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.html +22 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.scss +79 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.spec.ts +716 -0
- package/src/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.ts +504 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.html +44 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.scss +16 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.spec.ts +115 -0
- package/src/lib/components/tenant-basic-details/tenant-basic-details.component.ts +109 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.html +195 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.scss +163 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.spec.ts +1221 -0
- package/src/lib/components/view-tenant-details/view-tenant-details.component.ts +876 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.html +10 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.scss +44 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.spec.ts +410 -0
- package/src/lib/components/view-tenant-group-types/view-tenant-group-types.component.ts +219 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.html +32 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.scss +35 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.spec.ts +464 -0
- package/src/lib/components/view-tenants-list/view-tenants-list.component.ts +388 -0
- package/src/lib/models/app-type-config.model.ts +14 -0
- package/src/lib/models/app-type.model.ts +5 -0
- package/src/lib/models/create-group-type-config.model.ts +18 -0
- package/src/lib/models/create-group-type.model.ts +46 -0
- package/src/lib/models/feature-permission-id.model.ts +6 -0
- package/src/lib/models/features.model.ts +15 -0
- package/src/lib/models/form-status.model.ts +5 -0
- package/src/lib/models/permission-type.model.ts +9 -0
- package/src/lib/models/role-menu-action.model.ts +5 -0
- package/src/lib/models/role-type.model.ts +34 -0
- package/src/lib/models/roles-and-permissions-table-type.model.ts +5 -0
- package/src/lib/models/roles-and-permissions.model.ts +113 -0
- package/src/lib/models/route-config.model.ts +4 -0
- package/src/lib/models/table-column-schema-view-tenant-list.model.ts +21 -0
- package/src/lib/models/tenant-function-type.model.ts +10 -0
- package/src/lib/models/tenant.model.ts +47 -0
- package/src/lib/models/tenants-permission.model.ts +9 -0
- package/src/lib/models/update-tenant-status.model.ts +12 -0
- package/src/lib/models/view-tenant-group-types.model.ts +34 -0
- package/src/lib/services/tenant-applications.service.spec.ts +1245 -0
- package/src/lib/services/tenant-applications.service.ts +798 -0
- package/src/lib/services/tenant-permissions-map.service.spec.ts +25 -0
- package/src/lib/services/tenant-permissions-map.service.ts +28 -0
- package/src/lib/services/tenant-permissions.service.spec.ts +62 -0
- package/src/lib/services/tenant-permissions.service.ts +49 -0
- 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 +28 -0
- package/src/lib/tenant-applications.component.ts +12 -0
- package/src/lib/tenant-applications.module.ts +8 -0
- package/{public-api.d.ts → src/public-api.ts} +40 -30
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/ieeesa-npm-tenants.mjs +0 -5
- package/esm2022/lib/assets/constants.json +0 -390
- package/esm2022/lib/assets/tenant-validations.mjs +0 -13
- package/esm2022/lib/components/create-modify-role/create-modify-role.component.mjs +0 -280
- package/esm2022/lib/components/create-tenant-application/create-tenant-application.component.mjs +0 -512
- package/esm2022/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.mjs +0 -391
- package/esm2022/lib/components/tenant-basic-details/tenant-basic-details.component.mjs +0 -95
- package/esm2022/lib/components/view-tenant-details/view-tenant-details.component.mjs +0 -708
- package/esm2022/lib/components/view-tenant-group-types/view-tenant-group-types.component.mjs +0 -174
- package/esm2022/lib/components/view-tenants-list/view-tenants-list.component.mjs +0 -334
- package/esm2022/lib/models/app-type-config.model.mjs +0 -2
- package/esm2022/lib/models/app-type.model.mjs +0 -7
- package/esm2022/lib/models/feature-permission-id.model.mjs +0 -8
- package/esm2022/lib/models/features.model.mjs +0 -2
- package/esm2022/lib/models/form-status.model.mjs +0 -7
- package/esm2022/lib/models/permission-type.model.mjs +0 -12
- package/esm2022/lib/models/role-menu-action.model.mjs +0 -7
- package/esm2022/lib/models/role-type.model.mjs +0 -2
- package/esm2022/lib/models/roles-and-permissions-table-type.model.mjs +0 -7
- package/esm2022/lib/models/roles-and-permissions.model.mjs +0 -2
- package/esm2022/lib/models/route-config.model.mjs +0 -2
- package/esm2022/lib/models/table-column-schema-view-tenant-list.model.mjs +0 -16
- package/esm2022/lib/models/tenant-function-type.model.mjs +0 -10
- package/esm2022/lib/models/tenant.model.mjs +0 -2
- package/esm2022/lib/models/tenants-permission.model.mjs +0 -2
- package/esm2022/lib/models/update-tenant-status.model.mjs +0 -2
- package/esm2022/lib/models/view-tenant-group-types.model.mjs +0 -9
- package/esm2022/lib/services/tenant-applications.service.mjs +0 -542
- package/esm2022/lib/services/tenant-permissions-map.service.mjs +0 -36
- package/esm2022/lib/services/tenant-permissions.service.mjs +0 -38
- package/esm2022/lib/tenant-applications.component.mjs +0 -14
- package/esm2022/lib/tenant-applications.module.mjs +0 -16
- package/esm2022/public-api.mjs +0 -34
- package/fesm2022/ieeesa-npm-tenants.mjs +0 -3565
- package/fesm2022/ieeesa-npm-tenants.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/assets/tenant-validations.d.ts +0 -11
- package/lib/components/create-modify-role/create-modify-role.component.d.ts +0 -103
- package/lib/components/create-tenant-application/create-tenant-application.component.d.ts +0 -128
- package/lib/components/roles-and-permissions-mapping/roles-and-permissions-mapping.component.d.ts +0 -106
- package/lib/components/tenant-basic-details/tenant-basic-details.component.d.ts +0 -408
- package/lib/components/view-tenant-details/view-tenant-details.component.d.ts +0 -216
- package/lib/components/view-tenant-group-types/view-tenant-group-types.component.d.ts +0 -58
- package/lib/components/view-tenants-list/view-tenants-list.component.d.ts +0 -134
- package/lib/models/app-type-config.model.d.ts +0 -14
- package/lib/models/app-type.model.d.ts +0 -4
- package/lib/models/feature-permission-id.model.d.ts +0 -4
- package/lib/models/features.model.d.ts +0 -15
- package/lib/models/form-status.model.d.ts +0 -4
- package/lib/models/permission-type.model.d.ts +0 -8
- package/lib/models/role-menu-action.model.d.ts +0 -4
- package/lib/models/role-type.model.d.ts +0 -27
- package/lib/models/roles-and-permissions-table-type.model.d.ts +0 -4
- package/lib/models/roles-and-permissions.model.d.ts +0 -119
- package/lib/models/route-config.model.d.ts +0 -4
- package/lib/models/table-column-schema-view-tenant-list.model.d.ts +0 -20
- package/lib/models/tenant-function-type.model.d.ts +0 -7
- package/lib/models/tenant.model.d.ts +0 -51
- package/lib/models/tenants-permission.model.d.ts +0 -9
- package/lib/models/update-tenant-status.model.d.ts +0 -14
- package/lib/models/view-tenant-group-types.model.d.ts +0 -27
- package/lib/services/tenant-applications.service.d.ts +0 -357
- package/lib/services/tenant-permissions-map.service.d.ts +0 -13
- package/lib/services/tenant-permissions.service.d.ts +0 -22
- package/lib/tenant-applications.component.d.ts +0 -5
- package/lib/tenant-applications.module.d.ts +0 -6
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class="ieeesa-view-tenants-list"
|
|
3
|
+
[ngClass]="{ 'ieeesa-view-tenants-list__mobile': isMobileView }"
|
|
4
|
+
>
|
|
5
|
+
<p class="ieeesa-headline-lg-32 py-3 mb-0">
|
|
6
|
+
{{ tenantsPageInfo.tenantsTitle }}
|
|
7
|
+
</p>
|
|
8
|
+
<div class="ieeesa-view-tenants-list__content">
|
|
9
|
+
<div class="d-flex justify-content-end">
|
|
10
|
+
<button
|
|
11
|
+
mat-button
|
|
12
|
+
class="mat-tertiary-button me-3"
|
|
13
|
+
[attr.aria-label]="viewTenantsConstants?.ariaLabel?.add"
|
|
14
|
+
(click)="openCreateTenantForm()"
|
|
15
|
+
*ngIf="validateAccess(permissionType.MANAGE_TENANT)"
|
|
16
|
+
>
|
|
17
|
+
{{ viewTenantsConstants?.addTenant }}
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
<ieeesa-data-table
|
|
21
|
+
[tableDataInfo]="tableData"
|
|
22
|
+
[columnSchemaInfo]="columnSchema"
|
|
23
|
+
[isCellTextOverflowEllipsis]="true"
|
|
24
|
+
[tableActions]="tableActions"
|
|
25
|
+
[paginatorConfig]="paginatorConfig"
|
|
26
|
+
[defaultSortedColumn]="defaultSortedColumn"
|
|
27
|
+
(sortChange)="onSortTenants($event)"
|
|
28
|
+
(paginationChange)="onTablePaginationChange($event)"
|
|
29
|
+
(rowLink)="navigateToViewTenantDetails($event)"
|
|
30
|
+
></ieeesa-data-table>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import "styles.scss";
|
|
2
|
+
.ieeesa-view-tenants-list {
|
|
3
|
+
background-color: $ieeesa-background-color-gray;
|
|
4
|
+
padding: 0px 24px 48px 24px;
|
|
5
|
+
&__mobile {
|
|
6
|
+
background-color: $ieeesa-white;
|
|
7
|
+
}
|
|
8
|
+
&__content {
|
|
9
|
+
background-color: $ieeesa-white;
|
|
10
|
+
box-shadow: $ieeesa-box-shadow-15;
|
|
11
|
+
padding: 24px 0px;
|
|
12
|
+
.cdk-column-appId {
|
|
13
|
+
min-width: 9em;
|
|
14
|
+
max-width: 9em;
|
|
15
|
+
}
|
|
16
|
+
.cdk-column-appTitle {
|
|
17
|
+
min-width: 10em;
|
|
18
|
+
max-width: 10em;
|
|
19
|
+
}
|
|
20
|
+
.cdk-column-appDescription {
|
|
21
|
+
min-width: 20.25em;
|
|
22
|
+
max-width: 20.25em;
|
|
23
|
+
}
|
|
24
|
+
.cdk-column-features {
|
|
25
|
+
min-width: 17em;
|
|
26
|
+
max-width: 17em;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
.ieeesa-data-table {
|
|
30
|
+
&__pagination-container {
|
|
31
|
+
padding-left: 11px;
|
|
32
|
+
padding-right: 11px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentFixture,
|
|
3
|
+
TestBed,
|
|
4
|
+
fakeAsync,
|
|
5
|
+
flush,
|
|
6
|
+
tick,
|
|
7
|
+
} from '@angular/core/testing';
|
|
8
|
+
import { ViewTenantsListComponent } from './view-tenants-list.component';
|
|
9
|
+
import {
|
|
10
|
+
HttpClient,
|
|
11
|
+
HttpErrorResponse,
|
|
12
|
+
HttpHandler,
|
|
13
|
+
} from '@angular/common/http';
|
|
14
|
+
import { Router, RouterEvent } from '@angular/router';
|
|
15
|
+
import { SharedService } from '@ieeesa-npm/shared';
|
|
16
|
+
import { TenantApplicationsService } from '../../services/tenant-applications.service';
|
|
17
|
+
import { CommonModule } from '@angular/common';
|
|
18
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
19
|
+
import {
|
|
20
|
+
IconButtonComponent,
|
|
21
|
+
DataTableComponent,
|
|
22
|
+
ModalComponent,
|
|
23
|
+
} from '@ieeesa-npm/presentation';
|
|
24
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
25
|
+
import { Observable, ReplaySubject } from 'rxjs';
|
|
26
|
+
import {
|
|
27
|
+
AlertType,
|
|
28
|
+
AlertsService,
|
|
29
|
+
GlobalErrorHandlerService,
|
|
30
|
+
} from '@ieeesa-npm/utility';
|
|
31
|
+
import { PageEvent } from '@angular/material/paginator';
|
|
32
|
+
import { Sort } from '@angular/material/sort';
|
|
33
|
+
import { TenantsMocks } from '../../assets/tenants-mock';
|
|
34
|
+
import { RouterTestingModule } from '@angular/router/testing';
|
|
35
|
+
import * as constants from '../../assets/constants.json';
|
|
36
|
+
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
37
|
+
import { CreateTenantApplicationComponent } from '../create-tenant-application/create-tenant-application.component';
|
|
38
|
+
import {
|
|
39
|
+
ViewTenantsColumnSchemaDef,
|
|
40
|
+
GetTenantsPayload,
|
|
41
|
+
SortOrderBy,
|
|
42
|
+
} from '../../models/table-column-schema-view-tenant-list.model';
|
|
43
|
+
describe('ViewTenantsListComponent', () => {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
const constant: any = constants;
|
|
46
|
+
let component: ViewTenantsListComponent;
|
|
47
|
+
let fixture: ComponentFixture<ViewTenantsListComponent>;
|
|
48
|
+
let sharedService: SharedService;
|
|
49
|
+
let alertsService: AlertsService;
|
|
50
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
51
|
+
let tenantApplicationsService: TenantApplicationsService;
|
|
52
|
+
let globalErrorHandlerService: GlobalErrorHandlerService;
|
|
53
|
+
const routerEventSubject = new ReplaySubject<RouterEvent>(1);
|
|
54
|
+
const mockRouter = {
|
|
55
|
+
navigate: jasmine.createSpy('navigate'),
|
|
56
|
+
events: routerEventSubject.asObservable(),
|
|
57
|
+
url: 'test/url',
|
|
58
|
+
};
|
|
59
|
+
const dialogOptions = {
|
|
60
|
+
heading: 'New Application',
|
|
61
|
+
isCloseNeeded: true,
|
|
62
|
+
componentReference: CreateTenantApplicationComponent,
|
|
63
|
+
modalType: 1,
|
|
64
|
+
};
|
|
65
|
+
const emptyFieldValueReplacedBy =
|
|
66
|
+
constant?.viewTenants?.emptyFieldValueReplacedBy;
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
TestBed.configureTestingModule({
|
|
69
|
+
imports: [
|
|
70
|
+
ViewTenantsListComponent,
|
|
71
|
+
CommonModule,
|
|
72
|
+
MatButtonModule,
|
|
73
|
+
IconButtonComponent,
|
|
74
|
+
DataTableComponent,
|
|
75
|
+
BrowserAnimationsModule,
|
|
76
|
+
RouterTestingModule,
|
|
77
|
+
MatDialogModule,
|
|
78
|
+
],
|
|
79
|
+
providers: [
|
|
80
|
+
SharedService,
|
|
81
|
+
HttpClient,
|
|
82
|
+
HttpHandler,
|
|
83
|
+
TenantApplicationsService,
|
|
84
|
+
{ provide: Router, useValue: mockRouter },
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
fixture = TestBed.createComponent(ViewTenantsListComponent);
|
|
88
|
+
component = fixture.componentInstance;
|
|
89
|
+
alertsService = TestBed.inject(AlertsService);
|
|
90
|
+
sharedService = TestBed.inject(SharedService);
|
|
91
|
+
tenantApplicationsService = TestBed.inject(TenantApplicationsService);
|
|
92
|
+
globalErrorHandlerService = TestBed.inject(GlobalErrorHandlerService);
|
|
93
|
+
fixture.detectChanges();
|
|
94
|
+
});
|
|
95
|
+
describe('#ngOnInit', () => {
|
|
96
|
+
it('should set tenant title', () => {
|
|
97
|
+
const viewTenantsConstants = {
|
|
98
|
+
tenantsTitle: 'Tenant Application Management',
|
|
99
|
+
};
|
|
100
|
+
component.tenantsPageInfo = {
|
|
101
|
+
tenantsTitle: viewTenantsConstants?.tenantsTitle,
|
|
102
|
+
};
|
|
103
|
+
component.ngOnInit();
|
|
104
|
+
expect(component.tenantsPageInfo).toEqual(viewTenantsConstants);
|
|
105
|
+
});
|
|
106
|
+
it('should set route path', () => {
|
|
107
|
+
const mockRouteConfigPath = {
|
|
108
|
+
viewTenants: 'tenants/view-tenants-list',
|
|
109
|
+
viewTenantDetails: 'tenants/view-tenant-details',
|
|
110
|
+
createTenant: 'tenants/create-tenants',
|
|
111
|
+
};
|
|
112
|
+
const spyOnRoutePathService = spyOn(
|
|
113
|
+
sharedService,
|
|
114
|
+
'setRoutePaths'
|
|
115
|
+
).and.callThrough();
|
|
116
|
+
component.routePaths = mockRouteConfigPath;
|
|
117
|
+
sharedService?.setRoutePaths(component.routePaths);
|
|
118
|
+
component.ngOnInit();
|
|
119
|
+
expect(spyOnRoutePathService).toHaveBeenCalled();
|
|
120
|
+
expect(component.routePaths).toEqual(mockRouteConfigPath);
|
|
121
|
+
});
|
|
122
|
+
it('should set app config and call configureTableInfo and getTenantsAndInitializeTableView', () => {
|
|
123
|
+
const spyOnSetAppConfig = spyOn(
|
|
124
|
+
tenantApplicationsService,
|
|
125
|
+
'setAppConfig'
|
|
126
|
+
).and.callThrough();
|
|
127
|
+
const spyOnConfigureTableInfo = spyOn(
|
|
128
|
+
component,
|
|
129
|
+
'configureTableInfo'
|
|
130
|
+
).and.callThrough();
|
|
131
|
+
const spyGetTenantsAndInitializeTableView = spyOn(
|
|
132
|
+
component,
|
|
133
|
+
'getTenantsAndInitializeTableView'
|
|
134
|
+
).and.callThrough();
|
|
135
|
+
tenantApplicationsService.setAppConfig(
|
|
136
|
+
TenantsMocks?.getApiBaseURL,
|
|
137
|
+
TenantsMocks?.mockUserPermissions
|
|
138
|
+
);
|
|
139
|
+
component.ngOnInit();
|
|
140
|
+
expect(spyOnConfigureTableInfo).toHaveBeenCalled();
|
|
141
|
+
expect(spyGetTenantsAndInitializeTableView).toHaveBeenCalled();
|
|
142
|
+
expect(spyOnSetAppConfig).toHaveBeenCalledWith(
|
|
143
|
+
TenantsMocks?.getApiBaseURL,
|
|
144
|
+
TenantsMocks?.mockUserPermissions
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe('#configureTableInfo', () => {
|
|
149
|
+
it('should return elements appId attribute value', () => {
|
|
150
|
+
const response = component.columnSchema[0]?.cellData({
|
|
151
|
+
appId: 'Application Id',
|
|
152
|
+
});
|
|
153
|
+
expect(response).toEqual('Application Id');
|
|
154
|
+
});
|
|
155
|
+
it('should return elements appTitle attribute value', () => {
|
|
156
|
+
const response = component.columnSchema[1]?.cellData({
|
|
157
|
+
appTitle: 'Application Title',
|
|
158
|
+
});
|
|
159
|
+
expect(response).toEqual('Application Title');
|
|
160
|
+
});
|
|
161
|
+
it('should return emptyFieldPlacedBy value if appTitle is empty', () => {
|
|
162
|
+
const response = component.columnSchema[1]?.cellData({
|
|
163
|
+
appTitle: undefined,
|
|
164
|
+
});
|
|
165
|
+
expect(response).toEqual(emptyFieldValueReplacedBy);
|
|
166
|
+
});
|
|
167
|
+
it('should return elements appDescription attribute value', () => {
|
|
168
|
+
const response = component.columnSchema[2]?.cellData({
|
|
169
|
+
appDescription: 'Application Description',
|
|
170
|
+
});
|
|
171
|
+
expect(response).toEqual('Application Description');
|
|
172
|
+
});
|
|
173
|
+
it('should return emptyFieldPlacedBy value if appDescription is empty', () => {
|
|
174
|
+
const response = component.columnSchema[2]?.cellData({
|
|
175
|
+
appDescription: undefined,
|
|
176
|
+
});
|
|
177
|
+
expect(response).toEqual(emptyFieldValueReplacedBy);
|
|
178
|
+
});
|
|
179
|
+
it('should return elements features attribute value', () => {
|
|
180
|
+
const response = component.columnSchema[3]?.cellData({
|
|
181
|
+
features: [
|
|
182
|
+
{
|
|
183
|
+
featureId: 'FEATURE_049753e8-ea5c-4fad-adb0-e1456e69c7a5',
|
|
184
|
+
featureName: 'Meetings & Events',
|
|
185
|
+
isDefault: false,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
featureId: 'FEATURE_348f62c2-a8a1-404e-b4a9-06e416590cbb',
|
|
189
|
+
featureName: 'Groups & Rosters',
|
|
190
|
+
isDefault: false,
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
});
|
|
194
|
+
expect(response).toEqual('Meetings & Events, Groups & Rosters');
|
|
195
|
+
});
|
|
196
|
+
it('should return emptyFieldPlacedBy value if features is empty', () => {
|
|
197
|
+
const response = component.columnSchema[3]?.cellData({
|
|
198
|
+
features: undefined,
|
|
199
|
+
});
|
|
200
|
+
expect(response).toEqual(emptyFieldValueReplacedBy);
|
|
201
|
+
});
|
|
202
|
+
it('should return elements status attribute as Active Value', () => {
|
|
203
|
+
const response = component.columnSchema[4]?.cellData({
|
|
204
|
+
status: true,
|
|
205
|
+
});
|
|
206
|
+
expect(response).toEqual('Active');
|
|
207
|
+
});
|
|
208
|
+
it('should return elements status attribute as Inactive Value', () => {
|
|
209
|
+
const response = component.columnSchema[4]?.cellData({
|
|
210
|
+
status: false,
|
|
211
|
+
});
|
|
212
|
+
expect(response).toEqual('Inactive');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
describe('#getTenantsAndInitializeTableView', () => {
|
|
216
|
+
it('should call fetch tenants details', () => {
|
|
217
|
+
spyOn(tenantApplicationsService, 'getTenantsList').and.returnValue(
|
|
218
|
+
new Observable((subscriber) => {
|
|
219
|
+
subscriber.next(TenantsMocks.getTenantsMockResponse);
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
component.getTenantsAndInitializeTableView(
|
|
223
|
+
TenantsMocks?.getTenantsMockPayload
|
|
224
|
+
);
|
|
225
|
+
expect(component.tableData).toEqual(
|
|
226
|
+
TenantsMocks?.getTenantsMockResponse?.body?.appDetails
|
|
227
|
+
);
|
|
228
|
+
expect(component.paginatorConfig?.totalRecords).toEqual(
|
|
229
|
+
TenantsMocks?.getTenantsMockResponse?.body?.totalRecords
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
it('should return error', () => {
|
|
233
|
+
const mockServerErrorResponse = new HttpErrorResponse({
|
|
234
|
+
error: 'Resource Not Found',
|
|
235
|
+
});
|
|
236
|
+
spyOn(tenantApplicationsService, 'getTenantsList').and.returnValue(
|
|
237
|
+
new Observable((subscriber) => {
|
|
238
|
+
subscriber.error(mockServerErrorResponse);
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
spyOn(globalErrorHandlerService, 'handleError');
|
|
242
|
+
component.getTenantsAndInitializeTableView(
|
|
243
|
+
TenantsMocks?.getTenantsMockPayload
|
|
244
|
+
);
|
|
245
|
+
expect(globalErrorHandlerService.handleError).toHaveBeenCalledWith(
|
|
246
|
+
mockServerErrorResponse
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
describe('#onTablePaginationChange', () => {
|
|
251
|
+
it('should call getTenantsAndInitializeTableView method on view tenants list table page change for Ascending sort direction', () => {
|
|
252
|
+
const pageEventMock: PageEvent = {
|
|
253
|
+
pageIndex: 1,
|
|
254
|
+
pageSize: 10,
|
|
255
|
+
length: 0,
|
|
256
|
+
};
|
|
257
|
+
const getTenantsAndInitializeTableViewSpy = spyOn(
|
|
258
|
+
component,
|
|
259
|
+
'getTenantsAndInitializeTableView'
|
|
260
|
+
).and.callThrough();
|
|
261
|
+
component.onTablePaginationChange(pageEventMock);
|
|
262
|
+
component.getTenantsAndInitializeTableView(
|
|
263
|
+
TenantsMocks?.getTenantsMockPayload
|
|
264
|
+
);
|
|
265
|
+
expect(getTenantsAndInitializeTableViewSpy).toHaveBeenCalledWith(
|
|
266
|
+
TenantsMocks?.getTenantsMockPayload
|
|
267
|
+
);
|
|
268
|
+
expect(component.defaultColumnSortDirection).toBe(true);
|
|
269
|
+
});
|
|
270
|
+
it('should call getTenantsAndInitializeTableView method on view tenants list table page change for Descending sort direction', () => {
|
|
271
|
+
const pageEventMock: PageEvent = {
|
|
272
|
+
pageIndex: 1,
|
|
273
|
+
pageSize: 10,
|
|
274
|
+
length: 0,
|
|
275
|
+
};
|
|
276
|
+
component.defaultColumnSortDirection = false;
|
|
277
|
+
const getTenantsAndInitializeTableViewSpy = spyOn(
|
|
278
|
+
component,
|
|
279
|
+
'getTenantsAndInitializeTableView'
|
|
280
|
+
).and.callThrough();
|
|
281
|
+
component.onTablePaginationChange(pageEventMock);
|
|
282
|
+
component.getTenantsAndInitializeTableView(
|
|
283
|
+
TenantsMocks?.getTenantsMockPayload
|
|
284
|
+
);
|
|
285
|
+
expect(getTenantsAndInitializeTableViewSpy).toHaveBeenCalledWith(
|
|
286
|
+
TenantsMocks?.getTenantsMockPayload
|
|
287
|
+
);
|
|
288
|
+
expect(component.defaultColumnSortDirection).toBe(false);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
describe('#navigateToViewTenantDetails', () => {
|
|
292
|
+
it('should navigate to viewTenantDetails passed in route paths', () => {
|
|
293
|
+
const mockRouteUrl = 'tenants/view-tenant-details';
|
|
294
|
+
mockRouter.navigate();
|
|
295
|
+
component.routePaths.viewTenantDetails = mockRouteUrl;
|
|
296
|
+
component.navigateToViewTenantDetails(TenantsMocks?.tenantInfoMock);
|
|
297
|
+
expect(mockRouter.navigate).toHaveBeenCalledWith(
|
|
298
|
+
[mockRouteUrl],
|
|
299
|
+
Object({
|
|
300
|
+
queryParams: Object({ id: TenantsMocks?.tenantInfoMock?.appId }),
|
|
301
|
+
})
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
it('should emit viewTenantsDetailsClick event in case viewTenantDetails route is not passed', () => {
|
|
305
|
+
component.routePaths.viewTenantDetails = '';
|
|
306
|
+
const viewTenantsDetailsClickEmitSpy = spyOn(
|
|
307
|
+
component.viewTenantsDetails,
|
|
308
|
+
'emit'
|
|
309
|
+
);
|
|
310
|
+
component.navigateToViewTenantDetails(TenantsMocks?.tenantInfoMock);
|
|
311
|
+
expect(viewTenantsDetailsClickEmitSpy).toHaveBeenCalled();
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
describe('#onSortTenants', () => {
|
|
315
|
+
it('should call getTenantsAndInitializeTableView while sorting an app id and app title', () => {
|
|
316
|
+
const sortMock: Sort = {
|
|
317
|
+
active: 'appId',
|
|
318
|
+
direction: 'asc',
|
|
319
|
+
};
|
|
320
|
+
const spyOnGetTenantsAndInitializeTableView = spyOn(
|
|
321
|
+
component,
|
|
322
|
+
'getTenantsAndInitializeTableView'
|
|
323
|
+
).and.callThrough();
|
|
324
|
+
component.onSortTenants(sortMock);
|
|
325
|
+
component.getTenantsAndInitializeTableView(
|
|
326
|
+
TenantsMocks?.getTenantsMockPayload
|
|
327
|
+
);
|
|
328
|
+
expect(component.defaultSortedColumn).toBe(sortMock.active);
|
|
329
|
+
expect(component.defaultColumnSortDirection).toBe(true);
|
|
330
|
+
expect(spyOnGetTenantsAndInitializeTableView).toHaveBeenCalledWith(
|
|
331
|
+
TenantsMocks?.getTenantsMockPayload
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
it('should call getTenantsAndInitializeTableView while sorting desc an app id and app title', () => {
|
|
335
|
+
const sortMock: Sort = {
|
|
336
|
+
active: 'appId',
|
|
337
|
+
direction: 'desc',
|
|
338
|
+
};
|
|
339
|
+
const spyOnGetTenantsAndInitializeTableView = spyOn(
|
|
340
|
+
component,
|
|
341
|
+
'getTenantsAndInitializeTableView'
|
|
342
|
+
).and.callThrough();
|
|
343
|
+
component.onSortTenants(sortMock);
|
|
344
|
+
component.getTenantsAndInitializeTableView(
|
|
345
|
+
TenantsMocks?.getTenantsMockPayload
|
|
346
|
+
);
|
|
347
|
+
expect(component.defaultSortedColumn).toBe(sortMock.active);
|
|
348
|
+
expect(component.defaultColumnSortDirection).toBe(false);
|
|
349
|
+
expect(spyOnGetTenantsAndInitializeTableView).toHaveBeenCalledWith(
|
|
350
|
+
TenantsMocks?.getTenantsMockPayload
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
describe('#openCreateTenantForm', () => {
|
|
355
|
+
it('should call openCreateTenantForm method and open modal', () => {
|
|
356
|
+
const spyOpenModal = spyOn(component, 'openModal');
|
|
357
|
+
spyOn(component.dialog, 'open').and.callThrough();
|
|
358
|
+
component.openCreateTenantForm();
|
|
359
|
+
expect(spyOpenModal).toHaveBeenCalled();
|
|
360
|
+
fixture.detectChanges();
|
|
361
|
+
component.dialog.open(ModalComponent, {
|
|
362
|
+
data: dialogOptions,
|
|
363
|
+
width: 'auto',
|
|
364
|
+
panelClass: ['ieeesa-modal-dialog'],
|
|
365
|
+
ariaModal: true,
|
|
366
|
+
});
|
|
367
|
+
expect(component.dialog.open).toHaveBeenCalledWith(ModalComponent, {
|
|
368
|
+
data: dialogOptions,
|
|
369
|
+
width: 'auto',
|
|
370
|
+
panelClass: ['ieeesa-modal-dialog'],
|
|
371
|
+
ariaModal: true,
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
describe('#openModal', () => {
|
|
376
|
+
it('should open create tenant modal with the provided className', () => {
|
|
377
|
+
spyOn(component.dialog, 'open').and.callThrough();
|
|
378
|
+
component.openModal(dialogOptions);
|
|
379
|
+
fixture.detectChanges();
|
|
380
|
+
component.dialog.open(ModalComponent, {
|
|
381
|
+
data: dialogOptions,
|
|
382
|
+
width: 'auto',
|
|
383
|
+
panelClass: ['ieeesa-modal-dialog'],
|
|
384
|
+
ariaModal: true,
|
|
385
|
+
});
|
|
386
|
+
expect(component.dialog.open).toHaveBeenCalledWith(ModalComponent, {
|
|
387
|
+
data: dialogOptions,
|
|
388
|
+
width: 'auto',
|
|
389
|
+
panelClass: ['ieeesa-modal-dialog'],
|
|
390
|
+
ariaModal: true,
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should handle successful tenant creation', () => {
|
|
395
|
+
spyOn(alertsService, 'showMessage').and.callThrough();
|
|
396
|
+
const showAlertMessageSpy = spyOn(sharedService, 'showAlertMessage');
|
|
397
|
+
tenantApplicationsService.setNewTenantInfo(
|
|
398
|
+
TenantsMocks.createTenantMockPayload?.payload
|
|
399
|
+
);
|
|
400
|
+
component.openModal(dialogOptions, 'ieeesa-create-tenant');
|
|
401
|
+
component.dialogRef.componentInstance.submitFormResponse.next(
|
|
402
|
+
TenantsMocks.createTenantMockResponse
|
|
403
|
+
);
|
|
404
|
+
fixture.detectChanges();
|
|
405
|
+
expect(showAlertMessageSpy).toHaveBeenCalledOnceWith(
|
|
406
|
+
AlertType.SUCCESS,
|
|
407
|
+
'SA Collaboration portal has been created successfully.'
|
|
408
|
+
);
|
|
409
|
+
});
|
|
410
|
+
it('should handle create tenant form submission cancel', fakeAsync(() => {
|
|
411
|
+
component.openModal(dialogOptions, 'ieeesa-edit-tenant');
|
|
412
|
+
component.dialogRef.componentInstance.formCancel.next();
|
|
413
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
414
|
+
const dialogRefSpy = jasmine.createSpyObj<MatDialogRef<any>>(
|
|
415
|
+
'MatDialogRef',
|
|
416
|
+
['close']
|
|
417
|
+
);
|
|
418
|
+
expect(dialogRefSpy.close).toBeTruthy();
|
|
419
|
+
tick();
|
|
420
|
+
flush();
|
|
421
|
+
}));
|
|
422
|
+
});
|
|
423
|
+
describe('#getTenantsPayload', () => {
|
|
424
|
+
it('should call getTenantsPayload and return the default payload for fetching tenants list', () => {
|
|
425
|
+
const payload: GetTenantsPayload = {
|
|
426
|
+
payload: {
|
|
427
|
+
offset: 0,
|
|
428
|
+
pageSize: constants?.viewTenants?.pageSizeOptions[0],
|
|
429
|
+
sortedBy: ViewTenantsColumnSchemaDef.APP_ID,
|
|
430
|
+
sortedOrderBy: 'ASC',
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
expect(component.getTenantsPayload()).toEqual(payload);
|
|
434
|
+
});
|
|
435
|
+
it('should call getTenantsPayload and return the paginated and sorted payload for fetching tenants list', () => {
|
|
436
|
+
component.pageEvent = { pageIndex: 1, pageSize: 20 } as PageEvent;
|
|
437
|
+
component.sortConfig = {
|
|
438
|
+
isSortedByAscending: true,
|
|
439
|
+
sort: { active: ViewTenantsColumnSchemaDef.APP_ID } as Sort,
|
|
440
|
+
};
|
|
441
|
+
const payload: GetTenantsPayload = {
|
|
442
|
+
payload: {
|
|
443
|
+
offset: component.pageEvent.pageIndex,
|
|
444
|
+
pageSize: component.pageEvent.pageSize,
|
|
445
|
+
sortedBy: component.sortConfig.sort.active,
|
|
446
|
+
sortedOrderBy: component.sortConfig.isSortedByAscending
|
|
447
|
+
? SortOrderBy.ASC
|
|
448
|
+
: SortOrderBy.DESC,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
expect(component.getTenantsPayload()).toEqual(payload);
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
describe('#ngOnDestroy', () => {
|
|
456
|
+
it('should unsubscribe on ngOnDestroy', () => {
|
|
457
|
+
spyOn(component.destroy$, 'next');
|
|
458
|
+
spyOn(component.destroy$, 'unsubscribe');
|
|
459
|
+
component.ngOnDestroy();
|
|
460
|
+
expect(component.destroy$.next).toHaveBeenCalledWith(true);
|
|
461
|
+
expect(component.destroy$.unsubscribe).toHaveBeenCalled();
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
});
|