cat-documents-ng 1.0.4 → 1.0.6
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/ng-package.json +10 -0
- package/package.json +5 -11
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +3 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +13 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +70 -0
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +133 -0
- package/src/Shared/components/table-primary/table-primary.component.html +66 -0
- package/src/Shared/components/table-primary/table-primary.component.scss +227 -0
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +23 -0
- package/src/Shared/components/table-primary/table-primary.component.ts +143 -0
- package/src/Shared/components/table-primary/table-primary.model.ts +21 -0
- package/src/Shared/constant/ERROR.ts +55 -0
- package/src/Shared/constant/PERMISSIONS.ts +17 -0
- package/src/Shared/constant/SHARED.ts +936 -0
- package/{Shared/constant/URLS.d.ts → src/Shared/constant/URLS.ts} +31 -25
- package/src/Shared/services/app-config.service.spec.ts +19 -0
- package/src/Shared/services/app-config.service.ts +73 -0
- package/{Shared/services/global-error.handler.d.ts → src/Shared/services/global-error.handler.ts} +11 -9
- package/src/Shared/services/session.service.spec.ts +16 -0
- package/src/Shared/services/session.service.ts +76 -0
- package/src/Shared/shared.module.ts +25 -0
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +1 -0
- package/src/lib/document/components/document-actions/document-actions.component.html +59 -0
- package/src/lib/document/components/document-actions/document-actions.component.scss +362 -0
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +297 -0
- package/src/lib/document/components/document-actions/document-actions.component.ts +163 -0
- package/src/lib/document/components/document-container/document-container.component.html +36 -0
- package/src/lib/document/components/document-container/document-container.component.scss +144 -0
- package/src/lib/document/components/document-container/document-container.component.spec.ts +110 -0
- package/src/lib/document/components/document-container/document-container.component.ts +363 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +332 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +1877 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +258 -0
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +664 -0
- package/src/lib/document/components/document-history/document-history.component.html +96 -0
- package/src/lib/document/components/document-history/document-history.component.scss +392 -0
- package/src/lib/document/components/document-history/document-history.component.spec.ts +93 -0
- package/src/lib/document/components/document-history/document-history.component.ts +373 -0
- package/src/lib/document/components/document-list/document-list.component.html +46 -0
- package/src/lib/document/components/document-list/document-list.component.scss +513 -0
- package/src/lib/document/components/document-list/document-list.component.spec.ts +486 -0
- package/src/lib/document/components/document-list/document-list.component.ts +682 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.html +36 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +34 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +75 -0
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +40 -0
- package/src/lib/document/components/document-search/document-search.component.html +64 -0
- package/src/lib/document/components/document-search/document-search.component.scss +206 -0
- package/src/lib/document/components/document-search/document-search.component.spec.ts +82 -0
- package/src/lib/document/components/document-search/document-search.component.ts +163 -0
- package/src/lib/document/components/document-status/document-status.component.html +31 -0
- package/src/lib/document/components/document-status/document-status.component.scss +192 -0
- package/src/lib/document/components/document-status/document-status.component.spec.ts +23 -0
- package/src/lib/document/components/document-status/document-status.component.ts +87 -0
- package/src/lib/document/components/document-upload/document-upload.component.html +160 -0
- package/src/lib/document/components/document-upload/document-upload.component.scss +235 -0
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +95 -0
- package/src/lib/document/components/document-upload/document-upload.component.ts +668 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.html +50 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +187 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +79 -0
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +261 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +48 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +320 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +59 -0
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +150 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.html +44 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +363 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +23 -0
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +316 -0
- package/src/lib/document/components/folder-block/folder-block.component.html +46 -0
- package/src/lib/document/components/folder-block/folder-block.component.scss +9 -0
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +70 -0
- package/{lib/document/components/folder-block/folder-block.component.d.ts → src/lib/document/components/folder-block/folder-block.component.ts} +28 -12
- package/src/lib/document/components/folder-container/folder-container.component.html +56 -0
- package/src/lib/document/components/folder-container/folder-container.component.scss +20 -0
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +27 -0
- package/src/lib/document/components/folder-container/folder-container.component.ts +328 -0
- package/src/lib/document/components/linked-document/linked-document.component.html +23 -0
- package/src/lib/document/components/linked-document/linked-document.component.scss +10 -0
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +61 -0
- package/src/lib/document/components/linked-document/linked-document.component.ts +49 -0
- package/src/lib/document/components/request-document/request-document.component.html +86 -0
- package/src/lib/document/components/request-document/request-document.component.scss +16 -0
- package/src/lib/document/components/request-document/request-document.component.ts +278 -0
- package/src/lib/document/components/sidebar/sidebar.component.html +75 -0
- package/src/lib/document/components/sidebar/sidebar.component.scss +157 -0
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +114 -0
- package/src/lib/document/components/sidebar/sidebar.component.ts +223 -0
- package/src/lib/document/components/user-list/user-list.component.html +33 -0
- package/src/lib/document/components/user-list/user-list.component.scss +118 -0
- package/src/lib/document/components/user-list/user-list.component.spec.ts +23 -0
- package/src/lib/document/components/user-list/user-list.component.ts +181 -0
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +52 -0
- package/src/lib/document/directives/document.directive.ts +32 -0
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +72 -0
- package/src/lib/document/document.module.ts +351 -0
- package/{lib/document/models/document-alert.model.d.ts → src/lib/document/models/document-alert.model.ts} +11 -4
- package/src/lib/document/models/document-category.model.ts +30 -0
- package/src/lib/document/models/document-history.model.ts +109 -0
- package/src/lib/document/models/document-list-response.model.ts +37 -0
- package/src/lib/document/models/document-type.model.ts +44 -0
- package/src/lib/document/models/document.model.ts +53 -0
- package/{lib/document/models/folder.model.d.ts → src/lib/document/models/folder.model.ts} +10 -4
- package/src/lib/document/models/status-data.model.ts +31 -0
- package/src/lib/document/models/uploaded-file-response.model.ts +7 -0
- package/src/lib/document/models/user-list.model.ts +10 -0
- package/src/lib/document/services/csv-parser.service.spec.ts +97 -0
- package/src/lib/document/services/csv-parser.service.ts +303 -0
- package/src/lib/document/services/document-actions.service.ts +125 -0
- package/src/lib/document/services/document-content-type.service.ts +193 -0
- package/src/lib/document/services/document-history-style.service.ts +138 -0
- package/src/lib/document/services/document-history.service.ts +129 -0
- package/src/lib/document/services/document-http.service.spec.ts +119 -0
- package/src/lib/document/services/document-http.service.ts +497 -0
- package/src/lib/document/services/document-list.service.ts +195 -0
- package/src/lib/document/services/document-menu.service.ts +277 -0
- package/src/lib/document/services/document-scroll.service.ts +138 -0
- package/src/lib/document/services/document-severity.service.ts +98 -0
- package/src/lib/document/services/document-table-builder.service.ts +82 -0
- package/src/lib/document/services/document-upload-business.service.ts +326 -0
- package/src/lib/document/services/document-upload-data.service.ts +82 -0
- package/src/lib/document/services/document-upload-form.service.ts +149 -0
- package/src/lib/document/services/document-upload.service.spec.ts +99 -0
- package/src/lib/document/services/document-upload.service.ts +209 -0
- package/src/lib/document/services/document-viewer.service.ts +279 -0
- package/src/lib/document/services/document-zoom.service.spec.ts +56 -0
- package/src/lib/document/services/document-zoom.service.ts +164 -0
- package/src/lib/document/services/document.service.ts +356 -0
- package/src/lib/document/services/eml-parser.service.ts +444 -0
- package/src/lib/document/services/excel-parser.service.spec.ts +66 -0
- package/src/lib/document/services/excel-parser.service.ts +483 -0
- package/src/lib/document/services/file-format.service.spec.ts +16 -0
- package/src/lib/document/services/file-format.service.ts +63 -0
- package/src/lib/document/services/status-calculator.service.ts +44 -0
- package/src/lib/document/services/user-list.service.ts +77 -0
- package/src/lib/document/state/document.query.ts +378 -0
- package/{lib/document/state/document.service.d.ts → src/lib/document/state/document.service.ts} +46 -15
- package/src/lib/document/state/document.state.ts +100 -0
- package/src/lib/document/state/document.store.ts +200 -0
- package/{public-api.d.ts → src/public-api.ts} +4 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +0 -44
- package/Shared/components/table-primary/table-primary.component.d.ts +0 -31
- package/Shared/components/table-primary/table-primary.model.d.ts +0 -19
- package/Shared/constant/ERROR.d.ts +0 -52
- package/Shared/constant/SHARED.d.ts +0 -546
- package/Shared/services/app-config.service.d.ts +0 -51
- package/Shared/services/session.service.d.ts +0 -46
- package/Shared/shared.module.d.ts +0 -14
- package/fesm2022/cat-documents-ng.mjs +0 -11392
- package/fesm2022/cat-documents-ng.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/document/components/document-actions/document-actions.component.d.ts +0 -78
- package/lib/document/components/document-container/document-container.component.d.ts +0 -162
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +0 -291
- package/lib/document/components/document-history/document-history.component.d.ts +0 -160
- package/lib/document/components/document-list/document-list.component.d.ts +0 -299
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +0 -28
- package/lib/document/components/document-search/document-search.component.d.ts +0 -77
- package/lib/document/components/document-status/document-status.component.d.ts +0 -24
- package/lib/document/components/document-upload/document-upload.component.d.ts +0 -321
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +0 -137
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +0 -33
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +0 -110
- package/lib/document/components/folder-container/folder-container.component.d.ts +0 -162
- package/lib/document/components/linked-document/linked-document.component.d.ts +0 -39
- package/lib/document/components/request-document/request-document.component.d.ts +0 -69
- package/lib/document/components/sidebar/sidebar.component.d.ts +0 -109
- package/lib/document/components/user-list/user-list.component.d.ts +0 -34
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +0 -41
- package/lib/document/directives/document.directive.d.ts +0 -20
- package/lib/document/directives/permission.directive.d.ts +0 -38
- package/lib/document/document.module.d.ts +0 -60
- package/lib/document/models/document-category.model.d.ts +0 -24
- package/lib/document/models/document-history.model.d.ts +0 -94
- package/lib/document/models/document-list-response.model.d.ts +0 -33
- package/lib/document/models/document-type.model.d.ts +0 -37
- package/lib/document/models/document.model.d.ts +0 -44
- package/lib/document/models/status-data.model.d.ts +0 -27
- package/lib/document/models/uploaded-file-response.model.d.ts +0 -7
- package/lib/document/models/user-list.model.d.ts +0 -8
- package/lib/document/services/csv-parser.service.d.ts +0 -88
- package/lib/document/services/document-actions.service.d.ts +0 -48
- package/lib/document/services/document-content-type.service.d.ts +0 -85
- package/lib/document/services/document-history-style.service.d.ts +0 -34
- package/lib/document/services/document-history.service.d.ts +0 -42
- package/lib/document/services/document-http.service.d.ts +0 -179
- package/lib/document/services/document-list.service.d.ts +0 -74
- package/lib/document/services/document-menu.service.d.ts +0 -122
- package/lib/document/services/document-scroll.service.d.ts +0 -55
- package/lib/document/services/document-table-builder.service.d.ts +0 -38
- package/lib/document/services/document-upload-business.service.d.ts +0 -107
- package/lib/document/services/document-upload-data.service.d.ts +0 -40
- package/lib/document/services/document-upload-form.service.d.ts +0 -41
- package/lib/document/services/document-upload.service.d.ts +0 -99
- package/lib/document/services/document-viewer.service.d.ts +0 -97
- package/lib/document/services/document-zoom.service.d.ts +0 -81
- package/lib/document/services/document.service.d.ts +0 -161
- package/lib/document/services/eml-parser.service.d.ts +0 -116
- package/lib/document/services/excel-parser.service.d.ts +0 -169
- package/lib/document/services/file-format.service.d.ts +0 -34
- package/lib/document/services/status-calculator.service.d.ts +0 -20
- package/lib/document/services/user-list.service.d.ts +0 -29
- package/lib/document/state/document.query.d.ts +0 -243
- package/lib/document/state/document.state.d.ts +0 -61
- package/lib/document/state/document.store.d.ts +0 -56
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { DocumentListComponent } from './document-list.component';
|
|
3
|
+
import { DocumentHttpService } from '../../services/document-http.service';
|
|
4
|
+
import { DocumentListService } from '../../services/document-list.service';
|
|
5
|
+
import { DocumentMenuService } from '../../services/document-menu.service';
|
|
6
|
+
import { DocumentStore } from '../../state/document.store';
|
|
7
|
+
import { DocumentScrollService } from '../../services/document-scroll.service';
|
|
8
|
+
import { of } from 'rxjs';
|
|
9
|
+
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
10
|
+
import { DocumentTypeModel } from '../../models/document-type.model';
|
|
11
|
+
import { DocumentModel } from '../../models/document.model';
|
|
12
|
+
import { DocumentListItem, DocumentListResponse } from '../../models/document-list-response.model';
|
|
13
|
+
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
14
|
+
|
|
15
|
+
describe('DocumentListComponent', () => {
|
|
16
|
+
let component: DocumentListComponent;
|
|
17
|
+
let fixture: ComponentFixture<DocumentListComponent>;
|
|
18
|
+
let documentHttpService: jasmine.SpyObj<DocumentHttpService>;
|
|
19
|
+
let documentListService: jasmine.SpyObj<DocumentListService>;
|
|
20
|
+
let documentMenuService: jasmine.SpyObj<DocumentMenuService>;
|
|
21
|
+
let documentStore: jasmine.SpyObj<DocumentStore>;
|
|
22
|
+
let documentScrollService: jasmine.SpyObj<DocumentScrollService>;
|
|
23
|
+
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
// Mock services
|
|
26
|
+
documentHttpService = jasmine.createSpyObj('DocumentHttpService', ['getDocumentTypes', 'updateDocumentName']);
|
|
27
|
+
documentListService = jasmine.createSpyObj('DocumentListService', [
|
|
28
|
+
'setupDocumentListSubscription',
|
|
29
|
+
'buildDocumentCategories',
|
|
30
|
+
'refreshDocumentListForNewContext',
|
|
31
|
+
'handleTableRowClick',
|
|
32
|
+
'handleDeleteAction',
|
|
33
|
+
'refreshAllDataWithCurrentFilters',
|
|
34
|
+
'refreshDocumentList'
|
|
35
|
+
]);
|
|
36
|
+
documentMenuService = jasmine.createSpyObj('DocumentMenuService', ['isMenuItemSectionVisible']);
|
|
37
|
+
documentStore = jasmine.createSpyObj('DocumentStore', ['setSelectedMenuItem']);
|
|
38
|
+
documentScrollService = jasmine.createSpyObj('DocumentScrollService', [
|
|
39
|
+
'setupScrollListeners',
|
|
40
|
+
'setScrolling',
|
|
41
|
+
'setupSectionObserver',
|
|
42
|
+
'resetScrollingAfterDelay',
|
|
43
|
+
'disconnectSectionObserver',
|
|
44
|
+
'cleanupScrollListeners'
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
// Mock service methods
|
|
48
|
+
documentListService.setupDocumentListSubscription.and.returnValue(of([]));
|
|
49
|
+
documentListService.buildDocumentCategories.and.returnValue({
|
|
50
|
+
documentCategories: [],
|
|
51
|
+
categoryTables: [],
|
|
52
|
+
categoryCompletionCounts: [],
|
|
53
|
+
categorySeverities: []
|
|
54
|
+
});
|
|
55
|
+
documentListService.handleTableRowClick.and.returnValue({} as DocumentListItem);
|
|
56
|
+
documentListService.handleDeleteAction.and.returnValue(of({}));
|
|
57
|
+
documentMenuService.isMenuItemSectionVisible.and.returnValue(true);
|
|
58
|
+
|
|
59
|
+
await TestBed.configureTestingModule({
|
|
60
|
+
declarations: [DocumentListComponent],
|
|
61
|
+
providers: [
|
|
62
|
+
{ provide: DocumentHttpService, useValue: documentHttpService },
|
|
63
|
+
{ provide: DocumentListService, useValue: documentListService },
|
|
64
|
+
{ provide: DocumentMenuService, useValue: documentMenuService },
|
|
65
|
+
{ provide: DocumentStore, useValue: documentStore },
|
|
66
|
+
{ provide: DocumentScrollService, useValue: documentScrollService }
|
|
67
|
+
],
|
|
68
|
+
schemas: [NO_ERRORS_SCHEMA] // To suppress schema-related errors
|
|
69
|
+
}).compileComponents();
|
|
70
|
+
|
|
71
|
+
fixture = TestBed.createComponent(DocumentListComponent);
|
|
72
|
+
component = fixture.componentInstance;
|
|
73
|
+
fixture.detectChanges(); // Trigger lifecycle hooks and initial data binding
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should create', () => {
|
|
77
|
+
expect(component).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should initialize with default values', () => {
|
|
81
|
+
expect(component.contextId).toBe(SHARED.EMPTY);
|
|
82
|
+
expect(component.documentListResponse).toBeNull();
|
|
83
|
+
expect(component.selectedMenuItemId).toBeNull();
|
|
84
|
+
expect(component.navigationInfo).toBeNull();
|
|
85
|
+
expect(component.isSidebarVisible).toBe(SHARED.FALSE);
|
|
86
|
+
expect(component.isdialogVisible).toBe(SHARED.FALSE);
|
|
87
|
+
expect(component.documentList).toEqual(SHARED.EMPTY_ARRAY);
|
|
88
|
+
expect(component.options).toEqual(SHARED.EMPTY_ARRAY);
|
|
89
|
+
expect(component.selectedOption).toBeNull();
|
|
90
|
+
expect(component.categoryTables).toEqual(SHARED.EMPTY_ARRAY);
|
|
91
|
+
expect(component.documentCategories).toEqual(SHARED.EMPTY_ARRAY);
|
|
92
|
+
expect(component.categoryCompletionCounts).toEqual(SHARED.EMPTY_ARRAY);
|
|
93
|
+
expect(component.categorySeverities).toEqual(SHARED.EMPTY_ARRAY);
|
|
94
|
+
expect(component.deleteMessage).toEqual(SHARED.EMPTY_ARRAY);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should setup document list subscription on init', () => {
|
|
98
|
+
expect(documentListService.setupDocumentListSubscription).toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should handle sidebar visibility', () => {
|
|
102
|
+
component.handleOpenSideBar(true);
|
|
103
|
+
expect(component.isSidebarVisible).toBeTrue();
|
|
104
|
+
|
|
105
|
+
component.handleOpenSideBar(false);
|
|
106
|
+
expect(component.isSidebarVisible).toBeFalse();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should handle table row click', () => {
|
|
110
|
+
const mockRowData = { _id: '1', name: 'Test Document' };
|
|
111
|
+
component.handleTableRowClick(mockRowData);
|
|
112
|
+
|
|
113
|
+
expect(component.isdialogVisible).toBe(SHARED.TRUE);
|
|
114
|
+
expect(documentListService.handleTableRowClick).toHaveBeenCalledWith(mockRowData);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should handle delete action', () => {
|
|
118
|
+
const mockRowData = { _id: '1', name: 'Test Document' };
|
|
119
|
+
component.contextId = 'test-context';
|
|
120
|
+
component.selectedDocument = { _id: '1' } as DocumentListItem;
|
|
121
|
+
|
|
122
|
+
component.handleDeleteAction(mockRowData);
|
|
123
|
+
|
|
124
|
+
expect(documentListService.handleDeleteAction).toHaveBeenCalledWith(mockRowData, 'test-context');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should handle dialog close and reset selected document', () => {
|
|
128
|
+
component.selectedDocument = { _id: "1" } as DocumentListItem;
|
|
129
|
+
component.fileName = 'test-file.pdf';
|
|
130
|
+
component.contextId = 'test-context';
|
|
131
|
+
|
|
132
|
+
component.handleCloseModal();
|
|
133
|
+
|
|
134
|
+
expect(component.isdialogVisible).toBe(SHARED.FALSE);
|
|
135
|
+
expect(component.selectedDocument).toEqual({} as DocumentListItem);
|
|
136
|
+
expect(component.fileName).toBe(SHARED.EMPTY);
|
|
137
|
+
expect(documentListService.refreshAllDataWithCurrentFilters).toHaveBeenCalledWith('test-context');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should refresh document list', () => {
|
|
141
|
+
component.contextId = 'test-context';
|
|
142
|
+
component.refreshDocumentList();
|
|
143
|
+
|
|
144
|
+
expect(documentListService.refreshDocumentList).toHaveBeenCalledWith('test-context');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should refresh document list with delete action', () => {
|
|
148
|
+
component.contextId = 'test-context';
|
|
149
|
+
component.refreshDocumentList(true);
|
|
150
|
+
|
|
151
|
+
expect(documentListService.refreshDocumentList).toHaveBeenCalledWith('test-context');
|
|
152
|
+
expect(component.deleteMessage).toEqual([{severity: SHARED.SUCCESS_SEVERITY, detail: SHARED.DOCUMENT_DELETED_SUCCESSFULLY}]);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should handle document status update', () => {
|
|
156
|
+
component.contextId = 'test-context';
|
|
157
|
+
|
|
158
|
+
// Test name update action
|
|
159
|
+
component.handleDocumentStatusUpdate({ actionType: SHARED.NAME_UPDATE_ACTION });
|
|
160
|
+
expect(documentListService.refreshAllDataWithCurrentFilters).toHaveBeenCalledWith('test-context');
|
|
161
|
+
|
|
162
|
+
// Test other actions
|
|
163
|
+
component.handleDocumentStatusUpdate({ actionType: 'other' });
|
|
164
|
+
expect(documentListService.refreshDocumentList).toHaveBeenCalledWith('test-context');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should handle delete error', () => {
|
|
168
|
+
const mockError = { message: 'Delete failed' };
|
|
169
|
+
component.handleDeleteError(mockError);
|
|
170
|
+
|
|
171
|
+
expect(component.deleteMessage).toEqual([{severity: 'error', detail: 'Delete failed'}]);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should handle delete success', () => {
|
|
175
|
+
component.contextId = 'test-context';
|
|
176
|
+
component.handleDeleteSuccess();
|
|
177
|
+
|
|
178
|
+
expect(documentListService.refreshDocumentList).toHaveBeenCalledWith('test-context');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should handle document name update', () => {
|
|
182
|
+
component.contextId = 'test-context';
|
|
183
|
+
component.handleDocumentNameUpdate();
|
|
184
|
+
|
|
185
|
+
expect(documentListService.refreshAllDataWithCurrentFilters).toHaveBeenCalledWith('test-context');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should handle viewer destroyed', () => {
|
|
189
|
+
component.contextId = 'test-context';
|
|
190
|
+
component.handleViewerDestroyed();
|
|
191
|
+
|
|
192
|
+
expect(documentListService.refreshDocumentList).toHaveBeenCalledWith('test-context');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should build document categories', () => {
|
|
196
|
+
const mockResponse: DocumentListResponse[] = [{
|
|
197
|
+
label: 'Category 1',
|
|
198
|
+
categoryDescription: 'Test category',
|
|
199
|
+
totalDocs: 0,
|
|
200
|
+
acceptedDocs: 0,
|
|
201
|
+
list: [],
|
|
202
|
+
completed: '0%'
|
|
203
|
+
}];
|
|
204
|
+
component.documentListResponse = mockResponse;
|
|
205
|
+
|
|
206
|
+
component.buildDocumentCategories();
|
|
207
|
+
|
|
208
|
+
expect(documentListService.buildDocumentCategories).toHaveBeenCalledWith(mockResponse);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should cleanup on destroy', () => {
|
|
212
|
+
spyOn(component['documentListSubscription'], 'unsubscribe');
|
|
213
|
+
|
|
214
|
+
component.ngOnDestroy();
|
|
215
|
+
|
|
216
|
+
expect(component['documentListSubscription'].unsubscribe).toHaveBeenCalled();
|
|
217
|
+
expect(documentScrollService.disconnectSectionObserver).toHaveBeenCalled();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('ngOnChanges', () => {
|
|
221
|
+
it('should handle contextId changes', () => {
|
|
222
|
+
const changes = {
|
|
223
|
+
contextId: {
|
|
224
|
+
currentValue: 'new-context',
|
|
225
|
+
previousValue: 'old-context',
|
|
226
|
+
firstChange: false,
|
|
227
|
+
isFirstChange: () => false
|
|
228
|
+
}
|
|
229
|
+
} as any;
|
|
230
|
+
|
|
231
|
+
component.ngOnChanges(changes);
|
|
232
|
+
|
|
233
|
+
expect(documentListService.refreshDocumentListForNewContext).toHaveBeenCalledWith('new-context');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should handle selectedMenuItemId changes', () => {
|
|
237
|
+
component.selectedMenuItemId = 'test-menu-item';
|
|
238
|
+
const changes = {
|
|
239
|
+
selectedMenuItemId: {
|
|
240
|
+
currentValue: 'test-menu-item',
|
|
241
|
+
previousValue: null,
|
|
242
|
+
firstChange: false,
|
|
243
|
+
isFirstChange: () => false
|
|
244
|
+
}
|
|
245
|
+
} as any;
|
|
246
|
+
|
|
247
|
+
spyOn(component, 'scrollToCategorySection');
|
|
248
|
+
|
|
249
|
+
component.ngOnChanges(changes);
|
|
250
|
+
|
|
251
|
+
expect(component.scrollToCategorySection).toHaveBeenCalledWith('test-menu-item');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('should handle navigationInfo changes', () => {
|
|
255
|
+
const navigationInfo = {
|
|
256
|
+
menuItemId: 'test-menu',
|
|
257
|
+
menuItemLabel: 'Test Menu',
|
|
258
|
+
categoryLabel: 'Test Category',
|
|
259
|
+
categoryIndex: 0
|
|
260
|
+
};
|
|
261
|
+
component.navigationInfo = navigationInfo;
|
|
262
|
+
|
|
263
|
+
const changes = {
|
|
264
|
+
navigationInfo: {
|
|
265
|
+
currentValue: navigationInfo,
|
|
266
|
+
previousValue: null,
|
|
267
|
+
firstChange: false,
|
|
268
|
+
isFirstChange: () => false
|
|
269
|
+
}
|
|
270
|
+
} as any;
|
|
271
|
+
|
|
272
|
+
spyOn(component, 'scrollToCategorySectionWithNavigationInfo');
|
|
273
|
+
|
|
274
|
+
component.ngOnChanges(changes);
|
|
275
|
+
|
|
276
|
+
expect(component.scrollToCategorySectionWithNavigationInfo).toHaveBeenCalledWith(navigationInfo);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('should handle documentListResponse changes', () => {
|
|
280
|
+
const mockResponse: DocumentListResponse[] = [{
|
|
281
|
+
label: 'Category 1',
|
|
282
|
+
categoryDescription: 'Test category',
|
|
283
|
+
totalDocs: 0,
|
|
284
|
+
acceptedDocs: 0,
|
|
285
|
+
list: [],
|
|
286
|
+
completed: '0%'
|
|
287
|
+
}];
|
|
288
|
+
|
|
289
|
+
const changes = {
|
|
290
|
+
documentListResponse: {
|
|
291
|
+
currentValue: mockResponse,
|
|
292
|
+
previousValue: null,
|
|
293
|
+
firstChange: false,
|
|
294
|
+
isFirstChange: () => false
|
|
295
|
+
}
|
|
296
|
+
} as any;
|
|
297
|
+
|
|
298
|
+
component.ngOnChanges(changes);
|
|
299
|
+
|
|
300
|
+
// Since handleDocumentListFilteringChange is private, we can't spy on it directly
|
|
301
|
+
// Instead, we verify the component state changes appropriately
|
|
302
|
+
expect(component.documentListResponse).toBe(mockResponse);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('ngAfterViewInit', () => {
|
|
307
|
+
it('should setup scroll listeners and scroll to selected menu item', () => {
|
|
308
|
+
component.selectedMenuItemId = 'test-menu-item';
|
|
309
|
+
component.documentCategoriesContainer = { nativeElement: {} } as any;
|
|
310
|
+
|
|
311
|
+
spyOn(component, 'scrollToCategorySection');
|
|
312
|
+
|
|
313
|
+
component.ngAfterViewInit();
|
|
314
|
+
|
|
315
|
+
expect(documentScrollService.setupScrollListeners).toHaveBeenCalled();
|
|
316
|
+
expect(component.scrollToCategorySection).toHaveBeenCalledWith('test-menu-item');
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe('scrollToCategorySection', () => {
|
|
321
|
+
beforeEach(() => {
|
|
322
|
+
component.documentCategories = [
|
|
323
|
+
{ label: 'Application', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' },
|
|
324
|
+
{ label: 'Applicant', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' },
|
|
325
|
+
{ label: 'Affordability Calculators', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' },
|
|
326
|
+
{ label: 'Affordability', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' }
|
|
327
|
+
];
|
|
328
|
+
component.documentCategoriesContainer = {
|
|
329
|
+
nativeElement: {
|
|
330
|
+
querySelectorAll: jasmine.createSpy('querySelectorAll').and.returnValue([
|
|
331
|
+
{ scrollIntoView: jasmine.createSpy('scrollIntoView') }
|
|
332
|
+
])
|
|
333
|
+
}
|
|
334
|
+
} as any;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should scroll to exact match category when menu item matches exactly', () => {
|
|
338
|
+
component.scrollToCategorySection('affordability-calculators');
|
|
339
|
+
|
|
340
|
+
expect(documentScrollService.setScrolling).toHaveBeenCalled();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('should not match partial strings (affordability should not match affordability-calculators)', () => {
|
|
344
|
+
component.scrollToCategorySection('affordability');
|
|
345
|
+
|
|
346
|
+
expect(documentScrollService.setScrolling).toHaveBeenCalled();
|
|
347
|
+
// Should match the exact "Affordability" category, not "Affordability Calculators"
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should use legacy matching for application category', () => {
|
|
351
|
+
component.scrollToCategorySection('application-menu-item');
|
|
352
|
+
|
|
353
|
+
expect(documentScrollService.setScrolling).toHaveBeenCalled();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('should use legacy matching for applicant category', () => {
|
|
357
|
+
component.scrollToCategorySection('applicant-menu-item');
|
|
358
|
+
|
|
359
|
+
expect(documentScrollService.setScrolling).toHaveBeenCalled();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should fall back to first category when no match found', () => {
|
|
363
|
+
component.scrollToCategorySection('nonexistent-category');
|
|
364
|
+
|
|
365
|
+
expect(documentScrollService.setScrolling).toHaveBeenCalled();
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
describe('private helper methods', () => {
|
|
370
|
+
it('should convert menuItemId to readable label format', () => {
|
|
371
|
+
const result = component['convertMenuItemIdToReadableLabel']('affordability-calculators');
|
|
372
|
+
expect(result).toBe('Affordability Calculators');
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('should convert snake_case menuItemId to readable label format', () => {
|
|
376
|
+
const result = component['convertMenuItemIdToReadableLabel']('affordability_calculators');
|
|
377
|
+
expect(result).toBe('Affordability Calculators');
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('should detect substring relationships correctly', () => {
|
|
381
|
+
const isSubstring = component['isSubstringOfLongerCategory']('affordability', 'affordability calculators');
|
|
382
|
+
expect(isSubstring).toBeTrue();
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('should not detect substring when lengths are similar', () => {
|
|
386
|
+
const isSubstring = component['isSubstringOfLongerCategory']('affordability', 'affordability');
|
|
387
|
+
expect(isSubstring).toBeFalse();
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe('highlightCategory', () => {
|
|
392
|
+
it('should add and remove highlight class', (done) => {
|
|
393
|
+
const mockElement = {
|
|
394
|
+
classList: {
|
|
395
|
+
add: jasmine.createSpy('add'),
|
|
396
|
+
remove: jasmine.createSpy('remove')
|
|
397
|
+
}
|
|
398
|
+
} as any;
|
|
399
|
+
|
|
400
|
+
component.highlightCategory(mockElement);
|
|
401
|
+
|
|
402
|
+
expect(mockElement.classList.add).toHaveBeenCalledWith('category-highlight');
|
|
403
|
+
|
|
404
|
+
setTimeout(() => {
|
|
405
|
+
expect(mockElement.classList.remove).toHaveBeenCalledWith('category-highlight');
|
|
406
|
+
done();
|
|
407
|
+
}, 2100);
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
describe('getters', () => {
|
|
412
|
+
beforeEach(() => {
|
|
413
|
+
component.documentCategories = [
|
|
414
|
+
{ label: 'Category 1', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' },
|
|
415
|
+
{ label: 'Category 2', categoryDescription: '', totalDocs: 0, acceptedDocs: 0, list: [], completed: '0%' }
|
|
416
|
+
];
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('should return formatted category labels', () => {
|
|
420
|
+
expect(component.formattedCategoryLabels).toEqual(['Category 1', 'Category 2']);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('should return safe category IDs', () => {
|
|
424
|
+
expect(component.categoryIds).toEqual(['section-category-1', 'section-category-2']);
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
describe('error handling', () => {
|
|
429
|
+
it('should show delete error message with custom message', () => {
|
|
430
|
+
const error = { error: { message: 'Custom error message' } };
|
|
431
|
+
component.handleDeleteError(error);
|
|
432
|
+
|
|
433
|
+
expect(component.deleteMessage).toEqual([{severity: 'error', detail: 'Custom error message'}]);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('should show delete error message with fallback message', () => {
|
|
437
|
+
const error = { message: 'Fallback error message' };
|
|
438
|
+
component.handleDeleteError(error);
|
|
439
|
+
|
|
440
|
+
expect(component.deleteMessage).toEqual([{severity: 'error', detail: 'Fallback error message'}]);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('should show default error message when no specific message', () => {
|
|
444
|
+
const error = {};
|
|
445
|
+
component.handleDeleteError(error);
|
|
446
|
+
|
|
447
|
+
expect(component.deleteMessage).toEqual([{severity: 'error', detail: 'Failed to delete document. Please try again.'}]);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
describe('menu visibility logic', () => {
|
|
452
|
+
it('should check menu item visibility correctly', () => {
|
|
453
|
+
const mockResponse: DocumentListResponse[] = [
|
|
454
|
+
{
|
|
455
|
+
label: 'Affordability Calculators',
|
|
456
|
+
categoryDescription: 'Test category',
|
|
457
|
+
totalDocs: 1,
|
|
458
|
+
acceptedDocs: 0,
|
|
459
|
+
list: [{ _id: '1', fileName: 'test.pdf', docName: 'Test', fileSize: '1MB', documentUrl: 'url', status: 'pending', isUploaded: true, uploadedOn: '2023-01-01', ownerName: 'User', contentType: 'pdf' }],
|
|
460
|
+
completed: '0%'
|
|
461
|
+
}
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
component.documentListResponse = mockResponse;
|
|
465
|
+
component.selectedMenuItemId = 'affordability';
|
|
466
|
+
|
|
467
|
+
// Mock the menu service to return false for affordability (should not match affordability calculators)
|
|
468
|
+
documentMenuService.isMenuItemSectionVisible.and.returnValue(false);
|
|
469
|
+
|
|
470
|
+
// Trigger the filtering change
|
|
471
|
+
const changes = {
|
|
472
|
+
documentListResponse: {
|
|
473
|
+
currentValue: mockResponse,
|
|
474
|
+
previousValue: null,
|
|
475
|
+
firstChange: false,
|
|
476
|
+
isFirstChange: () => false
|
|
477
|
+
}
|
|
478
|
+
} as any;
|
|
479
|
+
|
|
480
|
+
component.ngOnChanges(changes);
|
|
481
|
+
|
|
482
|
+
expect(documentMenuService.isMenuItemSectionVisible).toHaveBeenCalledWith('affordability', mockResponse);
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
});
|