fixed # 新增缩放倍率适配

This commit is contained in:
2026-11-24 14:10:04 +08:00
parent 98116bef7b
commit d61b4b2526
18 changed files with 499 additions and 83 deletions
+111 -8
View File
@@ -9,6 +9,7 @@ const { chromium } = require(packages ? path.join(packages, 'playwright') : 'pla
const prefix = '/extension/' + encodeURIComponent('术樱包') + '/mengsan';
const decadePrefix = '/extension/' + encodeURIComponent('十周年UI');
const reviewOnly = process.env.HUD_REVIEW === '1';
const journeyReview = process.env.UI_ZOOM_REVIEW === '1';
const holdStatus = async (page, locator, pointerType = 'mouse') => {
const box = await locator.boundingBox();
const point = {x:box.x + box.width / 2,y:box.y + box.height / 2};
@@ -46,6 +47,18 @@ async function checkMobileTargetLine(page, artifact) {
await touch.send('Input.dispatchTouchEvent', {type:'touchMove',touchPoints:[end]});
await aim.waitFor({state:'visible',timeout:2500});
}
// Exercise a WebView-style mismatch between the SVG matrix and its painted bounds.
await page.evaluate(() => {
const create = document.createElementNS.bind(document);
document.createElementNS = (namespace,tag) => {
const node = create(namespace,tag);
if (tag === 'svg') {
const screenMatrix = node.getScreenCTM.bind(node);
node.getScreenCTM = () => screenMatrix()?.translate(-120,45);
}
return node;
};
});
await drag();
const geometry = await aim.evaluate((overlay, pointer) => {
const card = window.card.getBoundingClientRect();
@@ -61,6 +74,7 @@ async function checkMobileTargetLine(page, artifact) {
return {origin,pointer,from:{x:left?bounds.left:bounds.right,y:up?bounds.top:bounds.bottom},
to:{x:left?bounds.right:bounds.left,y:up?bounds.bottom:bounds.top}};
},end);
await page.evaluate(() => { delete document.createElementNS; });
if (artifact) await page.screenshot({path:artifact});
await touch.send('Input.dispatchTouchEvent', {type:'touchCancel',touchPoints:[]});
assert.equal(await aim.count(),0,'the target line disappears on touch cancellation');
@@ -78,6 +92,46 @@ async function checkMobileTargetLine(page, artifact) {
assert.equal(await page.evaluate(()=>game.isSubmitted()),before+1,'touch release still submits the valid target once');
}
async function checkOrdinaryPlayCenter(page, skin, artifact) {
const geometry = await page.evaluate(async skin => {
const {arena,control,me} = ui;
const prompt = document.createElement('div');
prompt.className = skin === 'native' ? 'dialog' : 'hand-tip';
prompt.textContent = '请选择要使用的牌';
arena.append(prompt);
ui.dialog = prompt;
hudEventState.event.dialog = prompt;
hud.refresh();
await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));
const bounds = node => node.getBoundingClientRect().toJSON();
const result = {arena:bounds(arena),hand:bounds(me),card:bounds(card),prompt:bounds(prompt),
buttons:[...control.firstElementChild.children].map(bounds)};
if (!window.card.isConnected) throw new Error('The original hand card must remain connected');
return result;
},skin);
if (artifact) await page.screenshot({path:artifact});
await page.evaluate(()=>{ui.dialog.remove();delete ui.dialog;delete hudEventState.event.dialog;hud.refresh();});
const {arena,hand,card,prompt,buttons} = geometry;
const center = box => (box.left+box.right)/2;
const actions = {left:Math.min(...buttons.map(box=>box.left)),right:Math.max(...buttons.map(box=>box.right))};
assert.ok([hand,card,prompt,actions].every(box=>Math.abs(center(box)-center(arena))<=2),
'ordinary play fan, prompt and action buttons share the arena center: '+JSON.stringify(geometry));
}
async function setBattleZoom(page, zoom) {
await page.evaluate(zoom => {
const {style} = document.body;
style.zoom = zoom;
style.width = style.height = '100%';
},zoom);
// Let the native hand transform and the resize observers settle after a zoom change.
await page.waitForFunction(() => {
const arena = ui.arena.getBoundingClientRect(), hand = card.getBoundingClientRect();
return Math.abs(arena.width-innerWidth)<=2 &&
Math.abs((arena.left+arena.right-hand.left-hand.right)/2)<=2;
},null,{timeout:2500});
}
async function checkCommittedLine(page, skin) {
const geometry = await page.evaluate(async ({skin,decadePrefix}) => {
const engine = await import('/noname.js');
@@ -86,11 +140,12 @@ async function checkCommittedLine(page, skin) {
const [actor,target] = window.game.players;
// Use the shipped line producers and renderer, with only the game lifecycle isolated.
engine.lib.config ??= {};
engine.setUI({arena,create:{div:() => {
engine.setUI({arena,create:{div:selector => {
const node = document.createElement('div');
node.className = 'linexy hidden';
if (selector) node.className = 'linexy hidden';
node.show = () => node.classList.remove('hidden');
node.listenTransition = () => {};
node.setBackgroundImage = path => {node.style.backgroundImage = `url(${path})`;};
return node;
}},refresh:node=>node.getBoundingClientRect()});
const get = engine.get;
@@ -102,7 +157,7 @@ async function checkCommittedLine(page, skin) {
if (skin !== 'native') {
const {playerLine} = await import(decadePrefix+'/src/overrides/player/animations.js');
const {BoundsCache} = await import(decadePrefix+'/src/utils/bounds.js');
window.decadeUI = {boundsCaches:{hand:new BoundsCache(hand)}};
window.decadeUI ??= {boundsCaches:{hand:new BoundsCache(hand)}};
actor.checkBoundsCache = target.checkBoundsCache = function() {
this.cacheLeft = this.offsetLeft;
this.cacheTop = this.offsetTop;
@@ -124,11 +179,30 @@ async function checkCommittedLine(page, skin) {
const result = {x1,y1,x2:x1+matrix.c*length,y2:y1+matrix.d*length,expectedStart,
expectedEnd:{x:target.offsetLeft+target.offsetWidth/2,y:target.offsetTop+target.offsetHeight/2}};
effect.remove();
// Run the configured renderer as well as the default one. Its art may be provided by the Android package.
Object.assign(engine.game,{
linexy:engine.Game.prototype.zsJinlongLineXy,
zsPlayLineAnimationByName:engine.Game.prototype.zsPlayLineAnimationByName,
zsPlayLineAnimation:engine.Game.prototype.zsPlayLineAnimation,
jianqiLineAnim:new engine.Game().jianqiLineAnim,
});
line.call(actor,target,{duration:120});
const dragon = arena.lastElementChild;
const {left,top,width,transform,backgroundImage} = dragon.style;
const degrees = Number(transform.match(/rotate\(([-.\d]+)deg\)/)?.[1]);
const radians = degrees*Math.PI/180;
const distance = parseFloat(width)-2;
const start = {x:parseFloat(left),y:parseFloat(top)+10};
result.dragon = {start,end:{x:start.x+distance*Math.cos(radians),y:start.y+distance*Math.sin(radians)},backgroundImage};
return result;
},{skin,decadePrefix});
assert.ok(geometry && Math.hypot(geometry.x1-geometry.expectedStart.x,geometry.y1-geometry.expectedStart.y)<=2 &&
Math.hypot(geometry.x2-geometry.expectedEnd.x,geometry.y2-geometry.expectedEnd.y)<=2,
'A012 the committed card effect retains its native origin and reaches the target: '+JSON.stringify(geometry));
assert.ok(geometry.dragon.backgroundImage.includes('jinlonglinexy') &&
Math.hypot(geometry.dragon.start.x-geometry.expectedStart.x,geometry.dragon.start.y-geometry.expectedStart.y)<=2 &&
Math.hypot(geometry.dragon.end.x-geometry.expectedEnd.x,geometry.dragon.end.y-geometry.expectedEnd.y)<=2,
'the configured Jinlong effect retains its origin and reaches the target: '+JSON.stringify(geometry));
}
async function checkBattlePotionSlots(page, skin, artifact) {
@@ -333,15 +407,16 @@ async function checkMobileResponseLayout(page, skin, artifact) {
const restored = await page.evaluate(() => {
delete hudEventState.event.respondTo;
hud.refresh();
return ui.control.style.translate === '' && reviewResponse.card.style.translate === '';
const verticalShift = Number.parseFloat(ui.control.style.translate.split(/\s+/)[1]) || 0;
return verticalShift === 0 && reviewResponse.card.style.translate === '';
});
assert.ok(restored,'response spacing is released when the original event ends');
}
const fixture = `<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="/layout/default/layout.css"><div id="window"><div id="arena"><div id="mebg"></div><div id="me" class="mengsan-hand-root-shuying"><div id="handcards1" class="mengsan-hand-scroll-shuying"><div class="handcards mengsan-hand-zone-shuying mengsan-hand-layout-shuying"></div></div><div id="handcards2"><div class="handcards"></div></div></div><div id="control"><div class="control"><div>测试技能</div><div>结束出牌</div></div></div></div></div><style>html,body,#window{margin:0;width:100%;height:100%;position:absolute}#arena{inset:0;width:100%;height:100%;position:absolute}#arena>.player{position:absolute;width:100px;height:130px;background:#345;color:#fff}#arena>.player .avatar{height:100%;width:100%;background:linear-gradient(#334f4b,#172d29)}#arena>.player .name{position:absolute;top:4px;left:4px}#me{position:absolute;bottom:0;width:100%;height:160px}#handcards1,#handcards2{position:absolute;width:100%;height:100%}.handcards{height:100%}.card{background:#e8d7b2;color:#263b35;position:absolute}.mengsan-intent-shuying{position:absolute}</style>`;
const importMap = reviewOnly ? fs.readFileSync(path.join(app,'index.html'),'utf8').match(/<script type="importmap">.*?<\/script>/s)[0] : '';
const importMap = reviewOnly || journeyReview ? fs.readFileSync(path.join(app,'index.html'),'utf8').match(/<script type="importmap">.*?<\/script>/s)[0] : '';
const server = http.createServer((req, res) => {
if (req.url === '/fixture') { res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fixture.replace('<meta charset="utf-8">','<meta charset="utf-8">'+importMap));return; }
if(!reviewOnly && req.url==='/noname.js'){res.setHeader('Content-Type','text/javascript');res.end('export const _status={};');return;}
if(!reviewOnly && !journeyReview && req.url==='/noname.js'){res.setHeader('Content-Type','text/javascript');res.end('export const _status={};');return;}
if(decodeURIComponent(new URL(req.url,'http://localhost').pathname)==='/extension/术樱包/diagnostics/index.js') {
res.setHeader('Content-Type','text/javascript');res.end('export const getDiagnostics=()=>({status:()=>({enabled:false}),scope:()=>({info(){},error(){}})});');return;
}
@@ -359,12 +434,17 @@ const server = http.createServer((req, res) => {
const viewports = reviewOnly ? [{width:1080,height:486},{width:812,height:375},{width:667,height:375}]
: [{width:1280,height:720},{width:1234,height:920},{width:812,height:600},{width:812,height:375},{width:667,height:375},{width:375,height:500},{width:540,height:900}];
try {
if (journeyReview) {
await require('./test-journey-ui-zoom.cjs').testJourneyZoom(browser,origin,prefix);
return;
}
for (const skin of process.env.HUD_TEST_SKIN?[process.env.HUD_TEST_SKIN]:['native','shousha','shizhounian','xinsha']) {
for (const viewport of viewports) {
const page = await browser.newPage({viewport,hasTouch:true,deviceScaleFactor:reviewOnly?2.625:1});
await page.goto(origin+'/fixture');
if (reviewOnly && viewport.width===1080) {
await page.addStyleTag({content:'body{zoom:.64;width:156.25%;height:156.25%}'});
await page.addStyleTag({url:origin+'/layout/nova/layout.css'});
await page.addStyleTag({content:'body{zoom:.65;width:100%;height:100%}'});
}
await page.addStyleTag({content:'body{background:#161e29 url("/image/background/lanting_bg.jpg") center/cover no-repeat}'});
await page.addStyleTag({url:origin+prefix+'/ui/style.css'});
@@ -477,8 +557,22 @@ const server = http.createServer((req, res) => {
if (reviewOnly) {
const scenario = `${skin}-${viewport.width}x${viewport.height}`;
const artifact = name => process.env.HUD_ARTIFACTS && path.join(process.env.HUD_ARTIFACTS,`${name}-${scenario}.png`);
try { await checkMobileTargetLine(page,artifact('A012')); await checkCommittedLine(page,skin); checks+=7; }
try { await checkMobileTargetLine(page,artifact('A012')); await checkCommittedLine(page,skin); checks+=8; }
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
try { await checkOrdinaryPlayCenter(page,skin,artifact('ordinary-play-center')); checks++; }
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
if (viewport.width===1080) {
for (const zoom of [.5,.85,1,1.2]) {
try {
await setBattleZoom(page,zoom);
await checkOrdinaryPlayCenter(page,skin);
await checkMobileTargetLine(page);
await checkCommittedLine(page,skin);
checks+=9;
} catch (error) { reviewFailures.push(`${scenario} zoom ${zoom} ${error.message}`); }
}
await setBattleZoom(page,.65);
}
try { await checkBattlePotionSlots(page,skin,artifact('battle-potion-slots')); checks+=4; }
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
try { await checkMobileResponseLayout(page,skin,artifact('A013')); checks+=4; }
@@ -486,6 +580,15 @@ const server = http.createServer((req, res) => {
if (skin!=='native') {
try { await checkPotionSkillsDuringDiscard(page,skin,artifact('discard-skill-controls')); checks+=5; }
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
try {
assert.equal(await page.evaluate(()=>{
const bounds = window.decadeUI.boundsCaches.hand;
bounds.check();
hud.dispose();
return bounds.updated;
}),false,'the skin will read restored hand geometry after the HUD exits');
checks++;
} catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
}
if (!reviewFailures.some(failure => failure.startsWith(`${scenario} `))) console.log(`${scenario} battle UI review passed`);
await page.close();
+198
View File
@@ -0,0 +1,198 @@
const assert = require('node:assert/strict');
const path = require('node:path');
const surfaces = [
['选将', '.mengsan-character-overlay-shuying', '确认出征', 'mengsan_liubei_shuying'],
['地图', '.mengsan-map-overlay-shuying', /可前往$/, 'route'],
['事件选项', '.mengsan-flow-overlay-shuying', '继续', 'go'],
['商店', '.mengsan-shop-overlay-shuying', '离开商店', 'leave'],
['休息处', '.mengsan-rest-overlay-shuying', '离开休息处', 'done'],
['剧情', '.mengsan-dialogue-overlay-shuying', /跳过对话/, null],
['剧情分支', '.mengsan-dialogue-overlay-shuying', /剧情文本/, 'pledge'],
['奖励选牌', '.mengsan-card-choice-dialog-shuying', '跳过', null],
['战后选择', '.mengsan-victory-dialog-shuying', /领取战利品/, 'claim'],
['牌库', '.mengsan-deck-dialog-shuying', '关闭', null],
['牌堆', '.mengsan-deck-dialog-shuying', '关闭', null],
['遗物', '.mengsan-relic-dialog-shuying', '关闭', null],
['药水详情', '.mengsan-potion-dialog', '关闭', null],
['菜单确认', '.mengsan-menu-dialog-shuying', '保留', 'keep'],
['调试管理器', '.mengsan-gm-dialog-shuying', '关闭', null],
['战斗状态', '.mengsan-hud-dialog-shuying', '关闭', null],
];
async function mountSurface(page, origin, prefix, settings, surface) {
await page.goto(origin+'/fixture');
await page.addStyleTag({content:'#window,#arena{transition:none}'});
for (const file of ['style','shop','rest','potions','character-select']) {
await page.addStyleTag({url:origin+prefix+`/ui/${file}.css`});
}
await page.evaluate(async ({prefix,settings,surface}) => {
const engine = await import('/noname.js');
const imported = await import(prefix+'/progression/state.js');
const updateZoom = settings.transform ? engine.UI.prototype.updatez.bind(engine.ui) :
(await import('/extension/'+encodeURIComponent('十周年UI')+'/src/overrides/ui/update.js')).uiUpdatez;
window.zoomReviewSetScale = zoom => {
engine.game.documentZoom = zoom;
updateZoom();
};
window.zoomReviewSetScale(settings.zoom);
const ui = {window:document.getElementById('window'),arena:document.getElementById('arena'),create:{}};
ui.create.div = (selector,...args) => {
const element = document.createElement('div');
element.className = selector.split('.').filter(Boolean).join(' ');
element.setBackground = (name,type) => {element.style.backgroundImage=`url(/image/${type}/${name}.jpg)`;};
for (const arg of args) {
if (arg instanceof Node) arg.append(element);
else if (typeof arg === 'string') element.textContent = arg;
}
return element;
};
engine.lib.config ??= {};
engine.lib.assetURL = '/';
engine.lib.card.sha ??= {type:'basic'};
engine.lib.translate.sha = '杀';
engine.lib.translate.sha_info = '对一名其他角色造成伤害。';
engine.lib.translate.mengsan_liubei_shuying = '刘备';
engine.setUI(ui);
const run = imported.createRun('mengsan_liubei_shuying');
Object.assign(run.player,{gold:99,hp:25,maxHp:50,potions:['ENERGY_POTION']});
window.zoomReviewResult = null;
function settled(value) {window.zoomReviewResult = value;}
const modules = name => import(prefix+`/ui/${name}.js`);
const choices = [{id:'go',name:'继续'},{id:'leave',name:'离开'}];
if (surface==='选将') {
const {chooseCharacterCards} = await modules('character-select');
chooseCharacterCards([{id:run.player.character,name:'刘备',description:'出征武将'}],prefix,'返回').then(settled);
} else if (surface==='地图') {
const {showMap} = await modules('map/renderer');
showMap(run).then(()=>settled('route'));
} else if (surface==='事件选项') {
const {chooseButtons} = await modules('flow-ui');
chooseButtons('地图事件',choices,'选择一项继续前进').then(settled);
} else if (surface==='商店') {
const {chooseShop} = await modules('shop-ui');
chooseShop(run.player,[{id:'supply:heal',name:'补给',description:'获得补给',price:30}]).then(settled);
} else if (surface==='休息处') {
const {chooseRest} = await modules('rest-ui');
chooseRest([{id:'heal',name:'休息',description:'恢复生命'}],{tent:true}).then(settled);
} else if (surface==='剧情' || surface==='剧情分支') {
const {playDialogue} = await modules('dialogue');
const branch = surface==='剧情分支';
const lines = branch ? [{type:'choice',text:'如何回答?',speed:0,flag:'story.zoom',
choices:[{id:'pledge',text:'结伴前行'},{id:'leave',text:'独自出发'}]}] :
[{type:'narrator',text:'整备完毕,今日继续向前。',speed:0}];
playDialogue(lines,{run}).then(()=>settled(branch ? run.storyFlags['story.zoom'] : null));
} else if (surface==='奖励选牌') {
const {chooseCardDialog} = await modules('reward-ui');
chooseCardDialog([{id:'sha',card:{name:'sha'}}]).then(settled);
} else if (surface==='战后选择') {
const {chooseVictoryOptions} = await modules('reward-ui');
chooseVictoryOptions([{id:'claim',label:'领取战利品'}]).then(settled);
} else if (surface==='牌库') {
const {openCardLibrary} = await modules('card-library');
run.player.deck = Array.from({length:48},()=>({name:'sha',suit:'heart',number:5}));
openCardLibrary(run);
} else if (surface==='牌堆') {
const {mountBattlePiles} = await modules('card-library');
mountBattlePiles({active:true,ownResource(){}},{drawPile:run.player.deck,discardPile:[],exhaustPile:[]});
} else if (surface==='遗物') {
const {mountRelics} = await modules('relics');
mountRelics({active:true,ownResource(){}},run,{status(){},counter:()=>({value:null,label:null})},{stripRoot:ui.arena});
} else if (surface==='药水详情') {
const {mountPotionSlots} = await modules('potions');
const slots = mountPotionSlots(ui.arena,run.player,{use(){},canUse:()=>true});
slots.layoutBattleSlots(ui);
} else if (surface==='菜单确认') {
const {askMenu} = await modules('navigation');
askMenu('结束征程?','保留进度后可以继续。',[{id:'keep',name:'保留'}]).then(settled);
} else if (surface==='调试管理器') {
const {mountGMManager} = await modules('gm-manager');
const game = {};
mountGMManager({active:true,ownResource(){}},{getCards:()=>[]},{},{},
{field:(target,key,value)=>{target[key]=value;}},game);
game.mengsanGM_shuying();
} else if (surface==='战斗状态') {
const {mountBattleHUD} = await modules('hud/index');
ui.me = document.getElementById('me');
ui.control = document.getElementById('control');
const player = ui.create.div('.player',ui.arena);
Object.assign(player,{name:run.player.character,hp:25,maxHp:50,storage:{mengsanStrength_shuying:2},node:{}});
mountBattleHUD(player,{session:{active:true,ownResource(){}}},{ui,get:engine.get,_status:engine._status,document,window,assetBase:prefix});
}
},{prefix,settings,surface});
}
async function checkMapDrag(page) {
const viewport = page.locator('.mengsan-map-viewport-shuying');
const scroll = await viewport.evaluate(element => {
element.scrollTop = (element.scrollHeight-element.clientHeight)/2;
const box = element.getBoundingClientRect();
const y = Math.min(box.bottom-4,innerHeight-4);
return {top:element.scrollTop,scale:box.height/element.offsetHeight,x:box.left+box.width/2,y,
distance:Math.min(32,Math.floor((y-Math.max(0,box.top))/2))};
});
assert.ok(scroll.distance>=8,`the map still provides a draggable viewport: ${JSON.stringify(scroll)}`);
await page.mouse.move(scroll.x,scroll.y);
await page.mouse.down();
await page.mouse.move(scroll.x,scroll.y-scroll.distance,{steps:4});
await page.mouse.up();
const moved = await viewport.evaluate(element=>element.scrollTop)-scroll.top;
assert.ok(Math.abs(moved*scroll.scale-scroll.distance)<=2,`map drag follows the pointer: ${JSON.stringify({...scroll,moved})}`);
}
async function checkSurface(page, surface, settings, origin, prefix) {
const [name,selector,buttonName,result] = surface;
await mountSurface(page,origin,prefix,settings,name);
const launcher = {'牌堆':'.mengsan-battle-piles-button-shuying','遗物':'.mengsan-battle-relics-button-shuying',
'药水详情':'button.mengsan-potion-slot','战斗状态':'.mengsan-hud-status-shuying'}[name];
if (launcher) await page.locator(launcher).first().tap({timeout:1800});
const root = page.locator(selector);
await root.waitFor({state:'visible',timeout:1800});
if (settings.switchTo) {
await page.evaluate(zoom => window.zoomReviewSetScale(zoom), settings.switchTo);
}
const box = await root.boundingBox();
const viewport = page.viewportSize();
assert.ok(box.x>=-2 && box.y>=-2 && box.x+box.width<=viewport.width+2 && box.y+box.height<=viewport.height+2,
`surface within viewport: ${JSON.stringify({box,viewport})}`);
if (name==='地图') {
await checkMapDrag(page);
await root.getByRole('button',{name:'菜单',exact:true}).tap({timeout:1800});
const drawer = root.locator('.mengsan-map-menu-sheet-shuying');
await drawer.getByRole('button',{name:/行囊/}).tap({timeout:1800});
await drawer.getByRole('button',{name:'返回菜单',exact:true}).tap({timeout:1800});
await drawer.getByRole('button',{name:'关闭菜单',exact:true}).tap({timeout:1800});
}
if (process.env.HUD_ARTIFACTS && settings.zoom===1.5 && !settings.transform && !settings.viewport) {
await page.screenshot({path:path.join(process.env.HUD_ARTIFACTS,`zoom-${name}.png`)});
}
if (name==='剧情分支') await root.getByRole('button',{name:'结伴前行',exact:true}).tap({timeout:1800});
const action = root.getByRole('button',{name:buttonName}).first();
if(name==='牌库') {
const card = root.locator('.ms-deck-card').first();
await card.tap({timeout:1800});
assert.ok(await root.locator('.ms-deck-detail').isVisible(),'a card opens its details');
}
await action.tap({timeout:1800});
assert.equal(await root.count(),0,'the original action closes the surface');
if (result!==null) assert.equal(await page.evaluate(()=>zoomReviewResult),result,'the original action returns the choice');
}
exports.testJourneyZoom = async function testJourneyZoom(browser,origin,prefix) {
const failures = [];
let checks = 0;
const scenarios = [{zoom:.5},{zoom:.65},{zoom:1},{zoom:1.5},{zoom:2},{zoom:3},{zoom:1.5,transform:true},
{zoom:1.5,viewport:{width:420,height:360}}, {zoom:.65,transform:true,viewport:{width:390,height:720}},
{zoom:1,transform:true,viewport:{width:1280,height:720}}, {zoom:3,transform:true},
{zoom:.65,switchTo:2}, {zoom:.65,switchTo:2,transform:true}];
for (const settings of scenarios) {
const page = await browser.newPage({viewport:settings.viewport??{width:812,height:375},hasTouch:true});
for (const surface of surfaces) {
try { await checkSurface(page,surface,settings,origin,prefix); checks++; }
catch (error) { failures.push(`${surface[0]} ${JSON.stringify(settings)} ${error.message}`); }
}
await page.close();
}
if (failures.length) throw new Error(`${checks} passed\n${failures.join('\n')}`);
console.log(`Journey UI zoom: ${checks} passed`);
};