test: landing column, around-field path, wide pad and grey hits (t1126–t1130)
@@ -268,6 +268,24 @@ if ($found) {
268
268
expect($found['miss'] === false, 'forced hit is not a miss');
269
269
expect($found['age'] >= 0 && $found['age'] < 2.0, 'age is seconds since created');
270
270
expect(almostEqual((float) $found['flight_duration'], METEORS_FLIGHT_DURATION), 'flight_duration on shot_flights');
271
expect(isset($found['land_col']) && $found['land_col'] >= 0 && $found['land_col'] <= 9, 'shot_flights has land_col 0–9');
272
expect(($shots[0]['land_col'] ?? null) === $found['land_col'], 'recordShots and shot_flights share land_col');
273
}
274
// Incoming carries the same land_col (t1126).
275
$targetId = $found['target_id'] ?? $shots[0]['target_id'];
276
$pdoLand = new PDO('sqlite:' . $tmp . '/meteors.sqlite');
277
$pdoLand->exec('UPDATE shots SET deliver_at = 0 WHERE client_id = "f1"');
278
$incLand = $store->viewFor($targetId);
279
$incHit = null;
280
foreach ($incLand['incoming'] as $row) {
281
if (($row['client_id'] ?? '') === 'f1') {
282
$incHit = $row;
283
break;
284
}
285
}
286
expect($incHit !== null, 'target receives incoming for the shot');
287
if ($incHit) {
288
expect(($incHit['land_col'] ?? null) === $found['land_col'], 'incoming.land_col matches the flight');
271
289
}
272
290
$view1 = $store->viewFor('local:test_user_1');
273
291
expect(count($view1['shot_flights']) >= 1, 'shooter also sees shot_flights (client de-dupes)');
@@ -268,6 +268,24 @@ if ($found) {268
expect($found['miss'] === false, 'forced hit is not a miss');268
expect($found['miss'] === false, 'forced hit is not a miss');269
expect($found['age'] >= 0 && $found['age'] < 2.0, 'age is seconds since created');269
expect($found['age'] >= 0 && $found['age'] < 2.0, 'age is seconds since created');270
expect(almostEqual((float) $found['flight_duration'], METEORS_FLIGHT_DURATION), 'flight_duration on shot_flights');270
expect(almostEqual((float) $found['flight_duration'], METEORS_FLIGHT_DURATION), 'flight_duration on shot_flights');271
expect(isset($found['land_col']) && $found['land_col'] >= 0 && $found['land_col'] <= 9, 'shot_flights has land_col 0–9');272
expect(($shots[0]['land_col'] ?? null) === $found['land_col'], 'recordShots and shot_flights share land_col');273
}274
// Incoming carries the same land_col (t1126).275
$targetId = $found['target_id'] ?? $shots[0]['target_id'];276
$pdoLand = new PDO('sqlite:' . $tmp . '/meteors.sqlite');277
$pdoLand->exec('UPDATE shots SET deliver_at = 0 WHERE client_id = "f1"');278
$incLand = $store->viewFor($targetId);279
$incHit = null;280
foreach ($incLand['incoming'] as $row) {281
if (($row['client_id'] ?? '') === 'f1') {282
$incHit = $row;283
break;284
}285
}286
expect($incHit !== null, 'target receives incoming for the shot');287
if ($incHit) {288
expect(($incHit['land_col'] ?? null) === $found['land_col'], 'incoming.land_col matches the flight');271
}289
}272
$view1 = $store->viewFor('local:test_user_1');290
$view1 = $store->viewFor('local:test_user_1');273
expect(count($view1['shot_flights']) >= 1, 'shooter also sees shot_flights (client de-dupes)');291
expect(count($view1['shot_flights']) >= 1, 'shooter also sees shot_flights (client de-dupes)');@@ -0,0 +1,146 @@
1
'use strict';
2
3
const { describe, it } = require('node:test');
4
const assert = require('node:assert/strict');
5
const { makeGame, GameCore, Planet, Rng } = require('./helpers.js');
6
const Offline = require('../src/offline.js');
7
const Online = require('../src/online.js');
8
const MiniLayout = require('../src/miniLayout.js');
9
10
describe('Garbage landing column (t1126)', () =>
11
{
12
it('pickGarbageColumn keeps a preferred open column', () =>
13
{
14
const g = makeGame({ noSpawn: true, seed: 3 });
15
assert.equal(g.pickGarbageColumn(4), 4);
16
assert.equal(g.ingestGarbage(4).col, 4);
17
});
18
19
it('pickGarbageColumn skips a full preferred column and still returns an open one', () =>
20
{
21
const g = makeGame({ noSpawn: true, seed: 3 });
22
for (let r = 0; r < 13; r++)
23
{ g.place(4, r, r % 5); }
24
const col = g.pickGarbageColumn(4);
25
assert.notEqual(col, 4);
26
assert.ok(col >= 0 && col < 10);
27
const block = g.ingestGarbage(4);
28
assert.notEqual(block.col, 4, 'ingest also skips the full preferred column');
29
assert.ok(block.col >= 0 && block.col < 10);
30
});
31
32
it('offline dispatch picks land_col and ingest uses the same column', () =>
33
{
34
const easy = Planet.createPlanet({ jumpsToClear: 1, fallTime: 5, riseTime: 3, id: 'easy' });
35
const hitRng = () => 0.99;
36
const battle = Offline.createBattle({ playerPlanet: easy, rng: hitRng, round: 1 });
37
const player = makeGame({ noSpawn: true });
38
// Bot shoots at the player: from_id is the bot.
39
const bot = battle.bots[0];
40
bot.core.outgoingShots.push({ id: 11, color: 2, col: 3, y: 13 });
41
battle.tick(0.01, player);
42
const flight = battle.flightResults.find((f) => f.from_id === bot.id && !f.miss);
43
assert.ok(flight, 'bot hit the player');
44
assert.equal(typeof flight.land_col, 'number');
45
assert.ok(flight.land_col >= 0 && flight.land_col < 10);
46
assert.equal(battle.pending[0].landCol, flight.land_col);
47
const before = player.blocks.length;
48
battle.tick(Offline.FLIGHT_DURATION + 0.05, player);
49
assert.equal(battle.pending.length, 0);
50
const greys = player.blocks.filter((b) => b.color === GameCore.COLOR_GRAY);
51
assert.ok(greys.length >= 1, 'player received grey garbage');
52
assert.equal(greys[greys.length - 1].col, flight.land_col,
53
'ingested column matches the flight land_col');
54
assert.ok(player.blocks.length > before);
55
});
56
});
57
58
describe('Around-field flight path (t1128)', () =>
59
{
60
const field = { left: 335, top: 173, right: 335 + 550, bottom: 173 + 715 };
61
62
it('routes a left-mini shot around the field into a given column', () =>
63
{
64
const start = { x: 250, y: 700 };
65
const end = {
66
x: field.left + (3 + 0.5) / 10 * (field.right - field.left),
67
y: field.top + 4
68
};
69
const pts = Online.waypointsAroundField(start, end, field, 72);
70
assert.ok(pts.length >= 2);
71
for (let i = 0; i <= 20; i++)
72
{
73
const u = i / 20;
74
const p = Online.aroundFieldPoint(start, end, u, field, 72);
75
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false,
76
'u=' + u + ' is inside the field at ' + p.x + ',' + p.y);
77
}
78
const landed = Online.aroundFieldPoint(start, end, 1, field, 72);
79
assert.ok(Math.abs(landed.x - end.x) < 0.5, 'ends at the landing column x');
80
assert.ok(Math.abs(landed.y - end.y) < 1, 'ends at the field top');
81
});
82
83
it('routes a player shot around the field to a right-hand mini', () =>
84
{
85
const start = {
86
x: field.left + (6 + 0.5) / 10 * (field.right - field.left),
87
y: field.top + 4
88
};
89
const end = { x: field.right + 80, y: 700 };
90
for (let i = 0; i <= 20; i++)
91
{
92
const p = Online.aroundFieldPoint(start, end, i / 20, field, 72);
93
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false,
94
'player→enemy u=' + (i / 20) + ' crosses the field');
95
}
96
});
97
98
it('a path already above the field stays as a simple arc above it', () =>
99
{
100
const start = { x: 400, y: 80 };
101
const end = { x: 600, y: field.top + 4 };
102
const pts = Online.waypointsAroundField(start, end, field, 72);
103
assert.equal(pts.length, 2, 'no extra waypoints when both ends are above');
104
for (let i = 0; i <= 16; i++)
105
{
106
const p = Online.aroundFieldPoint(start, end, i / 16, field, 72);
107
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false);
108
assert.ok(p.y <= field.top + 6, 'stays at or above the top edge, y=' + p.y);
109
}
110
});
111
});
112
113
describe('Wide-layout top padding (t1129)', () =>
114
{
115
it('leaves room above the field on a wide screen, not on narrow or mobile', () =>
116
{
117
const wide = MiniLayout.plan(1280, 900, 2, 70, 8);
118
assert.equal(wide.mode, 'sides');
119
assert.ok(wide.fieldY >= 70 + MiniLayout.ARC_TOP_PAD - 1,
120
'fieldY=' + wide.fieldY + ' should be at least hud+pad=' + (70 + MiniLayout.ARC_TOP_PAD));
121
assert.ok(wide.fieldY - 70 >= MiniLayout.ARC_TOP_PAD * 0.9);
122
123
const narrow = MiniLayout.plan(720, 800, 2, 70, 8);
124
assert.equal(narrow.mode, 'top');
125
// Unchanged: top band is hud + miniH, no arc pad.
126
assert.ok(narrow.miniH > 0);
127
assert.ok(narrow.fieldY >= 70 + narrow.miniH - 1);
128
129
const mobile = MiniLayout.plan(393, 851, 1, 60, 6);
130
assert.equal(mobile.mode, 'top');
131
});
132
});
133
134
describe('takeLandCol consistency (t1126)', () =>
135
{
136
it('prefers the server land_col and falls back to a remembered id', () =>
137
{
138
Online._pendingLandCol = Object.create(null);
139
assert.equal(Online.takeLandCol({ id: 9, land_col: 6 }), 6);
140
Online.rememberLandCol('abc', 2);
141
assert.equal(Online.takeLandCol({ client_id: 'abc' }), 2);
142
// Server value wins over the remembered one.
143
assert.equal(Online.takeLandCol({ client_id: 'abc', land_col: 8 }), 8);
144
assert.equal(Online.takeLandCol({ id: 1 }), null);
145
});
146
});
@@ -0,0 +1,146 @@1
'use strict';2
3
const { describe, it } = require('node:test');4
const assert = require('node:assert/strict');5
const { makeGame, GameCore, Planet, Rng } = require('./helpers.js');6
const Offline = require('../src/offline.js');7
const Online = require('../src/online.js');8
const MiniLayout = require('../src/miniLayout.js');9
10
describe('Garbage landing column (t1126)', () =>11
{12
it('pickGarbageColumn keeps a preferred open column', () =>13
{14
const g = makeGame({ noSpawn: true, seed: 3 });15
assert.equal(g.pickGarbageColumn(4), 4);16
assert.equal(g.ingestGarbage(4).col, 4);17
});18
19
it('pickGarbageColumn skips a full preferred column and still returns an open one', () =>20
{21
const g = makeGame({ noSpawn: true, seed: 3 });22
for (let r = 0; r < 13; r++)23
{ g.place(4, r, r % 5); }24
const col = g.pickGarbageColumn(4);25
assert.notEqual(col, 4);26
assert.ok(col >= 0 && col < 10);27
const block = g.ingestGarbage(4);28
assert.notEqual(block.col, 4, 'ingest also skips the full preferred column');29
assert.ok(block.col >= 0 && block.col < 10);30
});31
32
it('offline dispatch picks land_col and ingest uses the same column', () =>33
{34
const easy = Planet.createPlanet({ jumpsToClear: 1, fallTime: 5, riseTime: 3, id: 'easy' });35
const hitRng = () => 0.99;36
const battle = Offline.createBattle({ playerPlanet: easy, rng: hitRng, round: 1 });37
const player = makeGame({ noSpawn: true });38
// Bot shoots at the player: from_id is the bot.39
const bot = battle.bots[0];40
bot.core.outgoingShots.push({ id: 11, color: 2, col: 3, y: 13 });41
battle.tick(0.01, player);42
const flight = battle.flightResults.find((f) => f.from_id === bot.id && !f.miss);43
assert.ok(flight, 'bot hit the player');44
assert.equal(typeof flight.land_col, 'number');45
assert.ok(flight.land_col >= 0 && flight.land_col < 10);46
assert.equal(battle.pending[0].landCol, flight.land_col);47
const before = player.blocks.length;48
battle.tick(Offline.FLIGHT_DURATION + 0.05, player);49
assert.equal(battle.pending.length, 0);50
const greys = player.blocks.filter((b) => b.color === GameCore.COLOR_GRAY);51
assert.ok(greys.length >= 1, 'player received grey garbage');52
assert.equal(greys[greys.length - 1].col, flight.land_col,53
'ingested column matches the flight land_col');54
assert.ok(player.blocks.length > before);55
});56
});57
58
describe('Around-field flight path (t1128)', () =>59
{60
const field = { left: 335, top: 173, right: 335 + 550, bottom: 173 + 715 };61
62
it('routes a left-mini shot around the field into a given column', () =>63
{64
const start = { x: 250, y: 700 };65
const end = {66
x: field.left + (3 + 0.5) / 10 * (field.right - field.left),67
y: field.top + 468
};69
const pts = Online.waypointsAroundField(start, end, field, 72);70
assert.ok(pts.length >= 2);71
for (let i = 0; i <= 20; i++)72
{73
const u = i / 20;74
const p = Online.aroundFieldPoint(start, end, u, field, 72);75
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false,76
'u=' + u + ' is inside the field at ' + p.x + ',' + p.y);77
}78
const landed = Online.aroundFieldPoint(start, end, 1, field, 72);79
assert.ok(Math.abs(landed.x - end.x) < 0.5, 'ends at the landing column x');80
assert.ok(Math.abs(landed.y - end.y) < 1, 'ends at the field top');81
});82
83
it('routes a player shot around the field to a right-hand mini', () =>84
{85
const start = {86
x: field.left + (6 + 0.5) / 10 * (field.right - field.left),87
y: field.top + 488
};89
const end = { x: field.right + 80, y: 700 };90
for (let i = 0; i <= 20; i++)91
{92
const p = Online.aroundFieldPoint(start, end, i / 20, field, 72);93
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false,94
'player→enemy u=' + (i / 20) + ' crosses the field');95
}96
});97
98
it('a path already above the field stays as a simple arc above it', () =>99
{100
const start = { x: 400, y: 80 };101
const end = { x: 600, y: field.top + 4 };102
const pts = Online.waypointsAroundField(start, end, field, 72);103
assert.equal(pts.length, 2, 'no extra waypoints when both ends are above');104
for (let i = 0; i <= 16; i++)105
{106
const p = Online.aroundFieldPoint(start, end, i / 16, field, 72);107
assert.equal(Online.pointInFieldInterior(p.x, p.y, field), false);108
assert.ok(p.y <= field.top + 6, 'stays at or above the top edge, y=' + p.y);109
}110
});111
});112
113
describe('Wide-layout top padding (t1129)', () =>114
{115
it('leaves room above the field on a wide screen, not on narrow or mobile', () =>116
{117
const wide = MiniLayout.plan(1280, 900, 2, 70, 8);118
assert.equal(wide.mode, 'sides');119
assert.ok(wide.fieldY >= 70 + MiniLayout.ARC_TOP_PAD - 1,120
'fieldY=' + wide.fieldY + ' should be at least hud+pad=' + (70 + MiniLayout.ARC_TOP_PAD));121
assert.ok(wide.fieldY - 70 >= MiniLayout.ARC_TOP_PAD * 0.9);122
123
const narrow = MiniLayout.plan(720, 800, 2, 70, 8);124
assert.equal(narrow.mode, 'top');125
// Unchanged: top band is hud + miniH, no arc pad.126
assert.ok(narrow.miniH > 0);127
assert.ok(narrow.fieldY >= 70 + narrow.miniH - 1);128
129
const mobile = MiniLayout.plan(393, 851, 1, 60, 6);130
assert.equal(mobile.mode, 'top');131
});132
});133
134
describe('takeLandCol consistency (t1126)', () =>135
{136
it('prefers the server land_col and falls back to a remembered id', () =>137
{138
Online._pendingLandCol = Object.create(null);139
assert.equal(Online.takeLandCol({ id: 9, land_col: 6 }), 6);140
Online.rememberLandCol('abc', 2);141
assert.equal(Online.takeLandCol({ client_id: 'abc' }), 2);142
// Server value wins over the remembered one.143
assert.equal(Online.takeLandCol({ client_id: 'abc', land_col: 8 }), 8);144
assert.equal(Online.takeLandCol({ id: 1 }), null);145
});146
});@@ -116,12 +116,13 @@ LAYOUT_INFO = """() => {
116
116
}"""
117
117
118
118
119
INJECT_FLIGHTS = """() => {
119
120
INJECT_FLIGHTS = """(age) => {
121
if (age == null) age = 0.55;
120
122
const plan = app.miniLayout;
121
123
const field = app.scene.canvas.getBoundingClientRect();
122
const minis = [...document.querySelectorAll('#minis .mini')];
123
124
function anchor(id, inner) {
124
const el = document.querySelector('#minis .mini[data-player=\"' + id + '\"] canvas');
125
const el = document.querySelector('#minis .mini[data-player="' + id + '"] canvas');
125
126
if (!el) return { x: 80, y: 80 };
126
127
const r = el.getBoundingClientRect();
127
128
if (plan && plan.mode === 'sides') {
@@ -135,47 +136,88 @@ INJECT_FLIGHTS = """() => {
135
136
const bots = (app.battle.bots || []).map(b => b.id);
136
137
const a = bots[0] || 'bot-1';
137
138
const b = bots[1] || bots[0] || 'bot-2';
139
const landCol = 3;
138
140
const pStart = {
139
x: field.left + field.width / 2,
141
x: field.left + ((4 + 0.5) / 10) * field.width,
140
142
y: field.top + 4
141
143
};
142
144
if (typeof Online.clearFlights === 'function') Online.clearFlights();
143
145
const flights = [
144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: 0.55 },
145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: 0.55 },
146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: 0.55 },
147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: 0.45 }
146
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol },
147
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol },
148
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7 },
149
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45) }
148
150
];
149
151
const aOut = anchor(a, true);
150
152
const bOut = anchor(b, true);
151
153
const locals = {
152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4 },
153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y },
154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y },
154
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, land_col: landCol },
155
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, land_col: landCol },
156
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, land_col: 7 },
155
157
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y }
156
158
};
157
159
Online.spawnFlights(flights, locals);
158
160
Online.tickFlights();
159
161
const front = [...document.querySelectorAll('#flights .flight')].map(el => ({
160
cls: el.className,
162
src: el.getAttribute('src') || el.src,
161
163
transform: el.style.transform,
162
opacity: el.style.opacity,
163
164
parent: 'front'
164
165
}));
165
166
const back = [...document.querySelectorAll('#flights-back .flight')].map(el => ({
166
cls: el.className,
167
src: el.getAttribute('src') || el.src,
167
168
transform: el.style.transform,
168
opacity: el.style.opacity,
169
169
parent: 'back'
170
170
}));
171
const kinds = (Online._flights || []).map(f => {
172
const raw = Math.min(0.999, Math.max(0, (performance.now() - f.t0) / f.duration));
173
const u = Online.easeInOutCubic(raw);
174
let pt;
175
if (f.waypoints && f.waypoints.length > 2)
176
{ pt = Online.pointOnPath(f.waypoints, u); }
177
else if (f.kind === 'enemy-to-player' || f.kind === 'player-to-enemy')
178
{ pt = Online.aroundFieldPoint(f.start, f.end, u, f.field, (f.height || 80) * 0.45); }
179
else
180
{ pt = Online.arcPoint(f.start, f.end, u, f.height || 80); }
181
const samples = [];
182
if (f.kind === 'enemy-to-player' || f.kind === 'player-to-enemy')
183
{
184
for (let i = 0; i <= 16; i++)
185
{
186
const su = i / 16;
187
let sp;
188
if (f.waypoints && f.waypoints.length > 2)
189
{ sp = Online.pointOnPath(f.waypoints, su); }
190
else
191
{ sp = Online.aroundFieldPoint(f.start, f.end, su, f.field, (f.height || 80) * 0.45); }
192
samples.push({
193
u: su, x: sp.x, y: sp.y,
194
inside: Online.pointInFieldInterior(sp.x, sp.y, f.field)
195
});
196
}
197
}
198
return {
199
kind: f.kind, miss: f.miss,
200
startScale: f.startScale, endScale: f.endScale,
201
parent: (f.el && f.el.parentElement && f.el.parentElement.id) || '',
202
src: (f.el && (f.el.getAttribute('src') || f.el.src)) || '',
203
color: f.color,
204
landCol: f.landCol,
205
end: f.end,
206
pos: pt,
207
samples: samples,
208
insideNow: f.field ? Online.pointInFieldInterior(pt.x, pt.y, f.field) : false
209
};
210
});
211
const expectedEndX = field.left + ((landCol + 0.5) / 10) * field.width;
171
212
return {
172
213
front: front.length,
173
214
back: back.length,
174
kinds: (Online._flights || []).map(f => ({
175
kind: f.kind, miss: f.miss,
176
startScale: f.startScale, endScale: f.endScale,
177
parent: (f.el && f.el.parentElement && f.el.parentElement.id) || ''
178
}))
215
kinds,
216
expectedEndX,
217
field: { left: field.left, right: field.right, top: field.top, bottom: field.bottom },
218
pad: field.top,
219
hudH: app.hudH,
220
mode: plan.mode
179
221
};
180
222
}"""
181
223
@@ -186,6 +228,12 @@ def assert_sides(info, tag, expect_rows=False):
186
228
field = info["field"]
187
229
minis = info["minis"]
188
230
check(len(minis) >= 1, f"{tag}: at least one mini ({len(minis)})")
231
if field:
232
# t1129: room above the field for around-the-top arcs
233
gap = field["top"] - 50 # HUD is ~56–80; require a clear pad
234
check(field["top"] >= (info.get("hud") or 70) + 80
235
or field["y"] >= 70 + 80,
236
f"{tag}: wide layout has top padding (field.top={field['top']:.1f}, y={field.get('y')})")
189
237
if not field or not minis:
190
238
return
191
239
for i, m in enumerate(minis):
@@ -202,7 +250,6 @@ def assert_sides(info, tag, expect_rows=False):
202
250
check(m["top"] >= 50,
203
251
f"{tag}: mini {i} stays under the HUD (top={m['top']:.1f})")
204
252
if expect_rows and len(minis) >= 3:
205
# 3rd (index 2) is left, stacked above the first
206
253
check(minis[2]["bottom"] <= minis[0]["top"] + 4,
207
254
f"{tag}: third mini is stacked above the first "
208
255
f"(b={minis[2]['bottom']:.1f} vs top={minis[0]['top']:.1f})")
@@ -222,7 +269,7 @@ def assert_top(info, tag):
222
269
f"(bottom={m['bottom']:.1f} field.top={field['top']:.1f})")
223
270
224
271
225
def assert_flights(info, tag, expect_behind=True):
272
def assert_flights(info, tag, expect_behind=True, expect_around=True):
226
273
check(info["front"] >= 3, f"{tag}: front flights present ({info['front']})")
227
274
kinds = {k["kind"]: k for k in info["kinds"]}
228
275
check("player-to-enemy" in kinds, f"{tag}: player-to-enemy")
@@ -232,10 +279,33 @@ def assert_flights(info, tag, expect_behind=True):
232
279
k = kinds["player-to-enemy"]
233
280
check(k["startScale"] > k["endScale"],
234
281
f"{tag}: player-to-enemy shrinks ({k['startScale']:.2f}→{k['endScale']:.2f})")
282
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,
283
f"{tag}: player-to-enemy is grey (src={k.get('src')} color={k.get('color')})")
235
284
if "enemy-to-player" in kinds:
236
285
k = kinds["enemy-to-player"]
237
286
check(k["endScale"] > k["startScale"],
238
287
f"{tag}: enemy-to-player grows ({k['startScale']:.2f}→{k['endScale']:.2f})")
288
check(k.get("landCol") == 3,
289
f"{tag}: enemy-to-player landCol is 3 (got {k.get('landCol')})")
290
if k.get("end") and info.get("expectedEndX"):
291
check(abs(k["end"]["x"] - info["expectedEndX"]) < 3,
292
f"{tag}: arc ends at column 3 "
293
f"(end.x={k['end']['x']:.1f} expected={info['expectedEndX']:.1f})")
294
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,
295
f"{tag}: enemy-to-player is grey (src={k.get('src')} color={k.get('color')})")
296
if expect_around and k.get("samples"):
297
inside = [s for s in k["samples"] if s.get("inside")]
298
check(len(inside) == 0,
299
f"{tag}: enemy-to-player path stays outside the field "
300
f"({len(inside)} interior samples {inside[:3]})")
301
check(not k.get("insideNow"),
302
f"{tag}: enemy-to-player mid-arc is not over the field interior")
303
if "player-to-enemy" in kinds and expect_around:
304
k = kinds["player-to-enemy"]
305
inside = [s for s in (k.get("samples") or []) if s.get("inside")]
306
check(len(inside) == 0,
307
f"{tag}: player-to-enemy path stays outside the field "
308
f"({len(inside)} interior samples {inside[:3]})")
239
309
if "enemy-to-enemy" in kinds:
240
310
k = kinds["enemy-to-enemy"]
241
311
check(abs(k["startScale"] - k["endScale"]) < 0.05,
@@ -244,12 +314,17 @@ def assert_flights(info, tag, expect_behind=True):
244
314
f"{tag}: enemy-to-enemy is in #flights-back (got {k['parent']})")
245
315
if expect_behind:
246
316
check(info["back"] >= 1, f"{tag}: at least one behind-field flight")
317
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,
318
f"{tag}: enemy-to-enemy is grey (src={k.get('src')} color={k.get('color')})")
247
319
if "enemy-miss" in kinds:
248
320
k = kinds["enemy-miss"]
249
321
check(k["startScale"] < 0.7,
250
322
f"{tag}: enemy-miss starts small ({k['startScale']:.2f})")
251
323
check(k["parent"] == "flights",
252
324
f"{tag}: enemy-miss is in #flights (got {k['parent']})")
325
# Misses keep the sender colour (not forced grey).
326
check(k.get("color") != -1,
327
f"{tag}: enemy-miss keeps the sender colour (color={k.get('color')})")
253
328
254
329
255
330
def run_viewport(browser, url, name, width, height, is_mobile, round_n, expect_mode):
@@ -263,17 +338,30 @@ def run_viewport(browser, url, name, width, height, is_mobile, round_n, expect_m
263
338
open_offline(page, url, round_n=round_n)
264
339
page.wait_for_timeout(300)
265
340
info = page.evaluate(LAYOUT_INFO)
266
print(f"--- {name} layout:", {k: info[k] for k in ('mode', 'n', 'tile', 'vw', 'vh', 'sidesClass')})
341
print(f"--- {name} layout:", {k: info[k] for k in ('mode', 'n', 'tile', 'vw', 'vh', 'sidesClass')},
342
"fieldY", info.get("field") and info["field"].get("y"),
343
"field.top", info.get("field") and info["field"].get("top"))
267
344
if expect_mode == "sides":
268
345
assert_sides(info, name, expect_rows=(round_n >= 12))
269
346
else:
270
347
assert_top(info, name)
271
shot(page, f"t1125-{name}-layout.png")
348
shot(page, f"t1126-{name}-layout.png")
272
349
273
flights = page.evaluate(INJECT_FLIGHTS)
274
print(f"--- {name} flights:", flights)
350
# Mid-arc (age 0.55 of 1.2 s) — main verification frame
351
flights = page.evaluate(INJECT_FLIGHTS, 0.55)
352
print(f"--- {name} flights:", {k: flights[k] for k in ('front', 'back', 'expectedEndX', 'hudH', 'mode') if k in flights})
353
for knd in flights["kinds"]:
354
print(f" {knd['kind']}: color={knd.get('color')} landCol={knd.get('landCol')} "
355
f"src={knd.get('src')} insideNow={knd.get('insideNow')} "
356
f"end={knd.get('end')} pos={knd.get('pos')}")
275
357
assert_flights(flights, name)
276
shot(page, f"t1125-{name}-flights.png")
358
shot(page, f"t1126-{name}-midarc.png")
359
360
# Extra mid-path frames on the wide 2-bot view so the around-route is visible
361
if name == "desktop-wide":
362
for age, label in ((0.25, "early"), (0.85, "late")):
363
page.evaluate(INJECT_FLIGHTS, age)
364
shot(page, f"t1126-{name}-midarc-{label}.png")
277
365
context.close()
278
366
279
367
@@ -288,13 +376,9 @@ def main():
288
376
args=CHROME_ARGS,
289
377
headless=True,
290
378
)
291
# Desktop wide: 2 opponents (round 2) alternating L/R
292
379
run_viewport(browser, url, "desktop-wide", 1280, 900, False, 2, "sides")
293
# Many opponents, stacked rows (round 25 → 8 bots)
294
380
run_viewport(browser, url, "desktop-wide-many", 1400, 900, False, 25, "sides")
295
# Desktop narrow: top layout
296
381
run_viewport(browser, url, "desktop-narrow", 720, 800, False, 2, "top")
297
# Mobile
298
382
run_viewport(browser, url, "mobile", 393, 851, True, 2, "top")
299
383
browser.close()
300
384
finally:
@@ -116,12 +116,13 @@ LAYOUT_INFO = """() => {116
}"""116
}"""117
117
118
118
119
INJECT_FLIGHTS = """() => {119
120
INJECT_FLIGHTS = """(age) => {121
if (age == null) age = 0.55;120
const plan = app.miniLayout;122
const plan = app.miniLayout;121
const field = app.scene.canvas.getBoundingClientRect();123
const field = app.scene.canvas.getBoundingClientRect();122
const minis = [...document.querySelectorAll('#minis .mini')];123
function anchor(id, inner) {124
function anchor(id, inner) {124
const el = document.querySelector('#minis .mini[data-player=\"' + id + '\"] canvas');125
const el = document.querySelector('#minis .mini[data-player="' + id + '"] canvas');125
if (!el) return { x: 80, y: 80 };126
if (!el) return { x: 80, y: 80 };126
const r = el.getBoundingClientRect();127
const r = el.getBoundingClientRect();127
if (plan && plan.mode === 'sides') {128
if (plan && plan.mode === 'sides') {@@ -135,47 +136,88 @@ INJECT_FLIGHTS = """() => {135
const bots = (app.battle.bots || []).map(b => b.id);136
const bots = (app.battle.bots || []).map(b => b.id);136
const a = bots[0] || 'bot-1';137
const a = bots[0] || 'bot-1';137
const b = bots[1] || bots[0] || 'bot-2';138
const b = bots[1] || bots[0] || 'bot-2';139
const landCol = 3;138
const pStart = {140
const pStart = {139
x: field.left + field.width / 2,141
x: field.left + ((4 + 0.5) / 10) * field.width,140
y: field.top + 4142
y: field.top + 4141
};143
};142
if (typeof Online.clearFlights === 'function') Online.clearFlights();144
if (typeof Online.clearFlights === 'function') Online.clearFlights();143
const flights = [145
const flights = [144
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: 0.55 },146
{ id: 'vis-p2e', client_id: 'vis-p2e', from_id: 'player', target_id: a, miss: false, color: 0, flight_duration: 1.2, age: age, land_col: landCol },145
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: 0.55 },147
{ id: 'vis-e2p', client_id: 'vis-e2p', from_id: a, target_id: 'player', miss: false, color: 1, flight_duration: 1.2, age: age, land_col: landCol },146
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: 0.55 },148
{ id: 'vis-e2e', client_id: 'vis-e2e', from_id: a, target_id: b, miss: false, color: 2, flight_duration: 1.2, age: age, land_col: 7 },147
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: 0.45 }149
{ id: 'vis-emiss', client_id: 'vis-emiss', from_id: b, target_id: null, miss: true, color: 3, flight_duration: 1.2, age: Math.min(age, 0.45) }148
];150
];149
const aOut = anchor(a, true);151
const aOut = anchor(a, true);150
const bOut = anchor(b, true);152
const bOut = anchor(b, true);151
const locals = {153
const locals = {152
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4 },154
'vis-p2e': { from_id: 'player', color: 0, startX: pStart.x, startY: pStart.y, col: 4, land_col: landCol },153
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y },155
'vis-e2p': { from_id: a, color: 1, startX: aOut.x, startY: aOut.y, land_col: landCol },154
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y },156
'vis-e2e': { from_id: a, color: 2, startX: aOut.x, startY: aOut.y, land_col: 7 },155
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y }157
'vis-emiss': { from_id: b, color: 3, startX: bOut.x, startY: bOut.y }156
};158
};157
Online.spawnFlights(flights, locals);159
Online.spawnFlights(flights, locals);158
Online.tickFlights();160
Online.tickFlights();159
const front = [...document.querySelectorAll('#flights .flight')].map(el => ({161
const front = [...document.querySelectorAll('#flights .flight')].map(el => ({160
cls: el.className,162
src: el.getAttribute('src') || el.src,161
transform: el.style.transform,163
transform: el.style.transform,162
opacity: el.style.opacity,163
parent: 'front'164
parent: 'front'164
}));165
}));165
const back = [...document.querySelectorAll('#flights-back .flight')].map(el => ({166
const back = [...document.querySelectorAll('#flights-back .flight')].map(el => ({166
cls: el.className,167
src: el.getAttribute('src') || el.src,167
transform: el.style.transform,168
transform: el.style.transform,168
opacity: el.style.opacity,169
parent: 'back'169
parent: 'back'170
}));170
}));171
const kinds = (Online._flights || []).map(f => {172
const raw = Math.min(0.999, Math.max(0, (performance.now() - f.t0) / f.duration));173
const u = Online.easeInOutCubic(raw);174
let pt;175
if (f.waypoints && f.waypoints.length > 2)176
{ pt = Online.pointOnPath(f.waypoints, u); }177
else if (f.kind === 'enemy-to-player' || f.kind === 'player-to-enemy')178
{ pt = Online.aroundFieldPoint(f.start, f.end, u, f.field, (f.height || 80) * 0.45); }179
else180
{ pt = Online.arcPoint(f.start, f.end, u, f.height || 80); }181
const samples = [];182
if (f.kind === 'enemy-to-player' || f.kind === 'player-to-enemy')183
{184
for (let i = 0; i <= 16; i++)185
{186
const su = i / 16;187
let sp;188
if (f.waypoints && f.waypoints.length > 2)189
{ sp = Online.pointOnPath(f.waypoints, su); }190
else191
{ sp = Online.aroundFieldPoint(f.start, f.end, su, f.field, (f.height || 80) * 0.45); }192
samples.push({193
u: su, x: sp.x, y: sp.y,194
inside: Online.pointInFieldInterior(sp.x, sp.y, f.field)195
});196
}197
}198
return {199
kind: f.kind, miss: f.miss,200
startScale: f.startScale, endScale: f.endScale,201
parent: (f.el && f.el.parentElement && f.el.parentElement.id) || '',202
src: (f.el && (f.el.getAttribute('src') || f.el.src)) || '',203
color: f.color,204
landCol: f.landCol,205
end: f.end,206
pos: pt,207
samples: samples,208
insideNow: f.field ? Online.pointInFieldInterior(pt.x, pt.y, f.field) : false209
};210
});211
const expectedEndX = field.left + ((landCol + 0.5) / 10) * field.width;171
return {212
return {172
front: front.length,213
front: front.length,173
back: back.length,214
back: back.length,174
kinds: (Online._flights || []).map(f => ({215
kinds,175
kind: f.kind, miss: f.miss,216
expectedEndX,176
startScale: f.startScale, endScale: f.endScale,217
field: { left: field.left, right: field.right, top: field.top, bottom: field.bottom },177
parent: (f.el && f.el.parentElement && f.el.parentElement.id) || ''218
pad: field.top,178
}))219
hudH: app.hudH,220
mode: plan.mode179
};221
};180
}"""222
}"""181
223
@@ -186,6 +228,12 @@ def assert_sides(info, tag, expect_rows=False):186
field = info["field"]228
field = info["field"]187
minis = info["minis"]229
minis = info["minis"]188
check(len(minis) >= 1, f"{tag}: at least one mini ({len(minis)})")230
check(len(minis) >= 1, f"{tag}: at least one mini ({len(minis)})")231
if field:232
# t1129: room above the field for around-the-top arcs233
gap = field["top"] - 50 # HUD is ~56–80; require a clear pad234
check(field["top"] >= (info.get("hud") or 70) + 80235
or field["y"] >= 70 + 80,236
f"{tag}: wide layout has top padding (field.top={field['top']:.1f}, y={field.get('y')})")189
if not field or not minis:237
if not field or not minis:190
return238
return191
for i, m in enumerate(minis):239
for i, m in enumerate(minis):@@ -202,7 +250,6 @@ def assert_sides(info, tag, expect_rows=False):202
check(m["top"] >= 50,250
check(m["top"] >= 50,203
f"{tag}: mini {i} stays under the HUD (top={m['top']:.1f})")251
f"{tag}: mini {i} stays under the HUD (top={m['top']:.1f})")204
if expect_rows and len(minis) >= 3:252
if expect_rows and len(minis) >= 3:205
# 3rd (index 2) is left, stacked above the first206
check(minis[2]["bottom"] <= minis[0]["top"] + 4,253
check(minis[2]["bottom"] <= minis[0]["top"] + 4,207
f"{tag}: third mini is stacked above the first "254
f"{tag}: third mini is stacked above the first "208
f"(b={minis[2]['bottom']:.1f} vs top={minis[0]['top']:.1f})")255
f"(b={minis[2]['bottom']:.1f} vs top={minis[0]['top']:.1f})")@@ -222,7 +269,7 @@ def assert_top(info, tag):222
f"(bottom={m['bottom']:.1f} field.top={field['top']:.1f})")269
f"(bottom={m['bottom']:.1f} field.top={field['top']:.1f})")223
270
224
271
225
def assert_flights(info, tag, expect_behind=True):272
def assert_flights(info, tag, expect_behind=True, expect_around=True):226
check(info["front"] >= 3, f"{tag}: front flights present ({info['front']})")273
check(info["front"] >= 3, f"{tag}: front flights present ({info['front']})")227
kinds = {k["kind"]: k for k in info["kinds"]}274
kinds = {k["kind"]: k for k in info["kinds"]}228
check("player-to-enemy" in kinds, f"{tag}: player-to-enemy")275
check("player-to-enemy" in kinds, f"{tag}: player-to-enemy")@@ -232,10 +279,33 @@ def assert_flights(info, tag, expect_behind=True):232
k = kinds["player-to-enemy"]279
k = kinds["player-to-enemy"]233
check(k["startScale"] > k["endScale"],280
check(k["startScale"] > k["endScale"],234
f"{tag}: player-to-enemy shrinks ({k['startScale']:.2f}→{k['endScale']:.2f})")281
f"{tag}: player-to-enemy shrinks ({k['startScale']:.2f}→{k['endScale']:.2f})")282
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,283
f"{tag}: player-to-enemy is grey (src={k.get('src')} color={k.get('color')})")235
if "enemy-to-player" in kinds:284
if "enemy-to-player" in kinds:236
k = kinds["enemy-to-player"]285
k = kinds["enemy-to-player"]237
check(k["endScale"] > k["startScale"],286
check(k["endScale"] > k["startScale"],238
f"{tag}: enemy-to-player grows ({k['startScale']:.2f}→{k['endScale']:.2f})")287
f"{tag}: enemy-to-player grows ({k['startScale']:.2f}→{k['endScale']:.2f})")288
check(k.get("landCol") == 3,289
f"{tag}: enemy-to-player landCol is 3 (got {k.get('landCol')})")290
if k.get("end") and info.get("expectedEndX"):291
check(abs(k["end"]["x"] - info["expectedEndX"]) < 3,292
f"{tag}: arc ends at column 3 "293
f"(end.x={k['end']['x']:.1f} expected={info['expectedEndX']:.1f})")294
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,295
f"{tag}: enemy-to-player is grey (src={k.get('src')} color={k.get('color')})")296
if expect_around and k.get("samples"):297
inside = [s for s in k["samples"] if s.get("inside")]298
check(len(inside) == 0,299
f"{tag}: enemy-to-player path stays outside the field "300
f"({len(inside)} interior samples {inside[:3]})")301
check(not k.get("insideNow"),302
f"{tag}: enemy-to-player mid-arc is not over the field interior")303
if "player-to-enemy" in kinds and expect_around:304
k = kinds["player-to-enemy"]305
inside = [s for s in (k.get("samples") or []) if s.get("inside")]306
check(len(inside) == 0,307
f"{tag}: player-to-enemy path stays outside the field "308
f"({len(inside)} interior samples {inside[:3]})")239
if "enemy-to-enemy" in kinds:309
if "enemy-to-enemy" in kinds:240
k = kinds["enemy-to-enemy"]310
k = kinds["enemy-to-enemy"]241
check(abs(k["startScale"] - k["endScale"]) < 0.05,311
check(abs(k["startScale"] - k["endScale"]) < 0.05,@@ -244,12 +314,17 @@ def assert_flights(info, tag, expect_behind=True):244
f"{tag}: enemy-to-enemy is in #flights-back (got {k['parent']})")314
f"{tag}: enemy-to-enemy is in #flights-back (got {k['parent']})")245
if expect_behind:315
if expect_behind:246
check(info["back"] >= 1, f"{tag}: at least one behind-field flight")316
check(info["back"] >= 1, f"{tag}: at least one behind-field flight")317
check("gray" in (k.get("src") or "").lower() or k.get("color") == -1,318
f"{tag}: enemy-to-enemy is grey (src={k.get('src')} color={k.get('color')})")247
if "enemy-miss" in kinds:319
if "enemy-miss" in kinds:248
k = kinds["enemy-miss"]320
k = kinds["enemy-miss"]249
check(k["startScale"] < 0.7,321
check(k["startScale"] < 0.7,250
f"{tag}: enemy-miss starts small ({k['startScale']:.2f})")322
f"{tag}: enemy-miss starts small ({k['startScale']:.2f})")251
check(k["parent"] == "flights",323
check(k["parent"] == "flights",252
f"{tag}: enemy-miss is in #flights (got {k['parent']})")324
f"{tag}: enemy-miss is in #flights (got {k['parent']})")325
# Misses keep the sender colour (not forced grey).326
check(k.get("color") != -1,327
f"{tag}: enemy-miss keeps the sender colour (color={k.get('color')})")253
328
254
329
255
def run_viewport(browser, url, name, width, height, is_mobile, round_n, expect_mode):330
def run_viewport(browser, url, name, width, height, is_mobile, round_n, expect_mode):@@ -263,17 +338,30 @@ def run_viewport(browser, url, name, width, height, is_mobile, round_n, expect_m263
open_offline(page, url, round_n=round_n)338
open_offline(page, url, round_n=round_n)264
page.wait_for_timeout(300)339
page.wait_for_timeout(300)265
info = page.evaluate(LAYOUT_INFO)340
info = page.evaluate(LAYOUT_INFO)266
print(f"--- {name} layout:", {k: info[k] for k in ('mode', 'n', 'tile', 'vw', 'vh', 'sidesClass')})341
print(f"--- {name} layout:", {k: info[k] for k in ('mode', 'n', 'tile', 'vw', 'vh', 'sidesClass')},342
"fieldY", info.get("field") and info["field"].get("y"),343
"field.top", info.get("field") and info["field"].get("top"))267
if expect_mode == "sides":344
if expect_mode == "sides":268
assert_sides(info, name, expect_rows=(round_n >= 12))345
assert_sides(info, name, expect_rows=(round_n >= 12))269
else:346
else:270
assert_top(info, name)347
assert_top(info, name)271
shot(page, f"t1125-{name}-layout.png")348
shot(page, f"t1126-{name}-layout.png")272
349
273
flights = page.evaluate(INJECT_FLIGHTS)350
# Mid-arc (age 0.55 of 1.2 s) — main verification frame274
print(f"--- {name} flights:", flights)351
flights = page.evaluate(INJECT_FLIGHTS, 0.55)352
print(f"--- {name} flights:", {k: flights[k] for k in ('front', 'back', 'expectedEndX', 'hudH', 'mode') if k in flights})353
for knd in flights["kinds"]:354
print(f" {knd['kind']}: color={knd.get('color')} landCol={knd.get('landCol')} "355
f"src={knd.get('src')} insideNow={knd.get('insideNow')} "356
f"end={knd.get('end')} pos={knd.get('pos')}")275
assert_flights(flights, name)357
assert_flights(flights, name)276
shot(page, f"t1125-{name}-flights.png")358
shot(page, f"t1126-{name}-midarc.png")359
360
# Extra mid-path frames on the wide 2-bot view so the around-route is visible361
if name == "desktop-wide":362
for age, label in ((0.25, "early"), (0.85, "late")):363
page.evaluate(INJECT_FLIGHTS, age)364
shot(page, f"t1126-{name}-midarc-{label}.png")277
context.close()365
context.close()278
366
279
367
@@ -288,13 +376,9 @@ def main():288
args=CHROME_ARGS,376
args=CHROME_ARGS,289
headless=True,377
headless=True,290
)378
)291
# Desktop wide: 2 opponents (round 2) alternating L/R292
run_viewport(browser, url, "desktop-wide", 1280, 900, False, 2, "sides")379
run_viewport(browser, url, "desktop-wide", 1280, 900, False, 2, "sides")293
# Many opponents, stacked rows (round 25 → 8 bots)294
run_viewport(browser, url, "desktop-wide-many", 1400, 900, False, 25, "sides")380
run_viewport(browser, url, "desktop-wide-many", 1400, 900, False, 25, "sides")295
# Desktop narrow: top layout296
run_viewport(browser, url, "desktop-narrow", 720, 800, False, 2, "top")381
run_viewport(browser, url, "desktop-narrow", 720, 800, False, 2, "top")297
# Mobile298
run_viewport(browser, url, "mobile", 393, 851, True, 2, "top")382
run_viewport(browser, url, "mobile", 393, 851, True, 2, "top")299
browser.close()383
browser.close()300
finally:384
finally: