Skip to content

Commit

Permalink
fix: backward compatability for setValue command (#79)
Browse files Browse the repository at this point in the history
* fix: backward compatability for setValue command

* add test

* fix linting

* add linting fixes to test

* fix unit tests
  • Loading branch information
sudharsan-selvaraj authored Jul 25, 2024
1 parent 7418351 commit aff491d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"clean": "rimraf package-lock.json && rimraf node_modules && npm install",
"build": "rimraf build && tsc",
"watch": "tsc --watch",
"prettier": "prettier 'src/**/*.ts' --write --single-quote",
"prettier": "prettier 'src/**/*.ts' 'test/**/*.*' --write --single-quote",
"prettier-check": "prettier 'src/**/*.ts' 'test/**/*.*' --check",
"appium-home": "rm -rf /tmp/some-temp-dir && export APPIUM_HOME=/tmp/some-temp-dir",
"test": "NODE_OPTIONS='--loader ts-node/esm' mocha --require ts-node/register test/**/*.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export async function setValue(
) {
const driver = ELEMENT_CACHE.get(elementId);
return await driver.command(`/element/${elementId}/value`, 'POST', {
text,
text: text && _.isArray(text) ? text.join('') : text, // text should always be a string
value: text && _.isString(text) ? [...text] : text, // value should always be a array of char
});
}

Expand Down
4 changes: 3 additions & 1 deletion test/specs/test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ async function performLogin(userName = 'admin', password = '1234') {
const att = await browser.flutterByValueKey$('username_text_field');
console.log(await att.getAttribute('all'));
await browser.flutterByValueKey$('username_text_field').clearValue();
await browser.flutterByValueKey$('username_text_field').addValue(userName);
await $(
'//android.view.View[@content-desc="username_text_field"]/android.widget.EditText',
).addValue(userName);

await browser.flutterByValueKey$('password_text_field').clearValue();
await browser.flutterByValueKey$('password').addValue(password);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/element.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('Element Interaction Functions', () => {
mockDriver.command.calledWith(
`/element/${elementId}/value`,
'POST',
{ text },
{ text, value: [...text] },
),
).to.be.true;
});
Expand Down

0 comments on commit aff491d

Please # to comment.