tools/client/test_kevlar_cold.mjs (2708B)
1 import assert from 'node:assert/strict'; 2 import {createRequire} from 'node:module'; 3 import {GameTest} from './game_test.mjs'; 4 5 const {chromium} = createRequire(import.meta.url)('playwright'); 6 const [url, output] = process.argv.slice(2); 7 const browser = await chromium.launch({executablePath: '/usr/bin/chromium', headless: false, 8 args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage', 9 '--disable-background-timer-throttling', '--disable-renderer-backgrounding']}); 10 const games = []; 11 try { 12 for (const token of ['kevlar-owner', 'kevlar-watch']) { 13 const context = await browser.newContext({viewport: {width: 1024, height: 768}}); 14 await context.addCookies([{name: 'ao_client', value: token, url}]); 15 const page = await context.newPage(); 16 const game = await GameTest.attach(page); 17 games.push(game); 18 await page.goto(url); 19 await game.ready(); 20 await page.waitForFunction(() => touchRegion(500, 400)?.world === true); 21 await game.snapshot(); 22 } 23 const [owner, observer] = games; 24 if (!observer.state.camera.firstPerson) await observer.key('F8'); 25 await observer.wait('retained armor wearer is visible', state => state.actors.some(actor => actor.id === 1 && 26 actor.screenPosition?.[0] > 0 && actor.screenPosition[0] < 1024 && actor.screenPosition[1] > 0 && 27 actor.screenPosition[1] < 748 && actor.screenPosition[2] >= 0 && actor.screenPosition[2] <= 1)); 28 assert.deepEqual(owner.local().inventory.map(item => 29 [item.id, item.slot, item.quality, ...item.templates, item.count]).sort((a, b) => a[0] - b[0]), [ 30 [1, 27, 2, 85516, 22301, 1], [2, 30, 2, 85641, 22116, 1], 31 [3, 23, 2, 85745, 21929, 1], [4, 25, 2, 85745, 21929, 1], 32 [5, 52, 2, 85598, 22178, 1], [6, 21, 2, 85692, 22026, 1], 33 [7, 51, 2, 85691, 22004, 1], [9, 24, 101, 85598, 22178, 1], 34 [10, 50, 200, 22178, 22178, 1], 35 ]); 36 assert.equal(owner.local().stats[16], 244); 37 assert.equal(owner.local().stats[17], 269); 38 assert.equal(owner.local().stats[53], 978); 39 assert.equal(owner.local().stats[61], 5062); 40 assert.deepEqual(observer.local().inventory, []); 41 await owner.page.waitForFunction(() => touchRegion(500, 400)?.world === true); 42 await owner.snapshot(); 43 await owner.key('KeyI'); 44 await owner.page.keyboard.press('Control+1'); 45 await owner.click(953, 53); 46 await owner.page.keyboard.press('Control+9'); 47 assert(games.every(game => game.errors.length === 0)); 48 console.log('PASS: all nine exact Kevlar identities, endpoints, slots, training and sale wallet after cold startup'); 49 } finally { 50 try { await Promise.all(games.map((game, index) => game.save(output + '/' + index))); } 51 finally { await browser.close(); } 52 }