[ADF-5263] Empty page displayed all the time when load content fix (#6209)

* Make test run on API update
Improve create librrary test

* Fix empty page displayed always first

* remvoe console

* fix

* fix

* lint

* fix

* fix

* fix

* fix

* fix
This commit is contained in:
Eugenio Romano
2020-10-05 00:26:56 +01:00
committed by GitHub
parent d128bc158c
commit 04f5fdffd7
27 changed files with 174 additions and 179 deletions

View File

@@ -1588,12 +1588,12 @@ describe('DocumentList', () => {
expect(nodeSelectedSpy).not.toHaveBeenCalled();
});
});
});
});
@Component({
template: `
<adf-document-list currentFolderId="-my-" #customDocumentList>
<adf-document-list #customDocumentList>
<adf-custom-loading-content-template>
<span id="custom-loading-template">This is a custom loading template</span>
</adf-custom-loading-content-template>
@@ -1685,4 +1685,5 @@ describe('DocumentListComponent rendering', () => {
const cell3 = fixture.nativeElement.querySelector('div[title="Id"][data-automation-id="Name 3"]');
expect(cell3.innerText).toBe('3');
});
});

View File

@@ -481,18 +481,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
}
if (changes['currentFolderId']?.currentValue !== changes['currentFolderId']?.previousValue) {
if (this.data) {
this.data.loadPage(null, false, null, this.getPreselectNodesBasedOnSelectionMode());
this.onPreselectNodes();
this.resetNewFolderPagination();
}
if (changes['currentFolderId'].currentValue) {
this.loadFolder();
}
if (this.currentFolderId && changes['currentFolderId']?.currentValue !== changes['currentFolderId']?.previousValue) {
this.loadFolder();
}
if (this.data) {
@@ -659,14 +649,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
}
private setLoadingState(value: boolean) {
if (value) {
clearTimeout(this.loadingTimeout);
this.loadingTimeout = setTimeout(() => {
this.loading = true;
}, 1000);
if (this.data?.getRows().length > 0) {
if (value) {
clearTimeout(this.loadingTimeout);
this.loadingTimeout = setTimeout(() => {
this.loading = true;
}, 1000);
} else {
clearTimeout(this.loadingTimeout);
this.loading = false;
}
} else {
clearTimeout(this.loadingTimeout);
this.loading = false;
this.loading = value;
}
}

View File

@@ -127,7 +127,6 @@ export class DocumentListService implements DocumentListLoader {
* @returns Details of the folder
*/
getNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'definition', ...includeFields]
.filter((element, index, array) => index === array.indexOf(element));
@@ -146,7 +145,6 @@ export class DocumentListService implements DocumentListLoader {
* @returns Details of the folder
*/
getFolderNode(nodeId: string, includeFields: string[] = []): Observable<NodeEntry> {
const includeFieldsRequest = ['path', 'properties', 'allowableOperations', 'permissions', 'aspectNames', ...includeFields]
.filter((element, index, array) => index === array.indexOf(element));
@@ -184,7 +182,7 @@ export class DocumentListService implements DocumentListLoader {
}
private retrieveDocumentNode(nodeId: string, pagination: PaginationModel, includeFields: string[], where?: string, orderBy?: string[]): Observable<DocumentLoaderNode> {
return forkJoin(
return forkJoin([
this.getFolderNode(nodeId, includeFields),
this.getFolder(null, {
maxItems: pagination.maxItems,
@@ -192,7 +190,7 @@ export class DocumentListService implements DocumentListLoader {
orderBy: orderBy,
rootFolderId: nodeId,
where: where
}, includeFields)).pipe(
}, includeFields)]).pipe(
map((results) => new DocumentLoaderNode(results[0], results[1]))
);
}

View File

@@ -77,7 +77,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
this.textInput.valueChanges
.pipe(
filter(textInputValue => textInputValue !== this.editedValue),
debounceTime(500),
debounceTime(50),
takeUntil(this.onDestroy$)
)
.subscribe(textInputValue => {

View File

@@ -398,7 +398,7 @@ describe('TaskFormCloudComponent', () => {
component.loading = true;
fixture.detectChanges();
const loadingTemplate = debugElement.query(By.css('mat-spinner'));
const loadingTemplate = debugElement.query(By.css('mat-progress-spinner'));
expect(loadingTemplate).toBeDefined();
});
@@ -411,7 +411,7 @@ describe('TaskFormCloudComponent', () => {
component.loadTask();
fixture.detectChanges();
const loadingTemplate = debugElement.query(By.css('mat-spinner'));
const loadingTemplate = debugElement.query(By.css('mat-progress-spinner'));
expect(loadingTemplate).toBeNull();
});

View File

@@ -82,7 +82,7 @@ describe('AppsListComponent', () => {
component.loading = true;
fixture.detectChanges();
fixture.whenStable().then(() => {
const loadingSpinner = fixture.nativeElement.querySelector('mat-spinner');
const loadingSpinner = fixture.nativeElement.querySelector('mat-progress-spinner');
expect(loadingSpinner).toBeDefined();
});
}));

View File

@@ -50,7 +50,7 @@ export class CardTextItemPage {
async enterTextField(text: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.element(this.textField));
await BrowserActions.clearSendKeys(this.rootElement.element(this.textField), text);
await BrowserActions.clearSendKeys(this.rootElement.element(this.textField), text, 500);
await this.rootElement.element(this.textField).sendKeys(Key.TAB);
}

View File

@@ -36,6 +36,8 @@ export class DataTableComponentPage {
emptyListTitle: ElementFinder;
emptyListSubtitle: ElementFinder;
MAX_LOADING_TIME = 120000;
constructor(rootElement = element.all(by.css('adf-datatable')).first()) {
this.rootElement = rootElement;
this.list = this.rootElement.all(by.css(`div[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`));
@@ -311,21 +313,24 @@ export class DataTableComponentPage {
}
async waitTillContentLoaded(): Promise<void> {
await browser.sleep(500);
if (await this.isSpinnerPresent()) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-spinner')));
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(by.tagName('mat-progress-spinner')), this.MAX_LOADING_TIME);
if (await this.isEmpty()) {
Logger.log('empty page');
} else {
await this.waitFirstElementPresent();
}
} else if (await this.isEmpty()) {
Logger.log('empty page');
} else {
try {
Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-spinner')), 2000);
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.element(by.tagName('mat-progress-spinner')), 2000);
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(by.tagName('mat-progress-spinner')), this.MAX_LOADING_TIME);
} catch (error) {
}
@@ -341,7 +346,7 @@ export class DataTableComponentPage {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-spinner')).isDisplayed();
isSpinnerPresent = await this.rootElement.element(by.tagName('mat-progress-spinner')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}
@@ -353,7 +358,7 @@ export class DataTableComponentPage {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-progress-bar')).isDisplayed();
isSpinnerPresent = await this.rootElement.element(by.tagName('mat-progress-bar')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}

View File

@@ -119,11 +119,11 @@ export class ViewerPage {
if (this.isSpinnerPresent()) {
Logger.log('wait spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-spinner')));
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-progress-spinner')));
} else {
try {
Logger.log('wait spinner is present');
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-spinner')));
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-progress-spinner')));
} catch (error) {
}
}
@@ -133,7 +133,7 @@ export class ViewerPage {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-spinner')).isDisplayed();
isSpinnerPresent = await element(by.tagName('mat-progress-spinner')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}