Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update pages to extend base page
This way, we don't need to define visit methods for each page.
Instead, we defined only a relativeUrl for each page, which is
used in the visit method of the base page.
  • Loading branch information
Walmyr Filho committed May 28, 2020
1 parent 19792d2 commit 36ae57e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions page-objects/destination.js
@@ -1,16 +1,16 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationComponent = require('./components/destination')

const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN')

class Destination {
class Destination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
}

visit () {
browser.get(`/destinations/${randomNumberBewtweenOneAnd(15)}`)
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}`
}
}

Expand Down
10 changes: 5 additions & 5 deletions page-objects/editDestination.js
@@ -1,18 +1,18 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationComponent = require('./components/destination')
const FormComponent = require('./components/form')

const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN')

class EditDestination {
class EditDestination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
this.form = new FormComponent()
}

visit () {
browser.get(`/destinations/${randomNumberBewtweenOneAnd(15)}/edit`)
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}/edit`
}
}

Expand Down
10 changes: 5 additions & 5 deletions page-objects/home.js
@@ -1,14 +1,14 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const TagsComponent = require('./components/tags')

class Home {
class Home extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.tags = new TagsComponent()
}

visit () {
browser.get('/')
this.relativeUrl = '/'
}
}

Expand Down
10 changes: 5 additions & 5 deletions page-objects/tag.js
@@ -1,16 +1,16 @@
const BasePage = require('./base')

const HeaderComponent = require('./components/header')
const DestinationsComponent = require('./components/destinations')

const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN')

class Tag {
class Tag extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.destinations = new DestinationsComponent()
}

visit () {
browser.get(`/tags/${randomNumberBewtweenOneAnd(5)}`)
this.relativeUrl = `/tags/${randomNumberBewtweenOneAnd(5)}`
}
}

Expand Down

0 comments on commit 36ae57e

Please sign in to comment.