mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-9466] Folder information dialog no longer displays error message if response returned from API is "IN_PROGRESS' (#4498)
* [ACS-9466] Added delay between folder size initiation and folder size retrieval APIs. Added case to check if folder size calculation is in progress or not, before displaying error message. Updated unit test * [ACS-9466] Added unit test * [ACS-9466] Updated unit test * [ACS-9466] E2Es should now use latest version of alfresco content repository on GHA
This commit is contained in:
parent
d8acd1954b
commit
ba75c0b233
2
.github/acs-deployment-values-override.yaml
vendored
2
.github/acs-deployment-values-override.yaml
vendored
@ -18,7 +18,7 @@ kibana-audit:
|
|||||||
enabled: false
|
enabled: false
|
||||||
alfresco-repository:
|
alfresco-repository:
|
||||||
image:
|
image:
|
||||||
tag: 25.1.0-A.16
|
tag: latest
|
||||||
global:
|
global:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
|
@ -24,9 +24,8 @@
|
|||||||
|
|
||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { FolderInformationComponent } from './folder-information.component';
|
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 { ContentService, NodesApiService } from '@alfresco/adf-content-services';
|
||||||
import { By } from '@angular/platform-browser';
|
|
||||||
import { EMPTY, Observable, of, Subject } from 'rxjs';
|
import { EMPTY, Observable, of, Subject } from 'rxjs';
|
||||||
import { LibTestingModule } from '@alfresco/aca-shared';
|
import { LibTestingModule } from '@alfresco/aca-shared';
|
||||||
import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry, Node } from '@alfresco/js-api';
|
import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry, Node } from '@alfresco/js-api';
|
||||||
@ -34,6 +33,7 @@ import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry, Node } from '@alfresco/j
|
|||||||
describe('FolderInformationComponent', () => {
|
describe('FolderInformationComponent', () => {
|
||||||
let fixture: ComponentFixture<FolderInformationComponent>;
|
let fixture: ComponentFixture<FolderInformationComponent>;
|
||||||
let nodeService: NodesApiService;
|
let nodeService: NodesApiService;
|
||||||
|
let unitTestingUtils: UnitTestingUtils;
|
||||||
let initiateFolderSizeCalculationSpy: jasmine.Spy<(nodeId: string) => Observable<JobIdBodyEntry>>;
|
let initiateFolderSizeCalculationSpy: jasmine.Spy<(nodeId: string) => Observable<JobIdBodyEntry>>;
|
||||||
let getFolderSizeInfoSpy: jasmine.Spy<(nodeId: string, jobId: string) => Observable<SizeDetailsEntry>>;
|
let getFolderSizeInfoSpy: jasmine.Spy<(nodeId: string, jobId: string) => Observable<SizeDetailsEntry>>;
|
||||||
|
|
||||||
@ -58,8 +58,6 @@ describe('FolderInformationComponent', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValueFromElement = (id: string): string => fixture.debugElement.query(By.css(`[data-automation-id="${id}"]`)).nativeElement.textContent;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [FolderInformationComponent, LibTestingModule],
|
imports: [FolderInformationComponent, LibTestingModule],
|
||||||
@ -70,6 +68,7 @@ describe('FolderInformationComponent', () => {
|
|||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(FolderInformationComponent);
|
fixture = TestBed.createComponent(FolderInformationComponent);
|
||||||
nodeService = TestBed.inject(NodesApiService);
|
nodeService = TestBed.inject(NodesApiService);
|
||||||
|
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||||
spyOn(TestBed.inject(ContentService), 'getNodeIcon').and.returnValue('./assets/images/ft_ic_folder.svg');
|
spyOn(TestBed.inject(ContentService), 'getNodeIcon').and.returnValue('./assets/images/ft_ic_folder.svg');
|
||||||
initiateFolderSizeCalculationSpy = spyOn(nodeService, 'initiateFolderSizeCalculation').and.returnValue(mockSub.asObservable());
|
initiateFolderSizeCalculationSpy = spyOn(nodeService, 'initiateFolderSizeCalculation').and.returnValue(mockSub.asObservable());
|
||||||
getFolderSizeInfoSpy = spyOn(nodeService, 'getFolderSizeInfo').and.returnValue(EMPTY);
|
getFolderSizeInfoSpy = spyOn(nodeService, 'getFolderSizeInfo').and.returnValue(EMPTY);
|
||||||
@ -77,11 +76,11 @@ describe('FolderInformationComponent', () => {
|
|||||||
|
|
||||||
it('should render all information in init', () => {
|
it('should render all information in init', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(getValueFromElement('folder-info-name')).toBe('mock-folder');
|
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-name')).toBe('mock-folder');
|
||||||
expect(getValueFromElement('folder-info-size')).toBe('APP.FOLDER_INFO.CALCULATING');
|
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-size')).toBe('APP.FOLDER_INFO.CALCULATING');
|
||||||
expect(getValueFromElement('folder-info-location')).toBe('mock-folder-path');
|
expect(unitTestingUtils.getInnerTextByDataAutomationId('folder-info-location')).toBe('mock-folder-path');
|
||||||
expect(getValueFromElement('folder-info-creation-date')).toBe('01/02/2024 11:11');
|
expect(unitTestingUtils.getInnerTextByDataAutomationId('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-modify-date')).toBe('02/03/2024 22:22');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make API call on init to start folder size calculation', () => {
|
it('should make API call on init to start folder size calculation', () => {
|
||||||
@ -89,13 +88,15 @@ describe('FolderInformationComponent', () => {
|
|||||||
expect(initiateFolderSizeCalculationSpy).toHaveBeenCalledWith('mock-folder-id');
|
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();
|
fixture.detectChanges();
|
||||||
expect(initiateFolderSizeCalculationSpy).toHaveBeenCalledWith('mock-folder-id');
|
expect(initiateFolderSizeCalculationSpy).toHaveBeenCalledWith('mock-folder-id');
|
||||||
expect(getFolderSizeInfoSpy).not.toHaveBeenCalled();
|
expect(getFolderSizeInfoSpy).not.toHaveBeenCalled();
|
||||||
mockSub.next({ entry: { jobId: 'mock-job-id' } });
|
mockSub.next({ entry: { jobId: 'mock-job-id' } });
|
||||||
|
expect(getFolderSizeInfoSpy).not.toHaveBeenCalled();
|
||||||
|
tick(1000);
|
||||||
expect(getFolderSizeInfoSpy).toHaveBeenCalled();
|
expect(getFolderSizeInfoSpy).toHaveBeenCalled();
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should make repeated calls to get folder size info, if the response returned from the API is IN_PROGRESS', fakeAsync(() => {
|
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;
|
mockSizeDetailsEntry.entry.status = SizeDetails.StatusEnum.IN_PROGRESS;
|
||||||
@ -103,6 +104,7 @@ describe('FolderInformationComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(getFolderSizeInfoSpy).not.toHaveBeenCalled();
|
expect(getFolderSizeInfoSpy).not.toHaveBeenCalled();
|
||||||
mockSub.next({ entry: { jobId: 'mock-job-id' } });
|
mockSub.next({ entry: { jobId: 'mock-job-id' } });
|
||||||
|
tick(1000);
|
||||||
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(1);
|
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(1);
|
||||||
tick(5000);
|
tick(5000);
|
||||||
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(2);
|
expect(getFolderSizeInfoSpy).toHaveBeenCalledTimes(2);
|
||||||
@ -114,4 +116,17 @@ describe('FolderInformationComponent', () => {
|
|||||||
tick(5000);
|
tick(5000);
|
||||||
expect(getFolderSizeInfoSpy).not.toHaveBeenCalledTimes(5);
|
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);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,7 @@ import { Node, SizeDetails } from '@alfresco/js-api';
|
|||||||
import { MatDividerModule } from '@angular/material/divider';
|
import { MatDividerModule } from '@angular/material/divider';
|
||||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
import { ContentService, NodesApiService } from '@alfresco/adf-content-services';
|
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 { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
import { EMPTY, of, timer } from 'rxjs';
|
import { EMPTY, of, timer } from 'rxjs';
|
||||||
|
|
||||||
@ -75,6 +75,7 @@ export class FolderInformationComponent implements OnInit {
|
|||||||
.initiateFolderSizeCalculation(this.data.id)
|
.initiateFolderSizeCalculation(this.data.id)
|
||||||
.pipe(
|
.pipe(
|
||||||
first(),
|
first(),
|
||||||
|
delay(1000),
|
||||||
switchMap((jobIdEntry) => {
|
switchMap((jobIdEntry) => {
|
||||||
return this.nodesService.getFolderSizeInfo(this.data.id, jobIdEntry.entry.jobId).pipe(
|
return this.nodesService.getFolderSizeInfo(this.data.id, jobIdEntry.entry.jobId).pipe(
|
||||||
expand((result) =>
|
expand((result) =>
|
||||||
@ -114,7 +115,7 @@ export class FolderInformationComponent implements OnInit {
|
|||||||
isMoreThanBytes ? 'APP.FOLDER_INFO.CALCULATED_SIZE_LARGE' : 'APP.FOLDER_INFO.CALCULATED_SIZE_NORMAL',
|
isMoreThanBytes ? 'APP.FOLDER_INFO.CALCULATED_SIZE_LARGE' : 'APP.FOLDER_INFO.CALCULATED_SIZE_NORMAL',
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
} else {
|
} else if (folderInfo?.entry?.status !== SizeDetails.StatusEnum.IN_PROGRESS) {
|
||||||
this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.ERROR');
|
this.folderDetails.size = this.translateService.instant('APP.FOLDER_INFO.ERROR');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user