Add WASD jumps to the LU trainer
This commit is contained in:
1 parent
ba074df4ec
commit
a2751971cd
6 files changed
+59
-5
No files matched your search
@@ -72,6 +72,44 @@ async function run() {
|
||||
const captures = [];
|
||||
try {
|
||||
if (shotDir) await mkdir(shotDir,{recursive:true});
|
||||
const shortcuts = await browser.newContext({viewport:{width:1366,height:768}});
|
||||
try {
|
||||
await shortcuts.addInitScript(() => {
|
||||
let seed = 19;
|
||||
Math.random = () => { seed = (Math.imul(seed,1664525)+1013904223) >>> 0; return seed / 2 ** 32; };
|
||||
});
|
||||
const page = await shortcuts.newPage();
|
||||
await page.goto(`${origin}/trainer`);
|
||||
const sceneCell = id => page.locator(`#scene-grid button[data-id="${id}"]`);
|
||||
const current = () => cellIds(page.locator('#scene-grid .current button'));
|
||||
await sceneCell(0).waitFor();
|
||||
await page.locator('#simple-mode').check();
|
||||
await sceneCell(0).focus();
|
||||
await page.keyboard.press('d');
|
||||
assert.deepEqual(await current(),[1]);
|
||||
await page.keyboard.down('s');
|
||||
await page.keyboard.down('s');
|
||||
await page.keyboard.up('s');
|
||||
assert.deepEqual(await current(),[11],'holding a key must not repeat jumps');
|
||||
await sceneCell(59).focus();
|
||||
await page.keyboard.press('a');
|
||||
assert.deepEqual(await current(),[10],'direction starts at the cat, not keyboard focus');
|
||||
await page.keyboard.press('w');
|
||||
assert.deepEqual(await current(),[0]);
|
||||
assert.equal(await page.locator('#history li').count(),4);
|
||||
await page.keyboard.press('a');
|
||||
await page.keyboard.press('w');
|
||||
assert.deepEqual(await current(),[0],'edges must not wrap');
|
||||
await page.keyboard.press('ArrowRight');
|
||||
assert(await sceneCell(1).evaluate(n=>n===document.activeElement));
|
||||
await page.locator('#map-grid button[data-id="1"]').focus();
|
||||
await page.keyboard.press('d');
|
||||
assert.deepEqual(await current(),[0],'map focus must not move the cat');
|
||||
await page.locator('#settings-open').click();
|
||||
await page.keyboard.press('d');
|
||||
assert.deepEqual(await current(),[0],'dialogs must not move the cat');
|
||||
console.log('PASS WASD direct jumps, repeat prevention, edges, arrows, map and dialog isolation');
|
||||
} finally { await shortcuts.close(); }
|
||||
for (const [width,height,touch = false] of [[1920,1080],[1366,768],[768,1024],[390,844,true],[844,390,true],[1024,768,true]]) {
|
||||
const mobile = width <= 700 || width === 844, compact = mobile || touch;
|
||||
const context = await browser.newContext({viewport:{width,height}, reducedMotion:'reduce', locale:'ru-RU', hasTouch:touch, isMobile:mobile});
|
||||
|
||||
Reference in new issue
Block a user