tools/client/test_omni_pol_cold.mjs (2713B)
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 ['omni-pol-owner', 'omni-pol-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, 18, 2, 85552, 22246, 1], [2, 27, 2, 85505, 22331, 1], 31 [3, 30, 2, 85631, 22142, 1], [4, 23, 2, 85735, 21955, 1], 32 [5, 25, 2, 85735, 21955, 1], [6, 51, 2, 85591, 22196, 1], 33 [7, 21, 2, 85679, 22064, 1], [9, 24, 101, 85591, 22196, 1], 34 [10, 50, 200, 22196, 22196, 1], 35 ]); 36 assert.equal(owner.local().stats[16], 252); 37 assert.equal(owner.local().stats[18], 277); 38 assert.equal(owner.local().stats[53], 946); 39 assert.equal(owner.local().stats[61], 5948); 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 OmniPol 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 }