Skip to content

Commit

Permalink
Add browser navigation test
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 23, 2023
1 parent 3eddd2c commit 9ad44b8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/html_files/change-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<head>
<title>change page</title>
<style type="text/css">
body {
margin: 0;
background-color: #eee;
}
header {
background-color: #111;
width: 100%;
text-align: center;
font-size: 1.3em;
color: #fff;
}
.content {
text-align: center;
}
.content > a {
padding: 5px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #fff;
text-decoration: none;
color: #111;
}
</style>
</head>
<body>
<header>change page</header>
<button id="js-wait-nav" onclick="changePage()">hey</button>
<script>
function changePage() {
setTimeout(() => {
const parts = document.location.pathname.split('/').filter(x => x.length > 0);
parts[parts.length - 1] = 'elements.html';
document.location.pathname = parts.join('/');
}, 250);
}
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions tests/ui-tests/page-change-in-wait.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This test ensures that the script is working as expecting even through browser navigation and
// page changes.
goto: "file://" + |CURRENT_DIR| + "/" + |DOC_PATH| + "/change-page.html"
assert-document-property: {"title": "change page"}
click: "#js-wait-nav"
wait-for-document-property: {"title": "Other page"}
5 changes: 5 additions & 0 deletions tests/ui-tests/page-change-in-wait.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=> Starting doc-ui tests...

page-change-in-wait... ok

<= doc-ui tests done: 1 succeeded, 0 failed

0 comments on commit 9ad44b8

Please sign in to comment.