Improve mobile action layout and preserve touch scrolling
This commit is contained in:
parent
4d41681ad5
commit
126c9670f0
8 changed files with 434 additions and 80 deletions
|
|
@ -18,7 +18,8 @@
|
|||
"test:tutorial": "pnpm --filter outpost-engine build && node --test tests/tutorial.spec.mjs",
|
||||
"test:tutorial:browser": "node tests/tutorial-browser.mjs",
|
||||
"preview:tutorial": "node tests/tutorial-preview.mjs",
|
||||
"test:locales": "node scripts/check-locales.mjs packages/viewer/src/localization && node --test scripts/localization.test.mjs"
|
||||
"test:locales": "node scripts/check-locales.mjs packages/viewer/src/localization && node --test scripts/localization.test.mjs",
|
||||
"test:scroll": "node tests/mobile-scroll.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"oxfmt": "0.61.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "outpost-viewer",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"description": "Browser viewer for the Outpost game on boardgamers.space",
|
||||
"license": "AGPL-3.0",
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
</script>
|
||||
|
||||
{#if state && !state.ended && !store.replay.active && !store.myBidTurn}
|
||||
<div class="actionbar" data-tutorial="actions">
|
||||
<div class="actionbar" class:browsing={store.myActionTurn && !pending} data-tutorial="actions">
|
||||
{#if store.myMega && me}
|
||||
<div class="flow mega-flow">
|
||||
<span class="hint gold-hint">
|
||||
|
|
@ -219,45 +219,51 @@
|
|||
<button class="cancel" onclick={() => store.cancel()}>Cancel</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flow wrap">
|
||||
<div class="flow wrap purchase-options">
|
||||
<span class="hint">Your turn. Credits: <strong class="cash">◈ {store.myHandValue}</strong></span>
|
||||
<span class="group-label">New factory:</span>
|
||||
{#each FACTORY_TYPES as type (type)}
|
||||
{@const spec = FACTORIES[type]}
|
||||
{@const reason = factoryReason[type]}
|
||||
<button
|
||||
class="buy res-{type}"
|
||||
disabled={!store.canAffordFactory(type)}
|
||||
title={reason ??
|
||||
`${RESOURCE_LABELS[type]} factory: ◈ ${spec.cost}, ${spec.vp} VP manned, produces a ◈ ${MIN_CARD_VALUE[type]}–${MAX_CARD_VALUE[type]} card each round when manned`}
|
||||
onclick={() => store.startFactoryPayment(type)}
|
||||
>
|
||||
<ResourceIcon resource={type} size={13} />
|
||||
{RESOURCE_LABELS[type]} · ◈ {spec.cost}
|
||||
</button>
|
||||
{/each}
|
||||
<span class="group-label">Operators:</span>
|
||||
<button
|
||||
class="buy"
|
||||
disabled={me.population >= store.popMaxOf(store.playerIndex ?? -1) || store.myHandValue < store.popCost}
|
||||
title="Recruit a colonist: {store.popCost} credits{me.upgrades.ecoplants > 0
|
||||
? ' (Ecoplants discount)'
|
||||
: ''}"
|
||||
onclick={() => store.startPopulationPayment()}
|
||||
>
|
||||
Colonist · ◈ {store.popCost}
|
||||
</button>
|
||||
{#if me.upgrades.robots > 0}
|
||||
<div class="factory-options">
|
||||
<div class="factory-label">New factory</div>
|
||||
<div class="factory-buttons">
|
||||
{#each FACTORY_TYPES as type (type)}
|
||||
{@const spec = FACTORIES[type]}
|
||||
{@const reason = factoryReason[type]}
|
||||
<button
|
||||
class="buy res-{type}"
|
||||
disabled={!store.canAffordFactory(type)}
|
||||
title={reason ??
|
||||
`${RESOURCE_LABELS[type]} factory: ◈ ${spec.cost}, ${spec.vp} VP manned, produces a ◈ ${MIN_CARD_VALUE[type]}–${MAX_CARD_VALUE[type]} card each round when manned`}
|
||||
onclick={() => store.startFactoryPayment(type)}
|
||||
>
|
||||
<ResourceIcon resource={type} size={13} />
|
||||
{RESOURCE_LABELS[type]} · ◈ {spec.cost}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="operator-options">
|
||||
<span class="group-label">Operators:</span>
|
||||
<button
|
||||
class="buy"
|
||||
disabled={store.myHandValue < 10}
|
||||
title="Buy a robot: 10 credits"
|
||||
onclick={() => store.startRobotsPayment()}
|
||||
disabled={me.population >= store.popMaxOf(store.playerIndex ?? -1) || store.myHandValue < store.popCost}
|
||||
title="Recruit a colonist: {store.popCost} credits{me.upgrades.ecoplants > 0
|
||||
? ' (Ecoplants discount)'
|
||||
: ''}"
|
||||
onclick={() => store.startPopulationPayment()}
|
||||
>
|
||||
Robot · ◈ 10
|
||||
Colonist · ◈ {store.popCost}
|
||||
</button>
|
||||
{/if}
|
||||
<button class="end" onclick={() => store.startManning()}>Assign operators…</button>
|
||||
{#if me.upgrades.robots > 0}
|
||||
<button
|
||||
class="buy"
|
||||
disabled={store.myHandValue < 10}
|
||||
title="Buy a robot: 10 credits"
|
||||
onclick={() => store.startRobotsPayment()}
|
||||
>
|
||||
Robot · ◈ 10
|
||||
</button>
|
||||
{/if}
|
||||
<button class="end" onclick={() => store.startManning()}>Assign operators…</button>
|
||||
</div>
|
||||
</div>
|
||||
{#if staged.length > 0}
|
||||
<div class="flow">
|
||||
|
|
@ -267,11 +273,12 @@
|
|||
<button class="cancel" onclick={() => store.undoBuy()}>Undo last</button>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flow">
|
||||
<span class="hint dim">
|
||||
<details class="action-help">
|
||||
<summary>How to buy</summary>
|
||||
<p class="hint dim">
|
||||
Click a market upgrade to auction it, or a buy button and then the hand cards to pay with.
|
||||
</span>
|
||||
</div>
|
||||
</p>
|
||||
</details>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="flow">
|
||||
|
|
@ -403,4 +410,82 @@
|
|||
.cash {
|
||||
color: var(--gold);
|
||||
}
|
||||
|
||||
.purchase-options {
|
||||
align-items: stretch;
|
||||
}
|
||||
.purchase-options > .hint {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.factory-options {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.factory-label {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.factory-buttons .buy:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--res) 15%, var(--bg-panel));
|
||||
}
|
||||
.action-help summary {
|
||||
cursor: pointer;
|
||||
min-height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.action-help summary::after {
|
||||
content: "+";
|
||||
margin-left: auto;
|
||||
}
|
||||
details[open] > summary::after {
|
||||
content: "−";
|
||||
}
|
||||
.factory-buttons,
|
||||
.operator-options {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
.operator-options {
|
||||
flex-basis: 100%;
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 8px;
|
||||
}
|
||||
.operator-options .group-label {
|
||||
flex-basis: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.action-help {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
@media (max-width: 1099px) and (max-height: 600px) {
|
||||
.actionbar {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.actionbar {
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.actionbar.browsing {
|
||||
position: static;
|
||||
}
|
||||
.buy,
|
||||
.end {
|
||||
min-height: 44px;
|
||||
}
|
||||
.factory-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
.buy {
|
||||
padding: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -316,12 +316,19 @@
|
|||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 8px 12px;
|
||||
line-height: 18px;
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
@media (max-height: 600px) {
|
||||
.feed {
|
||||
max-height: 160px;
|
||||
}
|
||||
}
|
||||
.entry {
|
||||
margin-bottom: 4px;
|
||||
font-size: 12px;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,12 @@
|
|||
|
||||
<div class="side">
|
||||
<div class="caption">Recent events</div>
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex (Keyboard users must be able to scroll the journal.) -->
|
||||
<div
|
||||
class="feed"
|
||||
role="region"
|
||||
aria-label="Recent events"
|
||||
tabindex="0"
|
||||
bind:this={feed}
|
||||
onscroll={() => {
|
||||
if (feed) {
|
||||
|
|
@ -91,8 +95,17 @@
|
|||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 8px 12px;
|
||||
/* Whole-pixel rows avoid a fractional scroll boundary swallowing touch gestures. */
|
||||
line-height: 18px;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: auto;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@media (max-height: 600px) {
|
||||
.feed {
|
||||
max-height: 160px;
|
||||
}
|
||||
}
|
||||
.entries {
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -141,29 +141,32 @@
|
|||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="supply">
|
||||
{#each supplyByEra as x (x.era)}
|
||||
<span class="stag era-{x.era} ks-era" class:current={x.era === gameEra}>
|
||||
<span class="stag-era">{["", "I", "II", "III"][x.era]}</span>
|
||||
</span>
|
||||
{#each x.counts as c (c.u)}
|
||||
{@const spec = UPGRADE_SPECS[c.u]}
|
||||
<span
|
||||
class="stag era-{x.era}"
|
||||
title="{spec.name} ({spec.vp} VP, list ◈ {spec.price}): {effectToText(
|
||||
UPGRADE_EFFECTS[c.u]
|
||||
)} ×{c.n} left in the supply — Era {['', 'I', 'II', 'III'][x.era]} upgrade (card #{upgradeNumber(
|
||||
c.u
|
||||
)}){x.era === gameEra ? ' (current era)' : ''}"
|
||||
>
|
||||
{spec.name} <span class="kcount">×{c.n}</span>
|
||||
<details class="supply-details">
|
||||
<summary>Remaining upgrades</summary>
|
||||
<div class="supply">
|
||||
{#each supplyByEra as x (x.era)}
|
||||
<span class="stag era-{x.era} ks-era" class:current={x.era === gameEra}>
|
||||
<span class="stag-era">{["", "I", "II", "III"][x.era]}</span>
|
||||
</span>
|
||||
{#each x.counts as c (c.u)}
|
||||
{@const spec = UPGRADE_SPECS[c.u]}
|
||||
<span
|
||||
class="stag era-{x.era}"
|
||||
title="{spec.name} ({spec.vp} VP, list ◈ {spec.price}): {effectToText(
|
||||
UPGRADE_EFFECTS[c.u]
|
||||
)} ×{c.n} left in the supply — Era {['', 'I', 'II', 'III'][x.era]} upgrade (card #{upgradeNumber(
|
||||
c.u
|
||||
)}){x.era === gameEra ? ' (current era)' : ''}"
|
||||
>
|
||||
{spec.name} <span class="kcount">×{c.n}</span>
|
||||
</span>
|
||||
{/each}
|
||||
{/each}
|
||||
{/each}
|
||||
{#if supplyByEra.length === 0}
|
||||
<span class="stag dim">Supply exhausted</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if supplyByEra.length === 0}
|
||||
<span class="stag dim">Supply exhausted</span>
|
||||
{/if}
|
||||
</div>
|
||||
</details>
|
||||
{#if state.kickerMarket.length > 0}
|
||||
<div class="caption kicker-caption">Kicker cards — era {["", "I", "II", "III"][state.kickerEra]}</div>
|
||||
<div class="cards">
|
||||
|
|
@ -231,26 +234,29 @@
|
|||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="supply ksupply">
|
||||
{#each kickerSupply as x (x.era)}
|
||||
<span class="stag era-{x.era} ks-era" class:current={x.era === state.kickerEra}>
|
||||
<span class="stag-era">{["", "I", "II", "III"][x.era]}</span>
|
||||
</span>
|
||||
{#each x.counts as c (c.k)}
|
||||
{@const spec = KICKER_SPECS[c.k]}
|
||||
<span
|
||||
class="stag era-{x.era}"
|
||||
title="{spec.name} ({spec.vp} VP, list ◈ {spec.price}): {effectToText(
|
||||
KICKER_EFFECTS[c.k]
|
||||
)} ×{c.n} left in the Era {['', 'I', 'II', 'III'][x.era]} pile{x.era === state.kickerEra
|
||||
? ' (current era)'
|
||||
: ''}"
|
||||
>
|
||||
{spec.name} <span class="kcount">×{c.n}</span>
|
||||
<details class="supply-details">
|
||||
<summary>Remaining Kicker cards</summary>
|
||||
<div class="supply ksupply">
|
||||
{#each kickerSupply as x (x.era)}
|
||||
<span class="stag era-{x.era} ks-era" class:current={x.era === state.kickerEra}>
|
||||
<span class="stag-era">{["", "I", "II", "III"][x.era]}</span>
|
||||
</span>
|
||||
{#each x.counts as c (c.k)}
|
||||
{@const spec = KICKER_SPECS[c.k]}
|
||||
<span
|
||||
class="stag era-{x.era}"
|
||||
title="{spec.name} ({spec.vp} VP, list ◈ {spec.price}): {effectToText(
|
||||
KICKER_EFFECTS[c.k]
|
||||
)} ×{c.n} left in the Era {['', 'I', 'II', 'III'][x.era]} pile{x.era === state.kickerEra
|
||||
? ' (current era)'
|
||||
: ''}"
|
||||
>
|
||||
{spec.name} <span class="kcount">×{c.n}</span>
|
||||
</span>
|
||||
{/each}
|
||||
{/each}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
|
@ -480,4 +486,48 @@
|
|||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.supply-details summary {
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: var(--text-mid);
|
||||
padding: 10px 4px;
|
||||
min-height: 44px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.supply-details .supply {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
}
|
||||
.ucard {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 4px 10px;
|
||||
min-height: 0;
|
||||
padding: 8px 10px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.uname {
|
||||
flex: 1;
|
||||
}
|
||||
.uvp {
|
||||
margin-left: auto;
|
||||
}
|
||||
.uprice,
|
||||
.ueffect {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.bidbox {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.bidrow button {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -64,6 +64,21 @@ body {
|
|||
min-height: 100vh;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
summary,
|
||||
a {
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
@media (any-pointer: coarse) {
|
||||
/* Disabled native controls can swallow the start of a touch scroll. */
|
||||
button:disabled,
|
||||
button:disabled * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
|
|
|
|||
183
tests/mobile-scroll.mjs
Normal file
183
tests/mobile-scroll.mjs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { chromium } from "playwright";
|
||||
import { initGame } from "../packages/engine/dist/index.js";
|
||||
import { stripSecret } from "../packages/engine/dist/wrapper.js";
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
try {
|
||||
const configurations = [
|
||||
{ width: 320, height: 568 },
|
||||
{ width: 390, height: 844 },
|
||||
{ width: 844, height: 393 },
|
||||
].flatMap((viewport) => [false, true].map((embedded) => ({ viewport, embedded })));
|
||||
await Promise.all(
|
||||
configurations.map(async ({ viewport, embedded }) => {
|
||||
const page = await browser.newPage({ viewport, isMobile: true, hasTouch: true });
|
||||
const errors = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
const markup =
|
||||
'<!doctype html><meta name="viewport" content="width=device-width, initial-scale=1"><div id="app"></div>';
|
||||
let frame = page;
|
||||
if (embedded) {
|
||||
await page.setContent(
|
||||
'<!doctype html><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{margin:0}iframe{width:100%;border:0;display:block}</style><iframe></iframe><footer style="height:600px"></footer>'
|
||||
);
|
||||
frame = page.frames()[1];
|
||||
await frame.setContent(markup);
|
||||
} else {
|
||||
await page.setContent(`${markup}<footer style="height:600px"></footer>`);
|
||||
}
|
||||
await frame.addStyleTag({ path: "packages/viewer/dist/outpost-viewer.css" });
|
||||
await frame.addScriptTag({ path: "packages/viewer/dist/outpost-viewer.iife.js" });
|
||||
const state = initGame(3, { fastBid: true, kicker: true }, "protocol-smoke");
|
||||
await frame.evaluate(
|
||||
(state) => {
|
||||
window.moves = [];
|
||||
window.emitter = outpost.launch("#app");
|
||||
emitter.on("move", (move) => moves.push(move));
|
||||
emitter.emit("player", { index: 0 });
|
||||
emitter.emit("preferences", { sound: false });
|
||||
emitter.emit("state", state);
|
||||
emitter.emit("chat:state", { canSend: true });
|
||||
emitter.emit(
|
||||
"chat:messages",
|
||||
Array.from({ length: 60 }, (_, i) => ({
|
||||
_id: (i + 1).toString(16).padStart(24, "0"),
|
||||
text: `Message ${i} about the ongoing game`,
|
||||
type: "text",
|
||||
author: "Other",
|
||||
playerIndex: 1,
|
||||
}))
|
||||
);
|
||||
emitter.emit("gamelog", {
|
||||
start: state.log.length,
|
||||
data: {
|
||||
log: Array.from({ length: 80 }, () => ({
|
||||
type: "move",
|
||||
player: 1,
|
||||
move: { action: "bid", amount: 30 },
|
||||
})),
|
||||
},
|
||||
});
|
||||
},
|
||||
stripSecret(state, 0)
|
||||
);
|
||||
await frame.locator(".actionbar button:disabled").first().waitFor({ state: "visible" });
|
||||
if (embedded) {
|
||||
await frame.evaluate(() => {
|
||||
const resize = () => {
|
||||
window.frameElement.style.height = `${document.body.scrollHeight}px`;
|
||||
};
|
||||
new ResizeObserver(resize).observe(document.body);
|
||||
resize();
|
||||
});
|
||||
}
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
async function swipe(locator, deltaY, deltaX = 0) {
|
||||
const bounds = await locator.boundingBox();
|
||||
assert.ok(bounds);
|
||||
const x = bounds.x + bounds.width / 2;
|
||||
const y = bounds.y + bounds.height / 2;
|
||||
assert.ok(y > 0 && y < viewport.height, `Touch target is visible: ${y}`);
|
||||
await cdp.send("Input.dispatchTouchEvent", { type: "touchStart", touchPoints: [{ x, y }] });
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
await cdp.send("Input.dispatchTouchEvent", {
|
||||
type: "touchMove",
|
||||
touchPoints: [{ x: x + (deltaX * i) / 12, y: y + (deltaY * i) / 12 }],
|
||||
});
|
||||
await page.waitForTimeout(20);
|
||||
}
|
||||
await page.waitForTimeout(100);
|
||||
await cdp.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
|
||||
await page.waitForTimeout(180);
|
||||
}
|
||||
async function center(locator) {
|
||||
await locator.evaluate((el) => el.scrollIntoView({ block: "center" }));
|
||||
await page.waitForTimeout(100);
|
||||
}
|
||||
async function pageScrollsFrom(locator, label) {
|
||||
await center(locator);
|
||||
const before = await page.evaluate(() => scrollY);
|
||||
await swipe(locator, -100);
|
||||
assert.ok((await page.evaluate(() => scrollY)) > before + 40, `${label}: page scrolls`);
|
||||
assert.equal(await frame.evaluate(() => moves.length), 0, `${label}: swipe does not play`);
|
||||
}
|
||||
await pageScrollsFrom(frame.locator(".factory-buttons button:not(:disabled)").last(), "enabled buy button");
|
||||
const disabled = frame.locator(".factory-buttons button:disabled").first();
|
||||
await pageScrollsFrom(disabled, "disabled buy button");
|
||||
await center(disabled);
|
||||
const disabledBounds = await disabled.boundingBox();
|
||||
await page.touchscreen.tap(
|
||||
disabledBounds.x + disabledBounds.width / 2,
|
||||
disabledBounds.y + disabledBounds.height / 2
|
||||
);
|
||||
assert.equal(await frame.locator(".factory-buttons").count(), 1, "disabled tap does not open a purchase");
|
||||
await pageScrollsFrom(frame.locator(".me .pcard").first(), "hand card");
|
||||
await pageScrollsFrom(frame.locator(".market .ucard").first(), "market card");
|
||||
await pageScrollsFrom(frame.locator(".factory-buttons button:not(:disabled) svg").first(), "resource icon");
|
||||
await frame.evaluate(() => emitter.emit("player", { index: 1 }));
|
||||
await pageScrollsFrom(frame.locator(".market .ucard:disabled").first(), "disabled market card");
|
||||
await pageScrollsFrom(frame.locator(".pcard:disabled").first(), "disabled hand card");
|
||||
await frame.evaluate(() => emitter.emit("player", { index: 0 }));
|
||||
for (const name of ["Chat messages", "Recent events"]) {
|
||||
const feed = frame.getByRole("region", { name, exact: true });
|
||||
await center(feed);
|
||||
await feed.evaluate((el) => {
|
||||
el.scrollTop = 300;
|
||||
});
|
||||
await page.waitForTimeout(100);
|
||||
const outer = await page.evaluate(() => scrollY);
|
||||
await swipe(feed, -70);
|
||||
assert.ok((await feed.evaluate((el) => el.scrollTop)) > 330, `${name}: scrolls internally`);
|
||||
assert.ok(
|
||||
Math.abs((await page.evaluate(() => scrollY)) - outer) < 3,
|
||||
`${name}: internal gesture stays in feed`
|
||||
);
|
||||
await feed.evaluate((el) => {
|
||||
el.scrollTop = 60;
|
||||
});
|
||||
await page.waitForTimeout(80);
|
||||
await swipe(feed, 100);
|
||||
assert.equal(await feed.evaluate((el) => el.scrollTop), 0, `${name}: touch reaches the top`);
|
||||
const beforeTop = await page.evaluate(() => scrollY);
|
||||
await swipe(feed, 70);
|
||||
assert.ok((await page.evaluate(() => scrollY)) < beforeTop - 30, `${name}: top edge releases to page`);
|
||||
await center(feed);
|
||||
await feed.evaluate((el) => {
|
||||
el.scrollTop = el.scrollHeight - el.clientHeight - 60;
|
||||
});
|
||||
await page.waitForTimeout(80);
|
||||
await swipe(feed, -100);
|
||||
assert.ok(
|
||||
await feed.evaluate((el) => el.scrollHeight - el.clientHeight - el.scrollTop < 1),
|
||||
`${name}: touch reaches the bottom`
|
||||
);
|
||||
const beforeBottom = await page.evaluate(() => scrollY);
|
||||
await swipe(feed, -70);
|
||||
assert.ok((await page.evaluate(() => scrollY)) > beforeBottom + 30, `${name}: bottom edge releases to page`);
|
||||
}
|
||||
await frame.evaluate(() => emitter.emit("replay:start"));
|
||||
const marks = frame.locator(".marks");
|
||||
await center(marks);
|
||||
await swipe(marks, 0, -85);
|
||||
assert.ok((await marks.evaluate((el) => el.scrollLeft)) > 30, "replay timeline still scrolls horizontally");
|
||||
await pageScrollsFrom(marks, "replay timeline vertical gesture");
|
||||
await frame.evaluate(() => emitter.emit("replay:end"));
|
||||
await frame.locator(".factory-buttons button:not(:disabled)").last().tap();
|
||||
assert.equal(await frame.locator(".factory-buttons").count(), 0, "a tap still opens a purchase");
|
||||
await pageScrollsFrom(frame.locator(".actionbar button:disabled").first(), "disabled payment confirmation");
|
||||
assert.equal(
|
||||
await frame.evaluate(() => document.documentElement.scrollWidth > innerWidth),
|
||||
false,
|
||||
"no horizontal page overflow"
|
||||
);
|
||||
assert.deepEqual(errors, []);
|
||||
console.log(
|
||||
`Outpost touch scrolling: ${viewport.width}×${viewport.height}, ${embedded ? "auto-height iframe" : "standalone"} passed`
|
||||
);
|
||||
await page.close();
|
||||
})
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue