Use real pointer input and server progress in mobile movement test
This commit is contained in:
+27
-2
@@ -98,6 +98,11 @@ test('desktop renders models, moves authoritatively, gathers, and reconnects', a
|
||||
});
|
||||
|
||||
test('mobile controls fit and move the character', async ({ page }) => {
|
||||
// Entry, authoritative movement and screenshots each need time on software
|
||||
// rendering; allow their bounded waits to finish on the CI worker.
|
||||
test.slow();
|
||||
const errors: string[] = [];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
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.
|
||||
@@ -110,8 +115,27 @@ test('mobile controls fit and move the character', async ({ page }) => {
|
||||
await expect(page.getByRole('button', { name: 'Move north' })).toBeVisible();
|
||||
const before = await page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z);
|
||||
const button = page.getByRole('button', { name: 'Move north' });
|
||||
await button.dispatchEvent('pointerdown', { pointerId: 1 }); await page.waitForTimeout(650); await button.dispatchEvent('pointerup', { pointerId: 1 });
|
||||
await expect.poll(() => page.evaluate(() => (window as any).__aeternalis.snapshot.self.entity.position.z)).toBeLessThan(before - 2);
|
||||
// Pointer capture needs an active browser pointer, not a synthetic pointer ID.
|
||||
// Hold until the server confirms movement rather than releasing after 650ms
|
||||
// and assuming the CI browser sent enough movement intents during that time.
|
||||
await button.hover();
|
||||
await page.mouse.down();
|
||||
try {
|
||||
await expect.poll(() => page.evaluate(startZ => {
|
||||
const s = (window as any).__aeternalis.snapshot;
|
||||
return {
|
||||
movedNorth: s.self.entity.position.z < startZ - 2,
|
||||
position: s.self.entity.position,
|
||||
movementFactor: s.self.movementFactor,
|
||||
ack: s.self.ack,
|
||||
tick: s.tick,
|
||||
connection: document.querySelector('#connection-status')?.textContent,
|
||||
message: s.message,
|
||||
};
|
||||
}, before), { timeout: 15000, message: 'Holding Move north must produce authoritative movement' }).toMatchObject({ movedNorth: true });
|
||||
} finally {
|
||||
await page.mouse.up();
|
||||
}
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
await page.getByRole('button', { name: 'Inventory and crafting' }).click();
|
||||
const box = await page.locator('#inventory').boundingBox();
|
||||
@@ -121,6 +145,7 @@ test('mobile controls fit and move the character', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 844, height: 390 });
|
||||
await page.screenshot({ path: 'test-results/mobile-landscape.png' });
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test('unauthenticated API and hostile origins cannot mutate state', async ({ request }) => {
|
||||
|
||||
Reference in New Issue
Block a user