Use hash strategy in demo shell as the other apps (#6402)

* hash startegy

* use hash in e2e

* trigger build

* fix

* fix

* remove children router overwrite crazynes

* Update login.module.ts

* revert not needed changes

* some fixes

* fix

* remove fdescribe

* fix

* fix

* Update share-file.e2e.ts

* Update lock-file.e2e.ts

* Update share-file.e2e.ts

* some fix

* some other fixes

* username as id

* fix after rebase

* username

* fix usernamee

* Fix the errorComponent

* Attempt to fix unit test - to check

* * Fixed circular dependency error while building adf-testing package

* * Fixed failing UT

* fix

* use username

* some fixes

* some fix

* fix

Co-authored-by: Maurizio Vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Vito Albano <vitoalbano@vitoalbano-mbp-0120.local>
Co-authored-by: sivakumar414ram <siva.kumar@muraai.com>
This commit is contained in:
Eugenio Romano
2020-12-16 18:46:56 +00:00
committed by GitHub
parent 3734151338
commit 1c51b2a1a6
195 changed files with 1774 additions and 1460 deletions

View File

@@ -112,7 +112,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
ngOnInit() {
this.cardViewUpdateService.itemUpdated$
.pipe(
debounceTime(500),
debounceTime(200),
takeUntil(this.onDestroy$))
.subscribe(
(updatedNode) => {

View File

@@ -21,11 +21,11 @@ import {
} from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { Location } from '@angular/common';
import { AuthenticationService } from '../../services/authentication.service';
import { LogService } from '../../services/log.service';
import { TranslationService } from '../../services/translation.service';
import { UserPreferencesService } from '../../services/user-preferences.service';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LoginErrorEvent } from '../models/login-error.event';
import { LoginSubmitEvent } from '../models/login-submit.event';
@@ -139,10 +139,11 @@ export class LoginComponent implements OnInit, OnDestroy {
private router: Router,
private appConfig: AppConfigService,
private userPreferences: UserPreferencesService,
private location: Location,
private route: ActivatedRoute,
private sanitizer: DomSanitizer
) {}
private sanitizer: DomSanitizer,
private alfrescoApiService: AlfrescoApiService
) {
}
ngOnInit() {
this.initFormError();
@@ -154,10 +155,14 @@ export class LoginComponent implements OnInit, OnDestroy {
if (oauth && oauth.implicitFlow) {
this.implicitFlow = true;
}
if (oauth && oauth.silentLogin && !this.authService.isLoggedIn()) {
this.alfrescoApiService.getInstance().oauth2Auth.implicitLogin();
}
}
if (this.authService.isEcmLoggedIn() || this.authService.isBpmLoggedIn()) {
this.location.forward();
if (this.authService.isLoggedIn()) {
this.router.navigate([this.successRoute]);
} else {
this.route.queryParams.subscribe((params: Params) => {
const url = params['redirectUrl'];
@@ -204,6 +209,9 @@ export class LoginComponent implements OnInit, OnDestroy {
}
implicitLogin() {
if (this.authService.isLoggedIn()) {
this.router.navigate([this.successRoute]);
}
this.authService.ssoImplicitLogin();
}

View File

@@ -65,10 +65,6 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
if (redirectFragment) {
this.storageService.removeItem('loginFragment');
const routeRedirectTo = route.routeConfig.children.filter( (routeTo) => routeTo.path === '' );
if (routeRedirectTo?.length > 0) {
routeRedirectTo[0].redirectTo = redirectFragment;
}
return this.router.createUrlTree([redirectFragment]);
}
return true;
@@ -91,16 +87,18 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
}
protected redirectToUrl(provider: string, url: string) {
if (!this.isSilentLogin()) {
const pathToLogin = `/${this.getLoginRoute()}`;
let urlToRedirect;
if (!this.authenticationService.isOauth()) {
this.authenticationService.setRedirect({ provider, url });
const pathToLogin = this.getLoginRoute();
const urlToRedirect = `/${pathToLogin}?redirectUrl=${url}`;
this.dialog.closeAll();
this.router.navigateByUrl(urlToRedirect);
urlToRedirect = `${pathToLogin}?redirectUrl=${url}`;
} else {
urlToRedirect = pathToLogin;
}
this.dialog.closeAll();
this.router.navigateByUrl(urlToRedirect);
}
protected getLoginRoute(): string {
@@ -131,4 +129,5 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
return this.authenticationService.isOauth() && oauth && oauth.silentLogin;
}
}

View File

@@ -97,7 +97,7 @@ describe('AuthGuardService ECM', () => {
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should not redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async(() => {
it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async(() => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
@@ -116,7 +116,7 @@ describe('AuthGuardService ECM', () => {
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'abc'};
expect(authGuard.canActivate(null, route)).toBeTruthy();
expect(router.navigateByUrl).toHaveBeenCalledTimes(0);
expect(router.navigateByUrl).toHaveBeenCalledTimes(1);
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
}));

View File

@@ -103,7 +103,7 @@ describe('AuthGuardService', () => {
appConfigService.config.oauth2.silentLogin = true;
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).not.toHaveBeenCalled();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
it('should set redirect url', async(async () => {

View File

@@ -1,13 +1,13 @@
<div class="adf-error-content">
<p class="adf-error-content-code">
{{ errorCode }}
{{ errorCodeTranslated }}
</p>
<div class="adf-error-content-shadow"></div>
<p class="adf-error-content-title">
{{ 'ERROR_CONTENT.' + errorCode + '.TITLE' | translate }}
{{ 'ERROR_CONTENT.' + errorCodeTranslated + '.TITLE' | translate }}
</p>
<p class="adf-error-content-description">
{{ 'ERROR_CONTENT.' + errorCode + '.DESCRIPTION' | translate }}
{{ 'ERROR_CONTENT.' + errorCodeTranslated + '.DESCRIPTION' | translate }}
</p>
<ng-content select="[adf-error-content-actions]"></ng-content>
</div>

View File

@@ -123,7 +123,7 @@ describe('ErrorContentComponent', () => {
spyOn(translateService, 'instant').and.returnValue(of('404'));
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(errorContentComponent.errorCode).toBe('404');
expect(errorContentComponent.errorCodeTranslated).toBe('404');
});
}));
});

View File

@@ -22,9 +22,8 @@ import {
ViewEncapsulation,
OnInit
} from '@angular/core';
import { Params, ActivatedRoute } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { TranslationService } from '../../services/translation.service';
@Component({
selector: 'adf-error-content',
templateUrl: './error-content.component.html',
@@ -41,16 +40,18 @@ export class ErrorContentComponent implements OnInit {
@Input()
errorCode: string = ErrorContentComponent.UNKNOWN_ERROR;
errorCodeTranslated: string;
constructor(private route: ActivatedRoute,
private translateService: TranslationService) {
}
ngOnInit() {
if (this.route) {
this.route.params.forEach((params: Params) => {
if (params['id']) {
this.errorCode = this.checkErrorExists(params['id']) ? params['id'] : ErrorContentComponent.UNKNOWN_ERROR;
}
this.route.params.subscribe(params => {
const code = params['id'] || this.errorCode;
const errorHasTranslation = this.checkErrorExists(code);
this.errorCodeTranslated = errorHasTranslation ? code : ErrorContentComponent.UNKNOWN_ERROR;
});
}
}

View File

@@ -19,6 +19,7 @@ import { Locator, by, element, ElementFinder, browser } from 'protractor';
import { DataTableComponentPage } from '../../core/pages/data-table-component.page';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
import { Logger } from '../../core/utils/logger';
export class DocumentListPage {
@@ -66,6 +67,7 @@ export class DocumentListPage {
}
async clickOnActionMenu(content: string): Promise<void> {
Logger.log(`Click action menu ${content}`);
await BrowserActions.closeMenuAndDialogs();
const row = this.dataTable.getRow('Display name', content);
await BrowserActions.click(row.element(this.optionButton));

View File

@@ -17,6 +17,7 @@
import { browser, by, element } from 'protractor';
import { BrowserActions } from '../../core/utils/browser-actions';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
export class LikePage {
@@ -24,8 +25,8 @@ export class LikePage {
likeButton = element(by.css(`.adf-like-grey`));
unlikeButton = element(by.css(`.adf-like-select`));
async getLikeCounter(): Promise<string> {
return BrowserActions.getText(this.likeCounter);
async checkLikeCounter(counter: number): Promise<void> {
await BrowserVisibility.waitUntilElementHasText(this.likeCounter, counter);
}
async clickLike(): Promise<void> {

View File

@@ -31,9 +31,9 @@ export class RatePage {
await BrowserActions.click(ratedStar);
}
async getRatingCounter(): Promise<string> {
async checkRatingCounter(rating: number): Promise<void> {
const ratingsCounter = element(by.css(`div[id="adf-rating-counter"]`));
return BrowserActions.getText(ratingsCounter);
await BrowserVisibility.waitUntilElementHasText(ratingsCounter, rating);
}
async isStarRated(rateValue: number): Promise<void> {

View File

@@ -76,9 +76,9 @@ export class GroupIdentityService {
Logger.log(`Data ${JSON.stringify(data)}`);
return data[0];
return data[0]; Logger.error('Group not found');
} catch (error) {
Logger.error('Group not found');
}
};

View File

@@ -49,7 +49,7 @@ export class UsersActions {
if (this.api.apiService.isEcmConfiguration() || (this.api.apiService.isEcmBpmConfiguration())) {
Logger.log(`Create user ECM ${user.email}`);
await this.api.apiService.core.peopleApi.addPerson({
id: user.email,
id: user.username,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,

View File

@@ -18,6 +18,7 @@
import { element, by, ElementFinder } from 'protractor';
import { BrowserVisibility } from '../../utils/browser-visibility';
import { BrowserActions } from '../../utils/browser-actions';
import { Logger } from '../../utils/logger';
export class DropdownPage {
@@ -33,6 +34,7 @@ export class DropdownPage {
}
async selectOption(option: string): Promise<void> {
Logger.log(`Select dropdown option ${option}`);
await BrowserVisibility.waitUntilElementIsVisible(element.all(by.cssContainingText('mat-option span.mat-option-text', option)).first());
const optionElement = element.all(by.cssContainingText('mat-option span.mat-option-text', option)).first();
await BrowserActions.click(optionElement);

View File

@@ -32,8 +32,7 @@ export class NotificationHistoryPage {
}
async checkNotificationIsPresent(text: string): Promise<void> {
const notificationLisText = await BrowserActions.getText(this.notificationList);
await expect(notificationLisText).toContain(text);
await BrowserVisibility.waitUntilElementHasText(this.notificationList, text);
}
async checkNotificationIsNotPresent(text: string): Promise<void> {

View File

@@ -631,11 +631,11 @@ export class ViewerPage {
}
async checkOverlayViewerIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.viewer.element(by.css('div[class*="adf-viewer-overlay-container"]')));
await BrowserVisibility.waitUntilElementIsVisible(element(by.css('div[class*="adf-viewer-overlay-container"]')));
}
async checkInlineViewerIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.viewer.element(by.css('div[class*="adf-viewer-inline-container"]')));
await BrowserVisibility.waitUntilElementIsVisible(element(by.css('div[class*="adf-viewer-inline-container"]')));
}
async checkTabHasNoIcon(index: number): Promise<void> {

View File

@@ -193,7 +193,7 @@ export class BrowserActions {
}
static async closeMenuAndDialogs(): Promise<void> {
Logger.info(`close Menu And Dialogs`);
Logger.info(`Close Menu And Dialogs`);
const container = element(by.css('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing'));
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();

View File

@@ -20,8 +20,8 @@ import { Logger } from './logger';
export class BrowserVisibility {
static NOT_VISIBLE_DEFAULT_TIMEOUT = BrowserVisibility.getNoVisibleTimeout() ? browser.params.testConfig.timeouts.no_visible_timeout : 20000;
static DEFAULT_TIMEOUT = BrowserVisibility.getVisibleTimeout() ? browser.params.testConfig.timeouts.visible_timeout : 20000;
static NOT_VISIBLE_DEFAULT_TIMEOUT = BrowserVisibility.getNoVisibleTimeout() ? browser.params.testConfig.timeouts.no_visible_timeout : 10000;
static DEFAULT_TIMEOUT = BrowserVisibility.getVisibleTimeout() ? browser.params.testConfig.timeouts.visible_timeout : 10000;
static getVisibleTimeout() {
if (browser && browser.params && browser.params.testConfig && browser.params.testConfig.timeouts) {

View File

@@ -63,7 +63,7 @@ export class ApplicationsUtil {
await this.api.getInstance().activiti.appsApi.deployAppDefinitions({ appDefinitions: [{ id: publishApp.appDefinition.id }] });
return appCreated;
} catch (error) {
Logger.error('Import Publish Deploy Application - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
Logger.error('Import Publish Deploy Application - Service error, Response: ', JSON.stringify(error));
}
}