diff --git a/.github/acs-deployment-values-override.yaml b/.github/acs-deployment-values-override.yaml index 90a99f5f8..a6e900e4c 100644 --- a/.github/acs-deployment-values-override.yaml +++ b/.github/acs-deployment-values-override.yaml @@ -18,7 +18,7 @@ kibana-audit: enabled: false alfresco-repository: image: - tag: 25.1.0-A.16 + tag: latest global: imagePullSecrets: - name: regcred diff --git a/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.spec.ts b/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.spec.ts index 8fa8ef8fc..ba3eeff0c 100644 --- a/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.spec.ts +++ b/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.spec.ts @@ -24,9 +24,8 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { FolderInformationComponent } from './folder-information.component'; -import { DIALOG_COMPONENT_DATA, RedirectAuthService } from '@alfresco/adf-core'; +import { DIALOG_COMPONENT_DATA, RedirectAuthService, UnitTestingUtils } from '@alfresco/adf-core'; import { ContentService, NodesApiService } from '@alfresco/adf-content-services'; -import { By } from '@angular/platform-browser'; import { EMPTY, Observable, of, Subject } from 'rxjs'; import { LibTestingModule } from '@alfresco/aca-shared'; import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry, Node } from '@alfresco/js-api'; @@ -34,6 +33,7 @@ import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry, Node } from '@alfresco/j describe('FolderInformationComponent', () => { let fixture: ComponentFixture; let nodeService: NodesApiService; + let unitTestingUtils: UnitTestingUtils; let initiateFolderSizeCalculationSpy: jasmine.Spy<(nodeId: string) => Observable>; let getFolderSizeInfoSpy: jasmine.Spy<(nodeId: string, jobId: string) => Observable>; @@ -58,8 +58,6 @@ describe('FolderInformationComponent', () => { } }; - const getValueFromElement = (id: string): string => fixture.debugElement.query(By.css(`[data-automation-id="${id}"]`)).nativeElement.textContent; - beforeEach(() => { TestBed.configureTestingModule({ imports: [FolderInformationComponent, LibTestingModule], @@ -70,6 +68,7 @@ describe('FolderInformationComponent', () => { }); fixture = TestBed.createComponent(FolderInformationComponent); nodeService = TestBed.inject(NodesApiService); + unitTestingUtils = new UnitTestingUtils(fixture.debugElement); spyOn(TestBed.inject(ContentService), 'getNodeIcon').and.returnValue('./assets/images/ft_ic_folder.svg'); initiateFolderSizeCalculationSpy = spyOn(nodeService, 'initiateFolderSizeCalculation').and.returnValue(mockSub.asObservable()); getFolderSizeInfoSpy = spyOn(nodeService, 'getFolderSizeInfo').and.returnValue(EMPTY); @@ -77,11 +76,11 @@ describe('FolderInformationComponent', () => { it('should render all information in init', () => { fixture.detectChanges(); - expect(getValueFromElement('folder-info-name')).toBe('mock-folder'); - expect(getValueFromElement('folder-info-size')).toBe('APP.FOLDER_INFO.CALCULATING'); - expect(getValueFromElement('folder-info-location')).toBe('mock-folder-path'); - expect(getValueFromElement('folder-info-creation-date')).toBe('01/02/2024 11:11'); - expect(getValueFromElement('folder-info-modify-date')).toBe('02/03/2024 22:22'); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-name')).toBe('mock-folder'); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-size')).toBe('APP.FOLDER_INFO.CALCULATING'); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-location')).toBe('mock-folder-path'); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-creation-date')).toBe('01/02/2024 11:11'); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-modify-date')).toBe('02/03/2024 22:22'); }); it('should make API call on init to start folder size calculation', () => { @@ -89,13 +88,15 @@ describe('FolderInformationComponent', () => { expect(initiateFolderSizeCalculationSpy).toHaveBeenCalledWith('mock-folder-id'); }); - it('should fetch folder size only when the initial folder size calculation request is completed', () => { + it('should fetch folder size only when the initial folder size calculation request is completed and one second has passed', fakeAsync(() => { fixture.detectChanges(); expect(initiateFolderSizeCalculationSpy).toHaveBeenCalledWith('mock-folder-id'); expect(getFolderSizeInfoSpy).not.toHaveBeenCalled(); mockSub.next({ entry: { jobId: 'mock-job-id' } }); + expect(getFolderSizeInfoSpy).not.toHaveBeenCalled(); + tick(1000); expect(getFolderSizeInfoSpy).toHaveBeenCalled(); - }); + })); it('should make repeated calls to get folder size info, if the response returned from the API is IN_PROGRESS', fakeAsync(() => { mockSizeDetailsEntry.entry.status = SizeDetails.StatusEnum.IN_PROGRESS; @@ -103,6 +104,7 @@ describe('FolderInformationComponent', () => { fixture.detectChanges(); expect(getFolderSizeInfoSpy).not.toHaveBeenCalled(); mockSub.next({ entry: { jobId: 'mock-job-id' } }); + tick(1000); expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(1); tick(5000); expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(2); @@ -114,4 +116,17 @@ describe('FolderInformationComponent', () => { tick(5000); expect(getFolderSizeInfoSpy).not.toHaveBeenCalledTimes(5); })); + + it('should not make new API request, and display error message if response returned from API is neither COMPLETE, nor IN_PROGRESS', fakeAsync(() => { + mockSizeDetailsEntry.entry.status = SizeDetails.StatusEnum.NOT_INITIATED; + getFolderSizeInfoSpy.and.returnValue(of(mockSizeDetailsEntry)); + fixture.detectChanges(); + mockSub.next({ entry: { jobId: 'mock-job-id' } }); + tick(1000); + fixture.detectChanges(); + expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(1); + expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-size')).toBe('APP.FOLDER_INFO.ERROR'); + tick(5000); + expect(getFolderSizeInfoSpy).not.toHaveBeenCalledTimes(2); + })); }); diff --git a/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.ts b/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.ts index e63d01bef..84fe8c4dd 100644 --- a/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.ts +++ b/projects/aca-content/src/lib/dialogs/folder-details/folder-information.component.ts @@ -29,7 +29,7 @@ import { Node, SizeDetails } from '@alfresco/js-api'; import { MatDividerModule } from '@angular/material/divider'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { ContentService, NodesApiService } from '@alfresco/adf-content-services'; -import { catchError, concatMap, expand, first, switchMap } from 'rxjs/operators'; +import { catchError, concatMap, delay, expand, first, switchMap } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { EMPTY, of, timer } from 'rxjs'; @@ -75,6 +75,7 @@ export class FolderInformationComponent implements OnInit { .initiateFolderSizeCalculation(this.data.id) .pipe( first(), + delay(1000), switchMap((jobIdEntry) => { return this.nodesService.getFolderSizeInfo(this.data.id, jobIdEntry.entry.jobId).pipe( expand((result) => @@ -114,7 +115,7 @@ export class FolderInformationComponent implements OnInit { isMoreThanBytes ? 'APP.FOLDER_INFO.CALCULATED_SIZE_LARGE' : 'APP.FOLDER_INFO.CALCULATED_SIZE_NORMAL', params ); - } else { + } else if (folderInfo?.entry?.status !== SizeDetails.StatusEnum.IN_PROGRESS) { this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.ERROR'); } });