Files
dbx-main/tests/js/help.browser.test.js
king 39dcda66b4 feat(project): remove per-row this-week sales in weekly meetings
Drop the "이번주 실적" line under each row's target and the now-unused
shop link menu. Performance sales stay only in the header cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 16:01:47 +09:00

82 lines
5.0 KiB
JavaScript

// 실제 Chromium + ERP 셸에서 검색·이동과 데스크톱/모바일 표시 검증(DB 미사용).
// python tests/js/render_help.py
// PJ_TEST_BROWSER=<설치된 Chrome 경로> node tests/js/help.browser.test.js (playwright 필요)
const assert = require("node:assert/strict");
const fs = require("node:fs");
const http = require("node:http");
const path = require("node:path");
const { chromium } = require("playwright");
const ROOT = path.resolve(__dirname, "../..");
const STATIC = path.join(ROOT, "app/static");
const OUT = path.join(__dirname, ".out");
const server = http.createServer(function (req, res) {
const url = new URL(req.url, "http://localhost");
if (url.pathname === "/project/help") {
res.setHeader("Content-Type", "text/html; charset=utf-8");
res.end(fs.readFileSync(path.join(OUT, "help_render.html"))); return;
}
const file = path.resolve(STATIC, "." + decodeURIComponent(url.pathname.slice(7)));
if (!url.pathname.startsWith("/static/") || !file.startsWith(STATIC + path.sep) || !fs.existsSync(file) || !fs.statSync(file).isFile()) {
res.statusCode = 404; res.end(); return;
}
const types = { ".css": "text/css", ".js": "text/javascript", ".woff2": "font/woff2", ".woff": "font/woff", ".png": "image/png" };
res.setHeader("Content-Type", types[path.extname(file)] || "application/octet-stream");
fs.createReadStream(file).pipe(res);
});
(async function () {
let browser;
try {
await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
browser = await chromium.launch({ headless: true, executablePath: process.env.PJ_TEST_BROWSER || undefined });
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
const errors = [], mutations = [];
page.on("pageerror", e => errors.push(e.message));
page.on("request", r => { if (r.method() !== "GET") mutations.push(r.url()); });
await page.goto("http://127.0.0.1:" + server.address().port + "/project/help");
await page.locator("#pjh-query").waitFor({ state: "visible" });
await page.locator("#pjh-query").fill("셀 병합");
const first = page.locator("#pjh-results a").first();
assert.equal(await first.getAttribute("href"), "#goals-merge");
await page.screenshot({ path: path.join(OUT, "help-desktop.png") });
await first.click();
assert.equal(await page.evaluate(() => document.activeElement.id), "goals-merge");
assert.ok(await page.locator("#goals-merge").isVisible());
const rect = await page.locator("#goals-merge").boundingBox();
assert.ok(rect.y >= 0 && rect.y < 300, "앵커 이동 후 소제목이 화면 위에 표시");
await page.screenshot({ path: path.join(OUT, "help-goals.png") });
await page.keyboard.press("/");
await page.locator("#pjh-query").fill("매출 갱신");
await page.locator("#pjh-query").press("Enter");
assert.equal(await page.evaluate(() => document.activeElement.id), "meetings-markets");
await page.reload();
await page.locator("#pjh-query").waitFor({ state: "visible" });
assert.equal(await page.locator("#pjh-query").inputValue(), "매출 갱신");
assert.equal(await page.evaluate(() => document.activeElement.id), "meetings-markets");
await page.goBack();
assert.equal(await page.evaluate(() => document.activeElement.id), "goals-merge");
assert.equal(await page.locator("#pjh-query").inputValue(), new URL(page.url()).searchParams.get("q"), "뒤로 간 주소의 검색어 복원");
await page.setViewportSize({ width: 390, height: 844 });
await page.waitForFunction(() => document.querySelector(".erp-sidebar").getBoundingClientRect().right <= 1);
await page.keyboard.press("/");
await page.locator("#pjh-query").fill("회의록");
await page.screenshot({ path: path.join(OUT, "help-mobile.png") });
assert.ok(await page.locator("#pjh-query").isVisible(), "모바일에서 목차가 숨겨져도 검색 유지");
const widths = await page.evaluate(() => {
const nodes = [document.documentElement, document.querySelector(".erp-page"), document.querySelector(".pjh"), document.querySelector(".pjh-body")];
return nodes.map(n => ({ name: n.className || n.tagName, scroll: n.scrollWidth, client: n.clientWidth }));
});
assert.ok(widths.every(n => n.scroll <= n.client + 1), "모바일에서 가로 넘침 없음: " + JSON.stringify(widths));
await page.locator('#pjh-results a[href="#meetings-review"]').click();
assert.equal(await page.evaluate(() => document.activeElement.id), "meetings-review");
await page.screenshot({ path: path.join(OUT, "help-meeting-mobile.png") });
assert.deepEqual(errors, [], "브라우저 JS 오류 없음");
assert.deepEqual(mutations, [], "도움말 검색은 데이터 쓰기 요청 없음");
console.log("ALL PASS — Chromium 검색·Enter·새로고침·뒤로 가기·390px 모바일 레이아웃");
} finally {
if (browser) await browser.close();
await new Promise(resolve => server.close(resolve));
}
})().catch(function (e) { console.error(e); process.exitCode = 1; });