Files
shanhe-puzzle/tests/helpers.mjs
codex-bot 4845826deb
Shanhe source and offline package checks / verify (pull_request) Failing after 5s
feat: sync Shanhe 2.2 source and add remote package verification
2026-11-01 17:13:46 +08:00

21 lines
1.1 KiB
JavaScript

// Navigate through visible controls, without mutating application state.
export async function chooseProvince(page,code){
const current=await page.evaluate(()=>shanheDebug.state());
if(current.entryCity)await page.locator('#atlas-back').click();
const selected=current.entryProvince;
if(selected===code)return;
if(selected)await page.locator('#atlas-back').click();
if(code)await page.locator('#reference [data-province="'+code+'"] text').click();
}
export async function setDifficulty(page,{speed,bounce,snap}){
if(!await page.locator('#confirm-journey').isVisible())await page.locator('#start').click();
if(speed!==undefined&&speed!==4)throw Error("Timed drop modes were removed; choose snap difficulty instead.");
if(snap!==undefined)await page.locator('#modal [data-snap="'+snap+'"]').click();
if(bounce!==undefined)await page.locator('#modal [data-bounce="'+bounce+'"]').click();
}
export async function startJourney(page,selector='#start'){
if(!await page.locator('#confirm-journey').isVisible())await page.locator(selector).click();
await page.locator('#confirm-journey').click();
}