Add quick representative battle smoke QA
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
"verify:local-release": "pnpm run verify:battle-save && pnpm run verify:campaign-save && tsc --noEmit && pnpm run build && pnpm run verify:release",
|
"verify:local-release": "pnpm run verify:battle-save && pnpm run verify:campaign-save && tsc --noEmit && pnpm run build && pnpm run verify:release",
|
||||||
"verify:public-deploy": "node scripts/verify-public-deploy.mjs",
|
"verify:public-deploy": "node scripts/verify-public-deploy.mjs",
|
||||||
"qa:representative": "node scripts/qa-representative-battles.mjs",
|
"qa:representative": "node scripts/qa-representative-battles.mjs",
|
||||||
|
"qa:smoke": "node scripts/qa-representative-battles.mjs --set=smoke",
|
||||||
"deploy:nas": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/deploy-nas.ps1 -Build",
|
"deploy:nas": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/deploy-nas.ps1 -Build",
|
||||||
"ship:release": "node scripts/ship-release.mjs"
|
"ship:release": "node scripts/ship-release.mjs"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { existsSync } from 'node:fs';
|
|||||||
import { readFile, writeFile } from 'node:fs/promises';
|
import { readFile, writeFile } from 'node:fs/promises';
|
||||||
import { chromium } from 'playwright';
|
import { chromium } from 'playwright';
|
||||||
|
|
||||||
|
const cliOptions = parseCliOptions(process.argv.slice(2));
|
||||||
const defaultQaPort = process.env.QA_PORT ?? '41737';
|
const defaultQaPort = process.env.QA_PORT ?? '41737';
|
||||||
const targetUrl = process.env.QA_URL ?? `http://127.0.0.1:${defaultQaPort}/`;
|
const targetUrl = process.env.QA_URL ?? `http://127.0.0.1:${defaultQaPort}/`;
|
||||||
const headless = process.env.QA_HEADLESS !== '0';
|
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 = {
|
const qaBattleSets = {
|
||||||
|
smoke: smokeBattles,
|
||||||
representative: allRepresentativeBattles,
|
representative: allRepresentativeBattles,
|
||||||
campaign: allCampaignBattles,
|
campaign: allCampaignBattles,
|
||||||
early: earlyCampaignBattles,
|
early: earlyCampaignBattles,
|
||||||
@@ -630,14 +634,14 @@ const qaBattleSets = {
|
|||||||
nanzhongFinal: nanzhongFinalCampaignBattles,
|
nanzhongFinal: nanzhongFinalCampaignBattles,
|
||||||
northern: northernCampaignBattles
|
northern: northernCampaignBattles
|
||||||
};
|
};
|
||||||
const qaSetName = process.env.QA_SET ?? 'representative';
|
const qaSetName = cliOptions.set ?? process.env.QA_SET ?? 'representative';
|
||||||
const qaBattleSet = qaBattleSets[qaSetName];
|
const qaBattleSet = qaBattleSets[qaSetName];
|
||||||
if (!qaBattleSet) {
|
if (!qaBattleSet) {
|
||||||
throw new Error(`Unknown QA_SET "${qaSetName}". Use one of: ${Object.keys(qaBattleSets).join(', ')}`);
|
throw new Error(`Unknown QA_SET "${qaSetName}". Use one of: ${Object.keys(qaBattleSets).join(', ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestedBattles = new Set(
|
const requestedBattles = new Set(
|
||||||
(process.env.QA_BATTLES ?? '')
|
(cliOptions.battles ?? process.env.QA_BATTLES ?? '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((entry) => entry.trim())
|
.map((entry) => entry.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
@@ -1534,3 +1538,35 @@ async function isServerReachable(url) {
|
|||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, 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