tools/client/test_nomad_cold.mjs (2218B)
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 ['nomad-owner', 'nomad-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 } 21 const [owner, observer] = games; 22 assert.deepEqual(owner.local().inventory.map(item => 23 [item.id, item.slot, item.quality, ...item.templates, item.count]).sort((a, b) => a[0] - b[0]), [ 24 [1, 18, 2, 85554, 85553, 1], [2, 27, 2, 85507, 85506, 1], 25 [3, 30, 2, 85633, 85632, 1], [4, 23, 2, 85737, 85736, 1], 26 [5, 25, 2, 85737, 85736, 1], [6, 51, 2, 85593, 85592, 1], 27 [7, 21, 2, 85681, 85680, 1], [9, 24, 101, 85593, 85592, 1], 28 [10, 50, 200, 85592, 85592, 1], 29 ]); 30 assert.equal(owner.local().stats[16], 241); 31 assert.equal(owner.local().stats[18], 266); 32 assert.equal(owner.local().stats[53], 990); 33 assert.equal(owner.local().stats[61], 4884); 34 assert.deepEqual(observer.local().inventory, []); 35 await owner.page.waitForFunction(() => touchRegion(500, 400)?.world === true); 36 await owner.snapshot(); 37 await owner.key('KeyI'); 38 await owner.page.keyboard.press('Control+1'); 39 await owner.click(953, 53); 40 await owner.page.keyboard.press('Control+9'); 41 assert(games.every(game => game.errors.length === 0)); 42 console.log('PASS: all nine exact Nomad identities, endpoints, slots, training and sale wallet after cold startup'); 43 } finally { 44 try { await Promise.all(games.map((game, index) => game.save(output + '/' + index))); } 45 finally { await browser.close(); } 46 }