Skip to content

Commit

Permalink
[email protected] - Introduced a new base page to reduce client code (
Browse files Browse the repository at this point in the history
#1909)

* Introduced a new base page to reduce client code

* Updated ver.

Co-authored-by: billy.oliver <[email protected]>
  • Loading branch information
oliversweb and billy.oliver authored Jun 8, 2022
1 parent c013731 commit f6d9263
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
9 changes: 9 additions & 0 deletions packages/services/f-wdio-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


v0.11.0
------------------------------
*June 8, 2022*

### Added
- Introduce a new base page that infers the calling component which can then reduce the client code


v0.10.0
------------------------------
*June 1, 2022*
Expand Down
2 changes: 1 addition & 1 deletion packages/services/f-wdio-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@justeat/f-wdio-utils",
"description": "Fozzie Wdio Utils - webdriverIO page object",
"version": "0.10.0",
"version": "0.11.0",
"files": [
"src/"
],
Expand Down
24 changes: 24 additions & 0 deletions packages/services/f-wdio-utils/src/base.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const Page = require('./page.object');
const { buildUrl } = require('./storybook-extensions');

class BasePage extends Page {
get component () {
return $(`[${this.componentTag}='${this.componentName}']`);
}

async load (queries) {
const pageUrl = buildUrl(this.componentType, this.componentName, this.composePath(queries));
this.open(pageUrl);
await this.waitForComponent();
}

async waitForComponent (timeoutMs = 500) {
await this.component.waitForExist({ timeout: timeoutMs });
}

isComponentDisplayed () {
return this.component.isDisplayed();
}
}

module.exports = BasePage;
7 changes: 3 additions & 4 deletions packages/services/f-wdio-utils/src/page.object.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ const { source } = require('axe-core');
const { buildUrl } = require('./storybook-extensions');

class Page {
#defaultWaitTimeout = 500;

constructor (componentType, componentName) {
constructor (componentType, componentName, componentTag = 'data-test-id') {
this.title = 'Component URLS';
this.componentType = componentType;
this.componentName = componentName;
this.componentTag = componentTag;
this.path = '';
}

Expand All @@ -22,7 +21,7 @@ class Page {
return this;
}

waitForComponent (component, timeoutMs = this.#defaultWaitTimeout) {
waitForComponent (component, timeoutMs = 500) {
component.waitForExist({ timeout: timeoutMs });
}

Expand Down

0 comments on commit f6d9263

Please sign in to comment.