Skip to content

Commit

Permalink
Move header instantiation to base page
Browse files Browse the repository at this point in the history
This way, all page objects have access to it without the need for
code duplication.
  • Loading branch information
Walmyr Filho committed May 28, 2020
1 parent 36ae57e commit 6a30a77
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions page-objects/base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const HeaderComponent = require('./components/header')

class Base {
constructor () {
this.header = new HeaderComponent()
}

visit () {
browser.get(this.relativeUrl)
}
Expand Down
2 changes: 0 additions & 2 deletions page-objects/destination.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const BasePage = require('./base')

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

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

class Destination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}`
}
Expand Down
2 changes: 0 additions & 2 deletions page-objects/editDestination.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const BasePage = require('./base')

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

Expand All @@ -9,7 +8,6 @@ const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN
class EditDestination extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.self = new DestinationComponent()
this.form = new FormComponent()
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}/edit`
Expand Down
2 changes: 0 additions & 2 deletions page-objects/home.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const BasePage = require('./base')

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

class Home extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.tags = new TagsComponent()
this.relativeUrl = '/'
}
Expand Down
2 changes: 0 additions & 2 deletions page-objects/tag.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const BasePage = require('./base')

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

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

class Tag extends BasePage {
constructor () {
super()
this.header = new HeaderComponent()
this.destinations = new DestinationsComponent()
this.relativeUrl = `/tags/${randomNumberBewtweenOneAnd(5)}`
}
Expand Down

0 comments on commit 6a30a77

Please sign in to comment.