Making the test page URL dynamic depending on the environment

This commit is contained in:
David Négrier 2021-06-28 13:54:49 +02:00
parent 330a795fee
commit 7f79c2dc4a
2 changed files with 17 additions and 2 deletions

View file

@ -199,4 +199,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re
msg: "Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re \nTests available at https://maps-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re/tests"

View file

@ -4,7 +4,7 @@
</head>
<body>
<label>Base test URL:</label>
<input id="baseurl" type="text" value="http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/" />
<input id="baseurl" type="text" value="" />
<table>
<tr>
<th>Result</th>
@ -166,6 +166,21 @@
<script>
const baseInput = document.getElementById('baseurl');
let host = window.location.host;
let playHost;
if (host.startsWith('maps-')) {
playHost = 'play-'+host.substr(5);
} else if (host.startsWith('maps.')) {
playHost = 'play.'+host.substr(5);
} else {
playHost = 'localhost';
}
let completeUrl = window.location.protocol + '//' + playHost + '/_/global/' + host + window.location.pathname;
baseInput.value = completeUrl;
baseInput.addEventListener('change', init);
function init() {