Fix world entry readiness and mobile startup test

This commit is contained in:
dingo
2026-09-10 11:09:51 -04:00
parent 1bd5d487e2
commit c86f4c1f24
3 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -28,7 +28,7 @@
</footer>
<nav id="movement" class="movement" aria-label="Movement" hidden><button data-move="up" aria-label="Move north"><i data-lucide="chevron-up"></i></button><button data-move="left" aria-label="Move west"><i data-lucide="chevron-left"></i></button><button data-move="down" aria-label="Move south"><i data-lucide="chevron-down"></i></button><button data-move="right" aria-label="Move east"><i data-lucide="chevron-right"></i></button></nav>
</div>
<dialog id="arrival" open><div class="eyebrow">THE FIRST REACH</div><h1>Aeternalis</h1><p id="arrival-status">One life. A world on borrowed time.</p><form id="join-form"><label for="name">Character name</label><input id="name" name="name" autocomplete="nickname" minlength="2" maxlength="24" placeholder="Traveler" required value="Traveler" /><button id="join" type="submit">Enter world <i data-lucide="arrow-right"></i></button></form><a id="login" class="command" href="/auth/login" hidden>Sign in <i data-lucide="arrow-right"></i></a><div id="passages"></div><p id="arrival-error" class="error" role="alert"></p></dialog>
<dialog id="arrival" open><div class="eyebrow">THE FIRST REACH</div><h1>Aeternalis</h1><p id="arrival-status">One life. A world on borrowed time.</p><form id="join-form"><label for="name">Character name</label><input id="name" name="name" autocomplete="nickname" minlength="2" maxlength="24" placeholder="Traveler" required value="Traveler" /><button id="join" type="submit" disabled>Enter world <i data-lucide="arrow-right"></i></button></form><a id="login" class="command" href="/auth/login" hidden>Sign in <i data-lucide="arrow-right"></i></a><div id="passages"></div><p id="arrival-error" class="error" role="alert"></p></dialog>
<dialog id="ending"><div class="eyebrow" id="ending-eyebrow">JOURNEY ENDED</div><h1 id="ending-title">Your story remains.</h1><p id="ending-detail"></p><div id="destinations"></div><button id="new-character" hidden>New character <i data-lucide="arrow-right"></i></button><button id="reconnect" hidden>Reconnect <i data-lucide="refresh-cw"></i></button><a href="/" class="command">World directory</a></dialog>
<script type="module" src="/src/main.ts"></script>
</body>
+3 -1
View File
@@ -277,10 +277,10 @@ async function boot() {
travelButton.onclick=()=>{if(!snapshot)return;input.clear();walkTo=undefined;pendingAction=undefined;send('move');void showTravel({worldId:config.worldId,route:config.kind==='hub'?'hub':snapshot.world.phase==='won'?'portal':'escape',beforeTravel:()=>{requestedClose=true;},afterTravel:departed=>{requestedClose=departed;}});};
$<HTMLInputElement>('zoom').value = String(view.distance);
view.addChunks(chunks); view.updateEntities(chunks.flatMap(c => c.resources));
$('connection-status').textContent = 'World online';
visible('dev-boss', config.development);
let me: { character: Character | null; active?: { worldId: string; state: string; name: string } } | undefined;
try { me = await api('/api/me'); } catch { if (config.development) { await api('/auth/dev', {}); me = await api('/api/me'); } }
$('connection-status').textContent = 'World online';
if (!me && !config.development) { visible('join-form', false); visible('login', true); }
else if (me?.character) {
$<HTMLDialogElement>('arrival').close();
@@ -336,5 +336,7 @@ async function boot() {
else if (hit.point) { selection(); walkTo = hit.point; pendingAction = undefined; }
});
Object.defineProperty(window, '__aeternalis', { value: { diagnostics: () => view.diagnostics(), get snapshot() { return snapshot; }, get walkTo() { return walkTo; }, get pendingAction() { return pendingAction; }, get keys() { return input.keys; } }, configurable: true });
// Authentication and all input handlers must be ready before character creation.
$<HTMLButtonElement>('join').disabled = !me || !!me.character || !!me.active || config.kind === 'hub';
}
boot().catch(error => { console.error(error); $('arrival-error').textContent = `Unable to enter the world: ${error.message}`; $('connection-status').textContent = 'Unavailable'; });
+8 -1
View File
@@ -5,8 +5,8 @@ async function enter(page, name = 'Wayfarer') {
await expect(page.locator('#connection-status')).toHaveText('World online');
await page.getByLabel('Character name').fill(name);
await page.getByRole('button', { name: 'Enter world' }).click();
await expect(page.locator('#game-controls')).toBeVisible();
await expectWorldReady(page);
await expect(page.locator('#game-controls')).toBeVisible();
}
async function expectWorldReady(page, characterId?: string) {
@@ -80,6 +80,13 @@ test('desktop renders models, moves authoritatively, gathers, and reconnects', a
test('mobile controls fit and move the character', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
// Hold authentication at the network boundary: entry must stay unavailable
// until it completes, even when the world preview has already loaded.
await page.route('**/api/me', async route => {
await expect(page.getByRole('button', { name: 'Enter world' })).toBeDisabled();
await expect(page.locator('#connection-status')).not.toHaveText('World online');
await route.continue();
}, { times: 1 });
await enter(page, 'Mobile');
await expect(page.getByRole('button', { name: 'Move north' })).toBeVisible();
const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z);