tools/client/test_east_wind_cold.mjs (1774B)
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', args: [ 8 '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage', 9 '--disable-background-timer-throttling', '--disable-renderer-backgrounding']}); 10 let game; 11 try { 12 const context = await browser.newContext({viewport: {width: 1024, height: 768}}); 13 await context.addCookies([{name: 'ao_client', value: 'east-wind', url}]); 14 const page = await context.newPage(); 15 game = await GameTest.attach(page); 16 await page.goto(url); 17 await game.ready(); 18 await page.waitForFunction(() => touchRegion(500, 400)?.world === true); 19 await game.snapshot(); 20 assert.deepEqual(game.local().inventory.map(item => [item.id,item.slot,item.quality,...item.templates]), 21 [[4,6,2,160216,160217],[1,48,1,209283,209283]]); 22 for (const [stat, value] of [[60,6],[54,2],[105,9],[104,6],[142,8],[22,9],[53,188],[61,1003]]) 23 assert.equal(game.local().stats[stat], value, 'retained native stat ' + stat); 24 const state = await (await page.request.get(url + '/test-state')).json(); 25 assert.equal(state.completed, true); 26 assert.equal(state.lastID, 4); 27 assert.equal(state.inventory.Items.length, 2); 28 await game.key('KeyI'); 29 await page.keyboard.press('Control+1'); 30 assert.deepEqual(game.errors, []); 31 console.log('PASS: cold period reward retains exact identities, QL, training, weighted rating and wallet without replay'); 32 } finally { 33 try { if (game) await game.save(output + '/final'); } 34 finally { await browser.close(); } 35 }