Skip to content

Commit

Permalink
Expression: use qawolf.scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
jperl committed Mar 9, 2020
1 parent bcc1679 commit c27b804
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -23,6 +23,7 @@
"postinstall": "node ./src/postInstallMessage.js",
"release": "np --no-cleanup",
"test": "jest",
"test:server": "npx @qawolf/sandbox",
"version": "npm run clean && npm run build"
},
"repository": {
Expand All @@ -44,8 +45,8 @@
"inquirer": "^7.0.5",
"playwright": "next",
"playwright-ci": "^0.4.0",
"playwright-html-selector": "^0.2.0",
"playwright-utils": "^0.6.1",
"playwright-html-selector": "^0.3.0",
"playwright-utils": "^0.7.0",
"update-notifier": "^4.1.0"
},
"devDependencies": {
Expand Down
10 changes: 8 additions & 2 deletions src/build-code/Expression.ts
Expand Up @@ -62,9 +62,15 @@ export class Expression {
const value = this._buildValue();
if (value.length) args.push(value);

let methodOpen = `page.${action}(`;
if (action === 'scroll') {
methodOpen = `qawolf.scroll(page, `;
}

const expression = `await ${methodOpen}${args.join(', ')});`;

// TODO description
const method = `await page.${action}(${args.join(', ')});`;
return `${method}\n`;
return `${expression}\n`;
}

public step(): Step {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import { launch, repl, saveState, setState } from 'playwright-utils';
import { launch, repl, saveState, scroll, setState } from 'playwright-utils';
import { create } from './create-code/create';
import { register } from './register';

Expand All @@ -9,7 +9,7 @@ if (isCLI) {
}

// export public API
export { create, launch, register, repl, saveState, setState };
export { create, launch, register, repl, saveState, scroll, setState };

// make repl a global
(global as any).repl = repl;
2 changes: 1 addition & 1 deletion test/build-code/Expression.test.ts
Expand Up @@ -57,7 +57,7 @@ describe('Expression', () => {
});

expect(expression.code()).toBe(
'await page.scroll("[id=\'my-input\']", { x: 100, y: 200 });\n',
'await qawolf.scroll(page, "[id=\'my-input\']", { x: 100, y: 200 });\n',
);
});

Expand Down

0 comments on commit c27b804

Please sign in to comment.