feat: sync Shanhe 2.2 source and add remote package verification
Shanhe source and offline package checks / verify (pull_request) Failing after 5s
Shanhe source and offline package checks / verify (pull_request) Failing after 5s
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import {chooseProvince,setDifficulty} from './helpers.mjs';
|
||||
import {chromium} from 'playwright';import assert from 'node:assert/strict';import fs from 'node:fs';
|
||||
const browser=await chromium.launch({executablePath:'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',headless:true});const context=await browser.newContext({viewport:{width:390,height:844},isMobile:true,hasTouch:true,deviceScaleFactor:2});const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto('http://localhost:4173');const state=()=>page.evaluate(()=>shanheDebug.state());assert.equal((await state()).bounce,1);assert.equal(await page.locator('[data-bounce="1"]').getAttribute('aria-pressed'),'true');
|
||||
let tabs=await page.locator('.mode-tabs').boundingBox();await page.mouse.move(tabs.x+tabs.width-25,tabs.y+tabs.height/2);await page.mouse.down();await page.mouse.move(tabs.x+25,tabs.y+tabs.height/2,{steps:10});await page.mouse.up();assert.equal((await state()).level,'330000');assert.equal(await page.locator('[data-mode="city"]').getAttribute('aria-pressed'),'true');await page.waitForTimeout(400);const cityTrack=await page.locator('.mode-tabs').evaluate(e=>getComputedStyle(e,'::before').transform);assert.ok(!cityTrack.endsWith(', 0, 0)'),'滑块到达地级位置');
|
||||
tabs=await page.locator('.mode-tabs').boundingBox();await page.mouse.move(tabs.x+25,tabs.y+tabs.height/2);await page.mouse.down();await page.mouse.move(tabs.x+tabs.width-25,tabs.y+tabs.height/2,{steps:10});await page.mouse.up();assert.equal((await state()).level,'100000');await page.waitForTimeout(400);await page.locator('[data-mode="city"]').tap();assert.equal((await state()).level,'330000');await page.locator('#province-picker').tap();assert.ok((await page.locator('#province-picker').getAttribute('class')).includes('expanded'));await page.locator('[data-province="440000"]').tap();assert.equal((await state()).level,'440000');
|
||||
await page.locator('[data-bounce="2"]').tap();assert.equal((await state()).bounce,2);assert.ok((await page.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));await page.waitForTimeout(600);assert.ok(!(await page.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));assert.ok(await page.evaluate(()=>document.documentElement.scrollHeight<=innerHeight+1));await page.screenshot({path:'artifacts/animated-entry.png'});
|
||||
await page.locator('[data-mode="province"]').tap();await page.locator('[data-speed="3"]').tap();await page.clock.install();await page.locator('#start').tap();await page.clock.runFor(7800);await page.keyboard.press('ArrowUp');await page.clock.runFor(320);const strong=await state();assert.equal(strong.bounce,2);assert.ok(strong.shakeCount>0);await page.screenshot({path:'artifacts/strong-bounce.png'});
|
||||
const browser=await chromium.launch({executablePath:'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',headless:true});const context=await browser.newContext({viewport:{width:390,height:844},isMobile:true,hasTouch:true,deviceScaleFactor:2});const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto('http://localhost:4173');const state=()=>page.evaluate(()=>shanheDebug.state());assert.equal((await state()).bounce,1);
|
||||
await chooseProvince(page,'330000');assert.equal((await state()).level,'330000');await chooseProvince(page,'440000');assert.equal((await state()).level,'440000');await page.locator('#difficulty-settings').tap();assert.equal(await page.locator('[data-bounce="1"]').getAttribute('aria-pressed'),'true');await page.locator('[data-bounce="2"]').tap();assert.equal((await state()).bounce,2);assert.ok((await page.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));await page.waitForTimeout(600);assert.ok(!(await page.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));await page.getByRole('button',{name:'完成设置',exact:true}).tap();assert.ok(await page.evaluate(()=>document.documentElement.scrollHeight<=innerHeight+1));await page.screenshot({path:'artifacts/animated-entry.png'});
|
||||
await chooseProvince(page,null);await setDifficulty(page,{speed:3});await page.clock.install();await page.locator('#start').tap();await page.clock.runFor(7800);await page.keyboard.press('ArrowUp');await page.clock.runFor(320);const strong=await state();assert.equal(strong.bounce,2);assert.ok(strong.shakeCount>0);await page.screenshot({path:'artifacts/strong-bounce.png'});
|
||||
let seenContact=false;for(let i=0;i<70;i++){await page.clock.runFor(32);const s=await state();if(s.contactPulse>0){seenContact=true;await page.screenshot({path:'artifacts/contact-feedback.png'});break;}}assert.ok(seenContact,'真实碰撞触发短促反馈');
|
||||
const reduced=await browser.newContext({viewport:{width:320,height:568},reducedMotion:'reduce'});const rp=await reduced.newPage();rp.on('pageerror',e=>errors.push(e.message));await rp.goto('http://localhost:4173');await rp.locator('[data-bounce="2"]').click();assert.ok(!(await rp.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));assert.equal(await rp.locator('.mode-tabs').evaluate(e=>getComputedStyle(e,'::before').transitionDuration),'0s');assert.equal(await rp.locator('[data-bounce="2"]').evaluate(e=>getComputedStyle(e).animationName),'none');await rp.locator('#start').click();await rp.keyboard.press('ArrowUp');assert.equal((await rp.evaluate(()=>shanheDebug.state())).shakeCount,1);assert.deepEqual(errors,[]);
|
||||
fs.writeFileSync('artifacts/interactions-report.json',JSON.stringify({passed:true,results:['默认推荐蹦蹦跳','模式左右滑动和点击均更新真实关卡,滑块到位','省区选择与弹性按钮回弹不破坏点击','三向晃动和真实碰撞短反馈','减少动态效果设置禁用装饰动画,游戏仍可操作'],errors},null,2));console.log('滑动选择、回弹点击、强弹试玩、真实碰撞反馈与减少动态效果通过');await browser.close();
|
||||
const reduced=await browser.newContext({viewport:{width:320,height:568},reducedMotion:'reduce'});const rp=await reduced.newPage();rp.on('pageerror',e=>errors.push(e.message));await rp.goto('http://localhost:4173');await rp.locator('#difficulty-settings').click();await rp.locator('[data-bounce="2"]').click();assert.ok(!(await rp.locator('[data-bounce="2"]').getAttribute('class')).includes('bounce-pop'));assert.equal(await rp.locator('[data-bounce="2"]').evaluate(e=>getComputedStyle(e).animationName),'none');await rp.getByRole('button',{name:'完成设置',exact:true}).click();assert.equal(await rp.locator('#reference').evaluate(e=>getComputedStyle(e).animationName),'none');await rp.locator('#start').click();await rp.keyboard.press('ArrowUp');assert.equal((await rp.evaluate(()=>shanheDebug.state())).shakeCount,1);assert.deepEqual(errors,[]);
|
||||
fs.writeFileSync('artifacts/interactions-report.json',JSON.stringify({passed:true,results:['地图点击选省和返回全国','默认推荐蹦蹦跳','设置弹窗按钮回弹且选择更新真实难度','强弹真实试玩和碰撞短反馈','减少动态效果设置禁用装饰动画,游戏仍可操作'],errors},null,2));console.log('地图选择、设置弹窗回弹、强弹试玩、碰撞反馈与减少动态效果通过');await browser.close();
|
||||
|
||||
Reference in New Issue
Block a user