Skip to content

Commit

Permalink
fix - remove control flow from waitForAngularEnabled, waitForAngular,…
Browse files Browse the repository at this point in the history
… and angularAppRoot

- Enabled the driverProviderLocal tests
- Remove auto unwrap test for a WebElement. Reference PR angular#3471
  • Loading branch information
cnishina committed Nov 14, 2018
1 parent 8796ad8 commit b9245af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
48 changes: 18 additions & 30 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,18 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* this method is called use the new app root. Pass nothing to get a promise that
* resolves to the value of the selector.
*
* @param {string|webdriver.promise.Promise<string>} value The new selector.
* @param {string|webdriver.promise.Promise<string>} valuePromise The new selector.
* @returns A promise that resolves with the value of the selector.
*/
angularAppRoot(value: string|wdpromise.Promise<string> = null): wdpromise.Promise<string> {
return this.driver.controlFlow().execute(() => {
if (value != null) {
return wdpromise.when(value).then((value: string) => {
this.internalRootEl = value;
if (this.bpClient) {
const bpCommandPromise = this.bpClient.setWaitParams(value);
// Convert to webdriver promise as best as possible
return wdpromise.when(bpCommandPromise as any).then(() => this.internalRootEl);
}
return this.internalRootEl;
});
async angularAppRoot(valuePromise: string|wdpromise.Promise<string> = null): Promise<string> {
if (valuePromise != null) {
const value = await Promise.resolve(valuePromise);
this.internalRootEl = value;
if (this.bpClient) {
await this.bpClient.setWaitParams(value);
}
return wdpromise.when(this.internalRootEl);
}, `Set angular root selector to ${value}`);
}
return this.internalRootEl;
}

/**
Expand Down Expand Up @@ -417,23 +411,17 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* Call waitForAngularEnabled() without passing a value to read the current
* state without changing it.
*/
waitForAngularEnabled(enabled: boolean|wdpromise.Promise<boolean> = null):
wdpromise.Promise<boolean> {
if (enabled != null) {
const ret = this.driver.controlFlow().execute(() => {
return wdpromise.when(enabled).then((enabled: boolean) => {
if (this.bpClient) {
logger.debug('Setting waitForAngular' + !enabled);
const bpCommandPromise = this.bpClient.setWaitEnabled(enabled);
// Convert to webdriver promise as best as possible
return wdpromise.when(bpCommandPromise as any).then(() => enabled);
}
});
}, `Set proxy synchronization enabled to ${enabled}`);
async waitForAngularEnabled(enabledPromise: boolean|wdpromise.Promise<boolean> = null):
Promise<boolean> {
if (enabledPromise != null) {
const enabled = await Promise.resolve(enabledPromise);
if (this.bpClient) {
logger.debug('Setting waitForAngular' + !enabled);
await this.bpClient.setWaitEnabled(enabled);
}
this.internalIgnoreSynchronization = !enabled;
return ret;
}
return wdpromise.when(!this.ignoreSynchronization);
return !this.ignoreSynchronization;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/driverProviders/driverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export abstract class DriverProvider {
if (driver.getSession() !== undefined) {
const session = await driver.getSession();
if (session) {
return driver.quit();
return await driver.quit();
}
}
} catch (_) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"pretest": "gulp pretest",
"start": "cd testapp && npm start",
"test": "node scripts/test.js",
"tsc": "tsc",
"website": "cd website && npm start",
"compile_to_es5": "gulp compile_to_es5"
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var passingTests = [
'node built/cli.js spec/interactionConf.js',
'node built/cli.js spec/directConnectConf.js',
'node built/cli.js spec/restartBrowserBetweenTestsConf.js',
// 'node built/cli.js spec/driverProviderLocalConf.js',
// 'node built/cli.js spec/driverProviderLocalConf.js --useBlockingProxy',
'node built/cli.js spec/driverProviderLocalConf.js',
'node built/cli.js spec/driverProviderLocalConf.js --useBlockingProxy',
'node built/cli.js spec/getCapabilitiesConf.js',
'node built/cli.js spec/controlLockConf.js',
'node built/cli.js spec/customFramework.js',
Expand Down

0 comments on commit b9245af

Please sign in to comment.