Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: raise an error for reset #649

Merged
merged 5 commits into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import logger from '../logger';
import validate from 'validate.js';
import { errors } from 'appium-base-driver';
import { qualifyActivityName } from '../utils';
import { androidHelpers } from 'appium-android-driver';

let commands = {}, helpers = {}, extensions = {};

Expand Down Expand Up @@ -33,7 +32,9 @@ commands.closeApp = async function closeApp () {

// eslint-disable-next-line require-await
commands.reset = async function reset () {
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
throw new errors.UnsupportedOperationError('Please quit the session and create a new session in order to close and launch the application under test');
throw new errors.UnsupportedOperationError(
'Please quit the session and create a new one ' +
'in order to close and launch the application under test');
};

commands.getClipboard = async function getClipboard () {
Expand Down Expand Up @@ -311,15 +312,6 @@ commands.startActivity = async function startActivity (appPackage, appActivity,
await this.adb.waitForActivity(appWaitPackage, appWaitActivity);
};

commands.reset = async function reset () {
await androidHelpers.resetApp(this.adb, Object.assign({}, this.opts, {fastReset: true}));
await this.espresso.startSession(this.caps);
await this.adb.waitForActivity(this.caps.appWaitPackage, this.caps.appWaitActivity, this.opts.appWaitDuration);
if (this.opts.autoWebview) {
await this.initWebview();
}
};

commands.mobileDismissAutofill = async function mobileDismissAutofill (opts = {}) {
const {element} = assertRequiredOptions(opts, ['element']);
await this.espresso.jwproxy.command(
Expand Down
13 changes: 13 additions & 0 deletions test/functional/driver-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ describe('EspressoDriver', function () {
await driver.getCurrentDeviceActivity().should.eventually.eql('.accessibility.AccessibilityNodeProviderActivity');
});
});

describe('.reset', function () {
afterEach(async function () {
try {
await driver.quit();
} catch (ign) {}
});
it('should raise an error for resetApp', async function () {
await driver.init(APIDEMO_CAPS);
await driver.resetApp(APIDEMO_CAPS).should.eventually.be.rejectedWith(/Please quit the session and create a new one/);
});
});

describe('keys', function () {
beforeEach(async function () {
await driver.init({
Expand Down