Skip to content

Commit faa7d81

Browse files
committed
Add browser().reload() to simulate a refresh from a user
1 parent 6bb2cd6 commit faa7d81

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

example/personalLog/scenario/personalLogScenario.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ describe('personal log', function() {
6464
element('form input[type="submit"]').click();
6565
expect(repeater('ul li').count()).toEqual(1);
6666

67-
browser().navigateTo('about:blank');
68-
browser().navigateTo('../personalLog.html');
67+
browser().reload();
6968

7069
expect(repeater('ul li').column('log.msg')).toEqual('my persistent message');
7170
expect(repeater('ul li').count()).toEqual(1);

src/scenario/dsl.js

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ angular.scenario.dsl('pause', function() {
3131
* Usage:
3232
* browser().navigateTo(url) Loads the url into the frame
3333
* browser().navigateTo(url, fn) where fn(url) is called and returns the URL to navigate to
34+
* browser().reload() refresh the page (reload the same URL)
3435
* browser().location().href() the full URL of the page
3536
* browser().location().hash() the full hash in the url
3637
* browser().location().path() the full path in the url
@@ -52,6 +53,16 @@ angular.scenario.dsl('browser', function() {
5253
});
5354
};
5455

56+
chain.reload = function() {
57+
var application = this.application;
58+
return this.addFutureAction('browser reload', function($window, $document, done) {
59+
var href = $window.location.href;
60+
application.navigateTo(href, function() {
61+
done(null, href);
62+
}, done);
63+
});
64+
};
65+
5566
chain.location = function() {
5667
var api = {};
5768

test/scenario/dslSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ describe("angular.scenario.dsl", function() {
8888
});
8989

9090
describe('Browser', function() {
91+
describe('Reload', function() {
92+
it('should navigateTo', function() {
93+
$window.location = {
94+
href: '#foo'
95+
};
96+
$root.dsl.browser().reload();
97+
expect($root.futureResult).toEqual('#foo');
98+
expect($window.location).toEqual('#foo');
99+
});
100+
});
101+
91102
describe('NavigateTo', function() {
92103
it('should allow a string url', function() {
93104
$root.dsl.browser().navigateTo('http://myurl');

0 commit comments

Comments
 (0)