Skip to content

Commit 36ae57e

Browse files
author
Walmyr Filho
committed
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.
1 parent 19792d2 commit 36ae57e

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

page-objects/destination.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
const BasePage = require('./base')
2+
13
const HeaderComponent = require('./components/header')
24
const DestinationComponent = require('./components/destination')
35

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

6-
class Destination {
8+
class Destination extends BasePage {
79
constructor () {
10+
super()
811
this.header = new HeaderComponent()
912
this.self = new DestinationComponent()
10-
}
11-
12-
visit () {
13-
browser.get(`/destinations/${randomNumberBewtweenOneAnd(15)}`)
13+
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}`
1414
}
1515
}
1616

page-objects/editDestination.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
const BasePage = require('./base')
2+
13
const HeaderComponent = require('./components/header')
24
const DestinationComponent = require('./components/destination')
35
const FormComponent = require('./components/form')
46

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

7-
class EditDestination {
9+
class EditDestination extends BasePage {
810
constructor () {
11+
super()
912
this.header = new HeaderComponent()
1013
this.self = new DestinationComponent()
1114
this.form = new FormComponent()
12-
}
13-
14-
visit () {
15-
browser.get(`/destinations/${randomNumberBewtweenOneAnd(15)}/edit`)
15+
this.relativeUrl = `/destinations/${randomNumberBewtweenOneAnd(15)}/edit`
1616
}
1717
}
1818

page-objects/home.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
const BasePage = require('./base')
2+
13
const HeaderComponent = require('./components/header')
24
const TagsComponent = require('./components/tags')
35

4-
class Home {
6+
class Home extends BasePage {
57
constructor () {
8+
super()
69
this.header = new HeaderComponent()
710
this.tags = new TagsComponent()
8-
}
9-
10-
visit () {
11-
browser.get('/')
11+
this.relativeUrl = '/'
1212
}
1313
}
1414

page-objects/tag.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
const BasePage = require('./base')
2+
13
const HeaderComponent = require('./components/header')
24
const DestinationsComponent = require('./components/destinations')
35

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

6-
class Tag {
8+
class Tag extends BasePage {
79
constructor () {
10+
super()
811
this.header = new HeaderComponent()
912
this.destinations = new DestinationsComponent()
10-
}
11-
12-
visit () {
13-
browser.get(`/tags/${randomNumberBewtweenOneAnd(5)}`)
13+
this.relativeUrl = `/tags/${randomNumberBewtweenOneAnd(5)}`
1414
}
1515
}
1616

0 commit comments

Comments
 (0)