Skip to content
Permalink
Browse files
feat(protractor): Navigate.reloadPage() interaction
Closes #236
  • Loading branch information
jan-molak committed Feb 6, 2019
1 parent 74181ee commit 60ab171945da2dd2aeb9aaa902c9003475b08740
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
@@ -72,4 +72,32 @@ describe('Navigate', () => {
.to.equal(`#actor navigates forward in the browser history`);
});
});

describe('reloadPage', () => {
/** @test {Navigate.to} */
it('allows the actor to navigate to a desired destination', () => Bernie.attemptsTo(
Navigate.to(pageFromTemplate(`
<html>
<body>
<h1 id="h">Hello!</h1>
</body>
<script>
if(window.performance.navigation.type === window.performance.navigation.TYPE_RELOAD) {
document.getElementById('h').innerText = 'Reloaded'
}
</script>
</html>
`)),

Navigate.reloadPage(),

Ensure.that(Text.of(Target.the('heading').located(by.id('h'))), equals('Reloaded')),
));

/** @test {Navigate#toString} */
it(`provides a sensible description of the interaction being performed`, () => {
expect(Navigate.reloadPage().toString())
.to.equal(`#actor reloads the page`);
});
});
});
@@ -25,6 +25,10 @@ export abstract class Navigate implements Interaction {
return new NavigateForward();
}

static reloadPage() {
return new ReloadPage();
}

abstract performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void>;

abstract toString(): string;
@@ -65,3 +69,13 @@ class NavigateForward extends Navigate {
return formatted `#actor navigates forward in the browser history`;
}
}

class ReloadPage extends Navigate {
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
return promiseOf(BrowseTheWeb.as(actor).navigate().refresh());
}

toString(): string {
return formatted `#actor reloads the page`;
}
}

0 comments on commit 60ab171

Please sign in to comment.