Skip to content

Commit 6a30a77

Browse files
author
Walmyr Filho
committed
Move header instantiation to base page
This way, all page objects have access to it without the need for code duplication.
1 parent 36ae57e commit 6a30a77

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

page-objects/base.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
const HeaderComponent = require('./components/header')
2+
13
class Base {
4+
constructor () {
5+
this.header = new HeaderComponent()
6+
}
7+
28
visit () {
39
browser.get(this.relativeUrl)
410
}

page-objects/destination.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
const BasePage = require('./base')
22

3-
const HeaderComponent = require('./components/header')
43
const DestinationComponent = require('./components/destination')
54

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

87
class Destination extends BasePage {
98
constructor () {
109
super()
11-
this.header = new HeaderComponent()
1210
this.self = new DestinationComponent()
1311
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}`
1412
}

page-objects/editDestination.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const BasePage = require('./base')
22

3-
const HeaderComponent = require('./components/header')
43
const DestinationComponent = require('./components/destination')
54
const FormComponent = require('./components/form')
65

@@ -9,7 +8,6 @@ const randomNumberBewtweenOneAnd = require('../utils/randomNumberBewtweenOneAndN
98
class EditDestination extends BasePage {
109
constructor () {
1110
super()
12-
this.header = new HeaderComponent()
1311
this.self = new DestinationComponent()
1412
this.form = new FormComponent()
1513
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}/edit`

page-objects/home.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
const BasePage = require('./base')
22

3-
const HeaderComponent = require('./components/header')
43
const TagsComponent = require('./components/tags')
54

65
class Home extends BasePage {
76
constructor () {
87
super()
9-
this.header = new HeaderComponent()
108
this.tags = new TagsComponent()
119
this.relativeUrl = '/'
1210
}

page-objects/tag.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
const BasePage = require('./base')
22

3-
const HeaderComponent = require('./components/header')
43
const DestinationsComponent = require('./components/destinations')
54

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

87
class Tag extends BasePage {
98
constructor () {
109
super()
11-
this.header = new HeaderComponent()
1210
this.destinations = new DestinationsComponent()
1311
this.relativeUrl = `/tags/${randomNumberBewtweenOneAnd(5)}`
1412
}

0 commit comments

Comments
 (0)