forked from phenom/healer-man
117 lines
6.8 KiB
JavaScript
117 lines
6.8 KiB
JavaScript
const { chromium } = require('C:/Users/phenom/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
|
|
const output = path.resolve('playtest-artifacts/party-equipment');
|
|
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'healer-man-equipment-'));
|
|
fs.mkdirSync(output, { recursive: true });
|
|
|
|
async function capture(page, name) {
|
|
await page.screenshot({ path: path.join(output, `${name}.png`) });
|
|
}
|
|
|
|
(async () => {
|
|
const { createGameServer } = await import('../server/server.mjs');
|
|
const runtime = createGameServer({ dataDir, staticDir: path.resolve('dist'), contentDir: path.resolve('content'), enableShelvedModes: false });
|
|
await new Promise((resolve) => runtime.server.listen(0, '127.0.0.1', resolve));
|
|
console.log({ cwd: process.cwd(), staticDir: runtime.staticDir, indexExists: fs.existsSync(path.join(runtime.staticDir, 'index.html')), port: runtime.server.address().port });
|
|
const browser = await chromium.launch({ channel: 'msedge', headless: true });
|
|
const results = {};
|
|
try {
|
|
for (const category of process.argv.includes('--rom-only') ? ['RoM'] : ['WoW', 'RoM']) {
|
|
const context = await browser.newContext({ viewport: { width: 1600, height: 1000 } });
|
|
const page = await context.newPage();
|
|
page.setDefaultTimeout(60000);
|
|
const errors = [];
|
|
page.on('pageerror', (error) => errors.push(error.message));
|
|
page.on('console', (message) => {
|
|
if (message.type() === 'error' && !message.text().startsWith('Failed to load resource:')) errors.push(message.text());
|
|
});
|
|
page.on('response', (response) => {
|
|
if (response.status() >= 400 && !response.url().endsWith('/favicon.ico')) errors.push(`${response.status()}: ${response.url()}`);
|
|
});
|
|
try {
|
|
await page.goto(`http://127.0.0.1:${runtime.server.address().port}`, { waitUntil: 'domcontentloaded' });
|
|
await page.getByRole('button', { name: /Play offline/ }).click();
|
|
await page.getByRole('button', { name: /Create character/ }).click();
|
|
await page.locator('.creator-category-tabs button').filter({ hasText: category }).click();
|
|
await page.locator('.class-option').filter({ hasText: 'Priest' }).click();
|
|
await page.getByRole('button', { name: /Customize & name/ }).click();
|
|
await page.getByLabel('Character name', { exact: true }).fill(category === 'WoW' ? 'Wowgear' : 'Romgear');
|
|
await page.getByRole('button', { name: /Create character/ }).click();
|
|
await page.locator('.character-select-screen').waitFor();
|
|
await page.waitForTimeout(4000);
|
|
await capture(page, `${category}-roster`);
|
|
await page.getByRole('button', { name: /Continue as/ }).click({ position: { x: 24, y: 30 } });
|
|
await page.locator('.main-menu-screen').waitFor();
|
|
await page.getByRole('button', { name: /Downloads/ }).click();
|
|
const pack = page.locator('.content-pack-row').filter({ hasText: category === 'WoW'
|
|
? 'Extra Wrath Character Models & Skins' : 'RuneWaker Character Models & Skins' });
|
|
await pack.getByRole('button', { name: 'Download', exact: true }).click();
|
|
await pack.getByText('Installed — offline ready', { exact: true }).waitFor({ timeout: 180000 });
|
|
await page.getByRole('button', { name: 'Back', exact: true }).click();
|
|
await page.getByRole('button', { name: 'Change character', exact: true }).click();
|
|
await page.locator('.character-select-screen').waitFor();
|
|
await page.waitForTimeout(5000);
|
|
await capture(page, `${category}-roster`);
|
|
await page.getByRole('button', { name: /Continue as/ }).click({ position: { x: 24, y: 30 } });
|
|
await page.locator('.main-menu-screen').waitFor();
|
|
await page.getByRole('button', { name: /^Dungeons/ }).click();
|
|
await page.locator('.dungeon-category-tab').filter({ hasText: category }).click();
|
|
await page.locator('.dungeon-select-row').filter({ hasText: category === 'WoW' ? 'Wailing Caverns' : 'Forsaken Abbey' }).first().click();
|
|
const download = page.getByRole('button', { name: 'Download and continue' });
|
|
if (await download.isVisible()) await download.click();
|
|
else await page.getByRole('button', { name: 'Choose role' }).click();
|
|
await page.locator('.dungeon-role-option--healer').click();
|
|
await page.locator('.scene-shell').waitFor();
|
|
await page.locator('.loading-screen').waitFor({ state: 'hidden' });
|
|
await page.locator('.party-frames').waitFor();
|
|
await page.waitForTimeout(12000);
|
|
await page.locator('.dungeon-boss-intro').waitFor({ state: 'hidden' });
|
|
await capture(page, `${category}-dungeon`);
|
|
// Rotate the camera with the normal held-right-mouse gesture to show the party fronts.
|
|
const bounds = await page.locator('.scene-shell canvas').boundingBox();
|
|
await page.mouse.move(bounds.x + bounds.width * 0.5, bounds.y + bounds.height * 0.55);
|
|
await page.mouse.down({ button: 'right' });
|
|
await page.mouse.move(bounds.x + bounds.width * 0.5 + 440, bounds.y + bounds.height * 0.55, { steps: 40 });
|
|
await page.mouse.up({ button: 'right' });
|
|
await page.waitForTimeout(1200);
|
|
await capture(page, `${category}-party-front`);
|
|
if (category === 'RoM') {
|
|
await page.locator('.scene-shell').focus();
|
|
await page.keyboard.down('s');
|
|
await page.waitForTimeout(2000);
|
|
await page.keyboard.up('s');
|
|
await page.mouse.wheel(700, 700);
|
|
await page.waitForTimeout(2500);
|
|
await capture(page, `${category}-party-open`);
|
|
}
|
|
assert.deepEqual(errors, []);
|
|
results[category] = {
|
|
installedNativeCharacterPack: true,
|
|
screenshots: [`${category}-roster.png`, `${category}-dungeon.png`, `${category}-party-front.png`,
|
|
...(category === 'RoM' ? [`${category}-party-open.png`] : [])],
|
|
errors,
|
|
};
|
|
} catch (error) {
|
|
await capture(page, `${category}-failure`);
|
|
console.error((await page.locator('body').innerText()).slice(-2500));
|
|
console.error(errors);
|
|
throw error;
|
|
} finally {
|
|
await context.close();
|
|
}
|
|
}
|
|
fs.writeFileSync(path.join(output, 'results.json'), `${JSON.stringify(results, null, 2)}\n`);
|
|
console.log(JSON.stringify(results, null, 2));
|
|
} finally {
|
|
await browser.close();
|
|
await new Promise((resolve) => runtime.server.close(resolve));
|
|
assert.equal(path.dirname(path.resolve(dataDir)), path.resolve(os.tmpdir()));
|
|
assert.ok(path.basename(dataDir).startsWith('healer-man-equipment-'));
|
|
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
}
|
|
})().catch((error) => { console.error(error); process.exitCode = 1; });
|