Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eromano committed Sep 14, 2020
1 parent fd73439 commit 95db43b
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class DemoPermissionComponent implements OnInit {
this.nodeService
.getNode(this.nodeId, {include: ['permissions'] })
.subscribe( (currentNode: MinimalNodeEntryEntity) => {
this.toggleStatus = currentNode.permissions.isInheritanceEnabled;
this.toggleStatus = currentNode.permissions?.isInheritanceEnabled ?? false;
});
}

onUpdatedPermissions(node: MinimalNodeEntryEntity) {
this.toggleStatus = node.permissions.isInheritanceEnabled;
this.toggleStatus = node.permissions?.isInheritanceEnabled ?? false;
this.displayPermissionComponent.reload();
}

Expand Down
13 changes: 4 additions & 9 deletions e2e/content-services/directives/create-library-directive.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ describe('Create library directive', () => {
await apiService.getInstance().login(browser.params.testConfig.admin.email, browser.params.testConfig.admin.password);

acsUser = await usersActions.createUser();

await loginPage.login(acsUser.email, acsUser.password);

createSite = await apiService.getInstance().core.sitesApi.createSite({
title: StringUtil.generateRandomString(20).toLowerCase(),
visibility: 'PUBLIC'
});

await loginPage.login(acsUser.email, acsUser.password);
});

afterAll(async () => {
Expand Down Expand Up @@ -93,6 +92,7 @@ describe('Create library directive', () => {
it('[C290160] Should create a public library', async () => {
const libraryName = StringUtil.generateRandomString();
const libraryDescription = StringUtil.generateRandomString();

await createLibraryDialog.typeLibraryName(libraryName);
await createLibraryDialog.typeLibraryDescription(libraryDescription);
await createLibraryDialog.selectPublic();
Expand All @@ -112,6 +112,7 @@ describe('Create library directive', () => {
it('[C290173] Should create a private library', async () => {
const libraryName = StringUtil.generateRandomString();
const libraryDescription = StringUtil.generateRandomString();

await createLibraryDialog.typeLibraryName(libraryName);
await createLibraryDialog.typeLibraryDescription(libraryDescription);
await createLibraryDialog.selectPrivate();
Expand All @@ -121,8 +122,6 @@ describe('Create library directive', () => {
await createLibraryDialog.clickCreate();
await createLibraryDialog.waitForDialogToClose();

await expect(await createLibraryDialog.isDialogOpen()).not.toBe(true, 'The Create Library dialog is not closed');

await customSourcesPage.navigateToCustomSources();
await customSourcesPage.selectMySitesSourceType();
await customSourcesPage.checkRowIsDisplayed(libraryName);
Expand All @@ -144,8 +143,6 @@ describe('Create library directive', () => {
await createLibraryDialog.clickCreate();
await createLibraryDialog.waitForDialogToClose();

await expect(await createLibraryDialog.isDialogOpen()).not.toBe(true, 'The Create Library dialog is not closed');

await customSourcesPage.navigateToCustomSources();
await customSourcesPage.selectMySitesSourceType();
await customSourcesPage.checkRowIsDisplayed(libraryName);
Expand Down Expand Up @@ -243,8 +240,6 @@ describe('Create library directive', () => {

await createLibraryDialog.clickCreate();
await createLibraryDialog.waitForDialogToClose();

await expect(await createLibraryDialog.isDialogOpen()).not.toBe(true, 'The Create library dialog remained open');
});

it('[C290179] Should not accept more than the expected characters for input fields', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Document List Component - Actions', () => {

await loginPage.login(acsUser.email, acsUser.password);

await browser.sleep(10000);
await browser.sleep(browser.params.testConfig.timeouts.index_search); // wait search index previous file/folder uploaded
});

afterAll(async () => {
Expand Down
2 changes: 2 additions & 0 deletions e2e/core/pages/navigation-bar.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class NavigationBarPage {
logoutSection: ElementFinder = element(by.css('div[data-automation-id="adf-logout-section"]'));

async clickNavigationBarItem(title: string): Promise<void> {
Logger.log(`clickNavigationBarItem ${title}`);

const menu = element(by.css(`.app-sidenav-link[data-automation-id="${title}"]`));
await BrowserActions.closeMenuAndDialogs();
await BrowserActions.click(menu);
Expand Down
2 changes: 1 addition & 1 deletion e2e/test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
timeouts: {
visible_timeout: 20000,
no_visible_timeout: 20000,
index_search: 20000
index_search: 25000
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class SimpleInheritedPermissionTestComponent {
}

onUpdate(node: any) {
this.updatedNode = node.permissions.isInheritanceEnabled;
this.updatedNode = node.permissions?.isInheritanceEnabled ?? false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('InheritPermissionDirective', () => {
it('should be able to add inherited permission', async(() => {
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNodeNoInherit));
spyOn(nodeService, 'updateNode').and.callFake((_, nodeBody) => {
if (nodeBody.permissions.isInheritanceEnabled) {
if (nodeBody.permissions?.isInheritanceEnabled) {
return of(fakeNodeWithInherit);
} else {
return of(fakeNodeNoInherit);
Expand All @@ -79,7 +79,7 @@ describe('InheritPermissionDirective', () => {
it('should be able to remove inherited permission', async(() => {
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNodeWithInherit));
spyOn(nodeService, 'updateNode').and.callFake((_, nodeBody) => {
if (nodeBody.permissions.isInheritanceEnabled) {
if (nodeBody.permissions?.isInheritanceEnabled) {
return of(fakeNodeWithInherit);
} else {
return of(fakeNodeNoInherit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class InheritPermissionDirective {
onInheritPermissionClicked() {
this.nodeService.getNode(this.nodeId).subscribe((node: Node) => {
if (this.contentService.hasAllowableOperations(node, AllowableOperationsEnum.UPDATEPERMISSIONS)) {
const nodeBody = { permissions: { isInheritanceEnabled: !node?.permissions?.isInheritanceEnabled } };
const nodeBody = { permissions: { isInheritanceEnabled: !node?.permissions?.isInheritanceEnabled ?? false} };
this.nodeService.updateNode(this.nodeId, nodeBody, { include: ['permissions'] }).subscribe((nodeUpdated: Node) => {
this.updated.emit(nodeUpdated);
}, (error) => this.error.emit(error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
import { DropdownPage } from '../../core/pages/material/dropdown.page';
import { BreadcrumbDropdownPage } from '../pages/breadcrumb/breadcrumb-dropdown.page';
import { Logger } from '../../../..';

export class ContentNodeSelectorDialogPage {
dialog = element(by.css(`adf-content-node-selector`));
Expand Down Expand Up @@ -96,9 +97,11 @@ export class ContentNodeSelectorDialogPage {
return this.dataTable.numberOfRows();
}

async typeIntoNodeSelectorSearchField(text): Promise<void> {
async typeIntoNodeSelectorSearchField(text: string): Promise<void> {
Logger.log(`Search Node content node selector ${text}`);

await BrowserVisibility.waitUntilElementIsVisible(this.searchInputElement);
await BrowserActions.clearSendKeys(this.searchInputElement, text, 10);
await BrowserActions.clearSendKeys(this.searchInputElement, text, 100);
await this.dataTable.waitTillContentLoaded();
}

Expand Down
18 changes: 15 additions & 3 deletions lib/testing/src/lib/core/pages/data-table-component.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export class DataTableComponentPage {
}

async rightClickOnRow(columnName: string, columnValue: string): Promise<void> {
Logger.log(`Right Click On Row ${columnName} ${columnValue}`);

const row = this.getRow(columnName, columnValue);
await BrowserActions.rightClick(row);

Expand Down Expand Up @@ -256,6 +258,7 @@ export class DataTableComponentPage {
}

async checkContentIsDisplayed(columnName: string, columnValue: string): Promise<void> {
Logger.log(`Wait content is displayed ${columnName} ${columnValue}`);
const row = this.getCellElementByValue(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsVisible(row);
}
Expand Down Expand Up @@ -289,30 +292,39 @@ export class DataTableComponentPage {
async waitTillContentLoaded(): Promise<void> {
await browser.sleep(500);

if (element(by.tagName('mat-spinner')).isPresent()) {
const isSpinnerPresent = await element(by.tagName('mat-spinner')).isPresent();

if (isSpinnerPresent) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-spinner')));
await this.waitFirstElementPresent();
} else if (this.isEmpty()) {
Logger.log('empty page');
} else {
try {
Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-spinner')));
} catch (error) {
}
await this.waitFirstElementPresent();
}
}

private async waitFirstElementPresent(): Promise<void> {
try {
Logger.log('wait first element is present');
await BrowserVisibility.waitUntilElementIsVisible(this.contents.first());
} catch (error) {
Logger.log('Possible empty page');
}

}

async waitTillContentLoadedInfinitePagination(): Promise<void> {
await browser.sleep(500);

if (element(by.tagName('mat-progress-bar')).isPresent()) {
const isSpinnerPresent = await element(by.tagName('mat-progress-bar')).isPresent();

if (isSpinnerPresent) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-progress-bar')));
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/testing/src/lib/core/pages/viewer.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class ViewerPage {
await browser.sleep(500);

try {
if (element(by.tagName('mat-spinner')).isPresent()) {
if (await element(by.tagName('mat-spinner')).isPresent()) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-spinner')));
} else {
Expand Down

0 comments on commit 95db43b

Please sign in to comment.