cat-documents-ng 1.0.6 → 1.0.7
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/README.md +322 -322
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
- package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
- package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
- package/Shared/constant/ERROR.d.ts +52 -0
- package/Shared/constant/SHARED.d.ts +546 -0
- package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +25 -31
- package/Shared/services/app-config.service.d.ts +51 -0
- package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
- package/Shared/services/session.service.d.ts +46 -0
- package/Shared/shared.module.d.ts +14 -0
- package/fesm2022/cat-documents-ng.mjs +11405 -0
- package/fesm2022/cat-documents-ng.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
- package/lib/document/components/document-container/document-container.component.d.ts +162 -0
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
- package/lib/document/components/document-history/document-history.component.d.ts +160 -0
- package/lib/document/components/document-list/document-list.component.d.ts +299 -0
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
- package/lib/document/components/document-search/document-search.component.d.ts +77 -0
- package/lib/document/components/document-status/document-status.component.d.ts +24 -0
- package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
- package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -28
- package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
- package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
- package/lib/document/components/request-document/request-document.component.d.ts +69 -0
- package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
- package/lib/document/components/user-list/user-list.component.d.ts +34 -0
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
- package/lib/document/directives/document.directive.d.ts +20 -0
- package/lib/document/directives/permission.directive.d.ts +38 -0
- package/lib/document/document.module.d.ts +60 -0
- package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +4 -11
- package/lib/document/models/document-category.model.d.ts +24 -0
- package/lib/document/models/document-history.model.d.ts +94 -0
- package/lib/document/models/document-list-response.model.d.ts +33 -0
- package/lib/document/models/document-type.model.d.ts +37 -0
- package/lib/document/models/document.model.d.ts +44 -0
- package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +4 -10
- package/lib/document/models/status-data.model.d.ts +27 -0
- package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
- package/lib/document/models/user-list.model.d.ts +8 -0
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-actions.service.d.ts +48 -0
- package/lib/document/services/document-content-type.service.d.ts +85 -0
- package/lib/document/services/document-history-style.service.d.ts +34 -0
- package/lib/document/services/document-history.service.d.ts +42 -0
- package/lib/document/services/document-http.service.d.ts +179 -0
- package/lib/document/services/document-list.service.d.ts +74 -0
- package/lib/document/services/document-menu.service.d.ts +122 -0
- package/lib/document/services/document-scroll.service.d.ts +55 -0
- package/lib/document/services/document-table-builder.service.d.ts +38 -0
- package/lib/document/services/document-upload-business.service.d.ts +107 -0
- package/lib/document/services/document-upload-data.service.d.ts +40 -0
- package/lib/document/services/document-upload-form.service.d.ts +41 -0
- package/lib/document/services/document-upload.service.d.ts +99 -0
- package/lib/document/services/document-viewer.service.d.ts +97 -0
- package/lib/document/services/document-zoom.service.d.ts +81 -0
- package/lib/document/services/document.service.d.ts +161 -0
- package/lib/document/services/eml-parser.service.d.ts +116 -0
- package/lib/document/services/excel-parser.service.d.ts +169 -0
- package/lib/document/services/file-format.service.d.ts +34 -0
- package/lib/document/services/status-calculator.service.d.ts +20 -0
- package/lib/document/services/user-list.service.d.ts +29 -0
- package/lib/document/state/document.query.d.ts +243 -0
- package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
- package/lib/document/state/document.state.d.ts +61 -0
- package/lib/document/state/document.store.d.ts +56 -0
- package/package.json +11 -5
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -10
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.html +0 -3
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.scss +0 -13
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -70
- package/src/Shared/components/confirmation-dialog/confirmation-dialog.component.ts +0 -133
- package/src/Shared/components/table-primary/table-primary.component.html +0 -66
- package/src/Shared/components/table-primary/table-primary.component.scss +0 -227
- package/src/Shared/components/table-primary/table-primary.component.spec.ts +0 -23
- package/src/Shared/components/table-primary/table-primary.component.ts +0 -143
- package/src/Shared/components/table-primary/table-primary.model.ts +0 -21
- package/src/Shared/constant/ERROR.ts +0 -55
- package/src/Shared/constant/PERMISSIONS.ts +0 -17
- package/src/Shared/constant/SHARED.ts +0 -936
- package/src/Shared/services/app-config.service.spec.ts +0 -19
- package/src/Shared/services/app-config.service.ts +0 -73
- package/src/Shared/services/session.service.spec.ts +0 -16
- package/src/Shared/services/session.service.ts +0 -76
- package/src/Shared/shared.module.ts +0 -25
- package/src/lib/document/components/csv-viewer/csv-viewer.component.ts +0 -1
- package/src/lib/document/components/document-actions/document-actions.component.html +0 -59
- package/src/lib/document/components/document-actions/document-actions.component.scss +0 -362
- package/src/lib/document/components/document-actions/document-actions.component.spec.ts +0 -297
- package/src/lib/document/components/document-actions/document-actions.component.ts +0 -163
- package/src/lib/document/components/document-container/document-container.component.html +0 -36
- package/src/lib/document/components/document-container/document-container.component.scss +0 -144
- package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
- package/src/lib/document/components/document-container/document-container.component.ts +0 -363
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.html +0 -332
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.scss +0 -1877
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.spec.ts +0 -258
- package/src/lib/document/components/document-content-viewer/document-content-viewer.component.ts +0 -664
- package/src/lib/document/components/document-history/document-history.component.html +0 -96
- package/src/lib/document/components/document-history/document-history.component.scss +0 -392
- package/src/lib/document/components/document-history/document-history.component.spec.ts +0 -93
- package/src/lib/document/components/document-history/document-history.component.ts +0 -373
- package/src/lib/document/components/document-list/document-list.component.html +0 -46
- package/src/lib/document/components/document-list/document-list.component.scss +0 -513
- package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -486
- package/src/lib/document/components/document-list/document-list.component.ts +0 -682
- package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
- package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
- package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
- package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
- package/src/lib/document/components/document-search/document-search.component.html +0 -64
- package/src/lib/document/components/document-search/document-search.component.scss +0 -206
- package/src/lib/document/components/document-search/document-search.component.spec.ts +0 -82
- package/src/lib/document/components/document-search/document-search.component.ts +0 -163
- package/src/lib/document/components/document-status/document-status.component.html +0 -31
- package/src/lib/document/components/document-status/document-status.component.scss +0 -192
- package/src/lib/document/components/document-status/document-status.component.spec.ts +0 -23
- package/src/lib/document/components/document-status/document-status.component.ts +0 -87
- package/src/lib/document/components/document-upload/document-upload.component.html +0 -160
- package/src/lib/document/components/document-upload/document-upload.component.scss +0 -235
- package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
- package/src/lib/document/components/document-upload/document-upload.component.ts +0 -668
- package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -50
- package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -187
- package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
- package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -261
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.html +0 -48
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.scss +0 -320
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.spec.ts +0 -59
- package/src/lib/document/components/document-zoom-controls/document-zoom-controls.component.ts +0 -150
- package/src/lib/document/components/documents-menu/documents-menu.component.html +0 -44
- package/src/lib/document/components/documents-menu/documents-menu.component.scss +0 -363
- package/src/lib/document/components/documents-menu/documents-menu.component.spec.ts +0 -23
- package/src/lib/document/components/documents-menu/documents-menu.component.ts +0 -316
- package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
- package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
- package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
- package/src/lib/document/components/folder-container/folder-container.component.html +0 -56
- package/src/lib/document/components/folder-container/folder-container.component.scss +0 -20
- package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
- package/src/lib/document/components/folder-container/folder-container.component.ts +0 -328
- package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
- package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
- package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
- package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
- package/src/lib/document/components/request-document/request-document.component.html +0 -86
- package/src/lib/document/components/request-document/request-document.component.scss +0 -16
- package/src/lib/document/components/request-document/request-document.component.ts +0 -278
- package/src/lib/document/components/sidebar/sidebar.component.html +0 -75
- package/src/lib/document/components/sidebar/sidebar.component.scss +0 -157
- package/src/lib/document/components/sidebar/sidebar.component.spec.ts +0 -114
- package/src/lib/document/components/sidebar/sidebar.component.ts +0 -223
- package/src/lib/document/components/user-list/user-list.component.html +0 -33
- package/src/lib/document/components/user-list/user-list.component.scss +0 -118
- package/src/lib/document/components/user-list/user-list.component.spec.ts +0 -23
- package/src/lib/document/components/user-list/user-list.component.ts +0 -181
- package/src/lib/document/constant/DOCUMENT_HISTORY.ts +0 -52
- package/src/lib/document/directives/document.directive.ts +0 -32
- package/src/lib/document/directives/permission.directive.spec.ts +0 -0
- package/src/lib/document/directives/permission.directive.ts +0 -72
- package/src/lib/document/document.module.ts +0 -351
- package/src/lib/document/models/document-category.model.ts +0 -30
- package/src/lib/document/models/document-history.model.ts +0 -109
- package/src/lib/document/models/document-list-response.model.ts +0 -37
- package/src/lib/document/models/document-type.model.ts +0 -44
- package/src/lib/document/models/document.model.ts +0 -53
- package/src/lib/document/models/status-data.model.ts +0 -31
- package/src/lib/document/models/uploaded-file-response.model.ts +0 -7
- package/src/lib/document/models/user-list.model.ts +0 -10
- package/src/lib/document/services/csv-parser.service.spec.ts +0 -97
- package/src/lib/document/services/csv-parser.service.ts +0 -303
- package/src/lib/document/services/document-actions.service.ts +0 -125
- package/src/lib/document/services/document-content-type.service.ts +0 -193
- package/src/lib/document/services/document-history-style.service.ts +0 -138
- package/src/lib/document/services/document-history.service.ts +0 -129
- package/src/lib/document/services/document-http.service.spec.ts +0 -119
- package/src/lib/document/services/document-http.service.ts +0 -497
- package/src/lib/document/services/document-list.service.ts +0 -195
- package/src/lib/document/services/document-menu.service.ts +0 -277
- package/src/lib/document/services/document-scroll.service.ts +0 -138
- package/src/lib/document/services/document-severity.service.ts +0 -98
- package/src/lib/document/services/document-table-builder.service.ts +0 -82
- package/src/lib/document/services/document-upload-business.service.ts +0 -326
- package/src/lib/document/services/document-upload-data.service.ts +0 -82
- package/src/lib/document/services/document-upload-form.service.ts +0 -149
- package/src/lib/document/services/document-upload.service.spec.ts +0 -99
- package/src/lib/document/services/document-upload.service.ts +0 -209
- package/src/lib/document/services/document-viewer.service.ts +0 -279
- package/src/lib/document/services/document-zoom.service.spec.ts +0 -56
- package/src/lib/document/services/document-zoom.service.ts +0 -164
- package/src/lib/document/services/document.service.ts +0 -356
- package/src/lib/document/services/eml-parser.service.ts +0 -444
- package/src/lib/document/services/excel-parser.service.spec.ts +0 -66
- package/src/lib/document/services/excel-parser.service.ts +0 -483
- package/src/lib/document/services/file-format.service.spec.ts +0 -16
- package/src/lib/document/services/file-format.service.ts +0 -63
- package/src/lib/document/services/status-calculator.service.ts +0 -44
- package/src/lib/document/services/user-list.service.ts +0 -77
- package/src/lib/document/state/document.query.ts +0 -378
- package/src/lib/document/state/document.state.ts +0 -100
- package/src/lib/document/state/document.store.ts +0 -200
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -1,486 +0,0 @@
|
|
|
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
|
-
});
|