aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


tools/client/test_bau_cyber_cold.mjs (2310B)


      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',
      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 ['bau-cyber-owner', 'bau-cyber-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, 85571, 85570, 1], [2, 27, 2, 85530, 85529, 1],
     25     [3, 30, 2, 85654, 85653, 1], [4, 23, 2, 85759, 85758, 1],
     26     [5, 25, 2, 85759, 85758, 1], [6, 52, 2, 85611, 85610, 1],
     27     [7, 50, 2, 85710, 85709, 1], [8, 21, 2, 85708, 85707, 1],
     28     [10, 24, 101, 85611, 85610, 1], [11, 51, 200, 85610, 85610, 1],
     29   ]);
     30   assert.equal(owner.local().stats[19], 264);
     31   assert.equal(owner.local().stats[21], 239);
     32   assert.equal(owner.local().stats[53], 1499);
     33   assert.equal(owner.local().stats[61], 5380);
     34   assert.deepEqual(observer.local().inventory, []);
     35   await owner.key('KeyI');
     36   await owner.page.keyboard.press('Control+1');
     37   await owner.click(953, 53);
     38   await owner.page.keyboard.press('Control+9');
     39   await owner.wait('cold native armor stats', state => state.regions.some(
     40     ([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606));
     41   assert(games.every(game => game.errors.length === 0));
     42   console.log('PASS: all ten exact Bau instances, endpoints, slots, trained abilities and sale wallet after cold startup');
     43 } finally {
     44   try { await Promise.all(games.map((game, id) => game.save(output + '/' + id))); }
     45   finally { await browser.close(); }
     46 }