aorecomp

Anarchy Online classic in the browser

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


tools/client/test_steel_ribbed_cold.mjs (2118B)


      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 ['steel-owner', 'steel-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, 85541, 22262, 1], [2, 27, 2, 85494, 22347, 1],
     25     [3, 30, 2, 85620, 22158, 1], [4, 23, 2, 85724, 21971, 1],
     26     [5, 25, 2, 85724, 21971, 1], [6, 51, 2, 85580, 22212, 1],
     27     [7, 21, 2, 85668, 22080, 1], [9, 24, 101, 85580, 22212, 1],
     28     [10, 50, 200, 22212, 22212, 1],
     29   ]);
     30   assert.equal(owner.local().stats[17], 246);
     31   assert.equal(owner.local().stats[20], 271);
     32   assert.equal(owner.local().stats[53], 970);
     33   assert.equal(owner.local().stats[61], 5239);
     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   assert(games.every(game => game.errors.length === 0));
     40   console.log('PASS: all nine exact Steel-Ribbed identities, endpoints, slots, training and sale wallet after cold startup');
     41 } finally {
     42   try { await Promise.all(games.map((game, index) => game.save(output + '/' + index))); }
     43   finally { await browser.close(); }
     44 }