-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f557b0
commit 0dbf69a
Showing
11 changed files
with
318 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
var webdriver = require('selenium-webdriver'); | ||
var by = webdriver.By; | ||
var baseUrl = 'http://localhost:3001/'; | ||
var preventUrl = baseUrl + 'tests/preventdefault/'; | ||
var setUrl = baseUrl + 'tests/set/'; | ||
var popstateUrl = baseUrl + 'tests/popstate/'; | ||
var hashUrl = baseUrl + 'tests/hash/'; | ||
var trailingUrl = baseUrl + 'tests/trailing/'; | ||
|
||
exports['should display current url'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(preventUrl); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, preventUrl); | ||
}); | ||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should not allow going to a new url'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(preventUrl); | ||
driver.navigate().to(preventUrl + '#/foo'); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, preventUrl); | ||
}); | ||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should set url manually when prevented'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(setUrl); | ||
driver.navigate().to(setUrl + '#/foo'); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, setUrl + '#/foo'); | ||
}); | ||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should go to popstate url'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(popstateUrl); | ||
|
||
driver.findElement(by.id('messages')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + 'messages'); | ||
}); | ||
|
||
driver.findElement(by.id('message')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + 'messages/123'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should handle back and forward with popstate'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(popstateUrl); | ||
|
||
driver.findElement(by.id('messages')).click(); | ||
driver.findElement(by.id('message')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + 'messages/123'); | ||
}); | ||
|
||
driver.navigate().back(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + 'messages'); | ||
}); | ||
|
||
driver.navigate().forward(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + 'messages/123'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should go to hash url'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(hashUrl); | ||
|
||
driver.findElement(by.id('messages')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages'); | ||
}); | ||
|
||
driver.findElement(by.id('message')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages/123'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should handle back and forward with hash'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(hashUrl); | ||
|
||
driver.findElement(by.id('messages')).click(); | ||
driver.findElement(by.id('message')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages/123'); | ||
}); | ||
|
||
driver.navigate().back(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages'); | ||
}); | ||
|
||
driver.navigate().forward(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages/123'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should handle trailing slash convertion'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(trailingUrl + '#/messages/123'); | ||
driver.navigate().to(trailingUrl + '#/messages/'); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, trailingUrl + '#/messages'); | ||
}); | ||
|
||
driver.navigate().back(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, trailingUrl + '#/messages/123'); | ||
}); | ||
|
||
driver.navigate().forward(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, trailingUrl + '#/messages'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; | ||
|
||
exports['should resume history when changing url when on "back" url'] = function (test) { | ||
|
||
var driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.chrome()). | ||
build(); | ||
driver.get(hashUrl); | ||
|
||
driver.findElement(by.id('messages')).click(); | ||
driver.findElement(by.id('message')).click(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages/123'); | ||
}); | ||
|
||
driver.navigate().back(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages'); | ||
}); | ||
|
||
driver.navigate().to(baseUrl + '#/messages/456'); | ||
driver.navigate().forward(); | ||
driver.getCurrentUrl().then(function (url) { | ||
test.equal(url, baseUrl + '#/messages/456'); | ||
}); | ||
|
||
driver.quit().then(test.done); | ||
|
||
}; |
Oops, something went wrong.