mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
small refactoring of login / logout
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
import { browser, ExpectedConditions as EC, promise } from 'protractor';
|
||||
import { LoginComponent } from '../components/components';
|
||||
import { Page } from './page';
|
||||
import { Utils } from '../utilities/utils';
|
||||
|
||||
import {
|
||||
ADMIN_USERNAME,
|
||||
@@ -38,17 +39,17 @@ export class LoginPage extends Page {
|
||||
load(): promise.Promise<any> {
|
||||
return super.load().then(() => {
|
||||
const { submitButton } = this.login;
|
||||
const hasSumbitButton = EC.presenceOf(submitButton);
|
||||
const hasSubmitButton = EC.presenceOf(submitButton);
|
||||
|
||||
return browser.wait(hasSumbitButton, BROWSER_WAIT_TIMEOUT)
|
||||
.then(() => browser.executeScript('window.localStorage.clear();'))
|
||||
.then(() => browser.executeScript('window.sessionStorage.clear();'))
|
||||
.then(() => browser.driver.manage().deleteAllCookies());
|
||||
return browser.wait(hasSubmitButton, BROWSER_WAIT_TIMEOUT)
|
||||
.then(() => Utils.clearLocalStorage())
|
||||
.then(() => browser.manage().deleteAllCookies());
|
||||
});
|
||||
}
|
||||
|
||||
loginWith(username: string, password: string): promise.Promise<void> {
|
||||
return this.login.enterCredentials(username, password).submit();
|
||||
loginWith(username: string, password?: string): promise.Promise<void> {
|
||||
const pass = password || username;
|
||||
return this.login.enterCredentials(username, pass).submit();
|
||||
}
|
||||
|
||||
loginWithAdmin(): promise.Promise<any> {
|
||||
|
@@ -18,6 +18,7 @@
|
||||
import { promise } from 'protractor';
|
||||
import { Page } from './page';
|
||||
import { APP_ROUTES } from '../configs';
|
||||
import { Utils } from '../utilities/utils';
|
||||
|
||||
export class LogoutPage extends Page {
|
||||
/** @override */
|
||||
@@ -27,6 +28,8 @@ export class LogoutPage extends Page {
|
||||
|
||||
/** @override */
|
||||
load(): promise.Promise<any> {
|
||||
return super.load();
|
||||
return super.load()
|
||||
.then(() => Utils.clearLocalStorage())
|
||||
.then(() => Utils.clearSessionStorage());
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ export class PeopleApi extends RepoApi {
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
createUser(username: string, password: string, details?: Person): Promise<any> {
|
||||
createUser(username: string, password?: string, details?: Person): Promise<any> {
|
||||
const person: Person = new Person(username, password, details);
|
||||
const onSuccess = (response) => response;
|
||||
const onError = (response) => {
|
||||
|
@@ -27,4 +27,10 @@ export class Utils {
|
||||
static clearLocalStorage(): promise.Promise<any> {
|
||||
return browser.executeScript('window.localStorage.clear();');
|
||||
}
|
||||
|
||||
// session storage
|
||||
static clearSessionStorage(): promise.Promise<any> {
|
||||
return browser.executeScript('window.sessionStorage.clear();');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user