Add quick representative battle smoke QA
This commit is contained in:
@@ -3,6 +3,7 @@ import { existsSync } from 'node:fs';
|
||||
import { readFile, writeFile } from 'node:fs/promises';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const cliOptions = parseCliOptions(process.argv.slice(2));
|
||||
const defaultQaPort = process.env.QA_PORT ?? '41737';
|
||||
const targetUrl = process.env.QA_URL ?? `http://127.0.0.1:${defaultQaPort}/`;
|
||||
const headless = process.env.QA_HEADLESS !== '0';
|
||||
@@ -619,7 +620,10 @@ const allRepresentativeBattles = [
|
||||
}
|
||||
];
|
||||
|
||||
const smokeBattles = allRepresentativeBattles.filter((battle) => [1, 7, 27].includes(battle.no));
|
||||
|
||||
const qaBattleSets = {
|
||||
smoke: smokeBattles,
|
||||
representative: allRepresentativeBattles,
|
||||
campaign: allCampaignBattles,
|
||||
early: earlyCampaignBattles,
|
||||
@@ -630,14 +634,14 @@ const qaBattleSets = {
|
||||
nanzhongFinal: nanzhongFinalCampaignBattles,
|
||||
northern: northernCampaignBattles
|
||||
};
|
||||
const qaSetName = process.env.QA_SET ?? 'representative';
|
||||
const qaSetName = cliOptions.set ?? process.env.QA_SET ?? 'representative';
|
||||
const qaBattleSet = qaBattleSets[qaSetName];
|
||||
if (!qaBattleSet) {
|
||||
throw new Error(`Unknown QA_SET "${qaSetName}". Use one of: ${Object.keys(qaBattleSets).join(', ')}`);
|
||||
}
|
||||
|
||||
const requestedBattles = new Set(
|
||||
(process.env.QA_BATTLES ?? '')
|
||||
(cliOptions.battles ?? process.env.QA_BATTLES ?? '')
|
||||
.split(',')
|
||||
.map((entry) => entry.trim())
|
||||
.filter(Boolean)
|
||||
@@ -1534,3 +1538,35 @@ async function isServerReachable(url) {
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function parseCliOptions(args) {
|
||||
const options = {};
|
||||
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
const arg = args[index];
|
||||
if (!arg.startsWith('--')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const [rawKey, rawValue] = arg.slice(2).split('=', 2);
|
||||
const key = rawKey.trim();
|
||||
if (!key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rawValue !== undefined) {
|
||||
options[key] = rawValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
const next = args[index + 1];
|
||||
if (next && !next.startsWith('--')) {
|
||||
options[key] = next;
|
||||
index += 1;
|
||||
} else {
|
||||
options[key] = '1';
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user