tools/client/test_graft_organic_cold.mjs (2953B)
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 specs = { 11 graft: { 12 stamina: 278, strength: 253, ip: 938, wallet: 6302, 13 items: [ 14 [1, 18, 2, 120565, 142681, 1], 15 [2, 27, 2, 120579, 142679, 1], 16 [3, 30, 2, 120582, 142685, 1], 17 [4, 23, 2, 120584, 142689, 1], 18 [5, 25, 2, 120584, 142689, 1], 19 [6, 51, 2, 120581, 142683, 1], 20 [7, 21, 2, 120583, 142687, 1], 21 [9, 24, 101, 120581, 142683, 1], 22 [10, 50, 200, 142683, 142683, 1], 23 ], 24 }, 25 organic: { 26 stamina: 273, strength: 248, ip: 958, wallet: 5593, 27 items: [ 28 [1, 18, 2, 120586, 142682, 1], 29 [2, 27, 2, 120585, 142680, 1], 30 [3, 30, 2, 120588, 142686, 1], 31 [4, 23, 2, 120590, 142690, 1], 32 [5, 25, 2, 120590, 142690, 1], 33 [6, 51, 2, 120587, 142684, 1], 34 [7, 21, 2, 120589, 142688, 1], 35 [9, 24, 101, 120587, 142684, 1], 36 [10, 50, 200, 142684, 142684, 1], 37 ], 38 }, 39 }; 40 const games = []; 41 try { 42 for (const token of ['armor-owner', 'armor-watch']) { 43 const context = await browser.newContext({viewport: {width: 1024, height: 768}}); 44 await context.addCookies([{name: 'ao_client', value: token, url}]); 45 const page = await context.newPage(); 46 const game = await GameTest.attach(page); 47 games.push(game); 48 await page.goto(url); 49 await game.ready(); 50 } 51 const [owner, observer] = games; 52 const spec = specs[(await (await owner.page.request.get(url + "/test-state")).json()).family]; 53 assert.deepEqual(owner.local().inventory.map(item => 54 [item.id, item.slot, item.quality, ...item.templates, item.count]).sort((a, b) => a[0] - b[0]), spec.items); 55 assert.equal(owner.local().stats[16], spec.strength + 1); 56 assert.equal(owner.local().stats[18], spec.stamina + 1); 57 assert.equal(owner.local().stats[53], spec.ip); 58 assert.equal(owner.local().stats[61], spec.wallet); 59 assert.deepEqual(observer.local().inventory, []); 60 await owner.page.waitForFunction(() => touchRegion(500, 400)?.world === true); 61 await owner.snapshot(); 62 await owner.key('KeyI'); 63 await owner.page.keyboard.press('Control+1'); 64 await owner.click(953, 53); 65 await owner.page.keyboard.press('Control+9'); 66 assert(games.every(game => game.errors.length === 0)); 67 console.log('PASS: all nine exact armor identities, endpoints, slots, training and sale wallet after cold startup'); 68 } finally { 69 try { await Promise.all(games.map((game, index) => game.save(output + '/' + index))); } 70 finally { await browser.close(); } 71 }