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: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: 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> </head>
<body> <body>
<label>Base test URL:</label> <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> <table>
<tr> <tr>
<th>Result</th> <th>Result</th>
@ -166,6 +166,21 @@
<script> <script>
const baseInput = document.getElementById('baseurl'); 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); baseInput.addEventListener('change', init);
function init() { function init() {