wip: add some demos of docstrings to trigger auto command docs gen
MODIFY
packages/fake-driver/lib/commands/alert.js
packages/fake-driver/lib/commands/alert.js
@@ -16,11 +16,24 @@ helpers.assertAlert = function assertAlert() {
}
};
+/**
+ * Get the text of an alert
+ *
+ * @appiumCommand
+ * @returns {Promise<string>}
+ */
commands.getAlertText = async function getAlertText() {
this.assertAlert();
return this.appModel.alertText();
};
+/**
+ * Set the text of an alert
+ *
+ * @appiumCommand
+ * @param {string} text
+ * @returns {Promise<null>}
+ */
commands.setAlertText = async function setAlertText(text) {
this.assertAlert();
try {
@@ -30,11 +43,23 @@ commands.setAlertText = async function setAlertText(text) {
}
};
+/**
+ * Accept an alert
+ *
+ * @appiumCommand
+ * @returns {Promise<null>}
+ */
commands.postAcceptAlert = async function postAcceptAlert() {
this.assertAlert();
this.appModel.handleAlert();
};
+/**
+ * Dismiss an alert
+ *
+ * @appiumCommand
+ * @returns {Promise<null>}
+ */
commands.postDismissAlert = commands.postAcceptAlert;
Object.assign(extensions, commands, helpers);

MODIFY
packages/fake-driver/lib/commands/contexts.js
packages/fake-driver/lib/commands/contexts.js
@@ -20,14 +20,33 @@ helpers.assertWebviewContext = function assertWebviewContext() {
}
};
+/**
+ * Get the current appium context
+ *
+ * @appiumCommand
+ * @returns {Promise<string>}
+ */
commands.getCurrentContext = async function getCurrentContext() {
return this.curContext;
};
+/**
+ * Get the list of available contexts
+ *
+ * @appiumCommand
+ * @returns {Promise<Array<string>>}
+ */
commands.getContexts = async function getContexts() {
return _.keys(this.getRawContexts());
};
+/**
+ * Set the current context
+ *
+ * @appiumCommand
+ * @param {string} context - name of the context
+ * @returns {Promise<null>}
+ */
commands.setContext = async function setContext(context) {
let contexts = this.getRawContexts();
if (_.includes(_.keys(contexts), context)) {
@@ -46,6 +65,13 @@ commands.setContext = async function setContext(context) {
}
};
+/**
+ * Set the active frame
+ *
+ * @appiumCommand
+ * @param {number}
+ * @returns {Promise<null>}
+ */
commands.setFrame = async function setFrame(frameId) {
this.assertWebviewContext();
if (frameId === null) {

MODIFY
packages/fake-driver/lib/commands/general.js
packages/fake-driver/lib/commands/general.js
@@ -73,6 +73,15 @@ commands.execute = async function execute(script, args) {
return await this.executeMethod(script, args);
};
+/**
+ * Add two or maybe even three numbers
+ *
+ * @appiumCommand
+ * @param {number} num1
+ * @param {number} num2
+ * @param {?number} num3
+ * @returns {Promise<number>}
+ */
commands.fakeAddition = async function fakeAddition(num1, num2, num3) {
return num1 + num2 + (num3 ?? 0);
};

MODIFY
packages/fake-driver/lib/driver.js
packages/fake-driver/lib/driver.js
@@ -92,12 +92,25 @@ class FakeDriver extends BaseDriver {
return this.fakeThing;
}
+ /**
+ * Set the 'thing' value (so that it can be retrieved later)
+ *
+ * @appiumCommand
+ * @param {any} thing
+ * @returns {Promise<null>}
+ */
async setFakeThing(thing) {
await B.delay(1);
this.fakeThing = thing;
return null;
}
+ /**
+ * Get the driver args that were sent in via the CLI
+ *
+ * @appiumCommand
+ * @returns {Promise<Record<string, any>>}
+ */
async getFakeDriverArgs() {
await B.delay(1);
return this.cliArgs;

wip: add some demos of docstrings to trigger auto command docs gen