Files
HMDesign/scripts/verify-orgchart-hm-story.mjs
T
shkim4 f4ddd5ac4b
Deploy Storybook / deploy (push) Successful in 59s
docs(storybook): make Expanded OrgChart a preview-only page
Remove the data, layout, interaction and employee-popup setting panels
from the Expanded OrgChart Story. The chart now renders a fixed sample
(7 companies x 20, TB, all expanded, collapse/zoom/pan on, Drag & Drop
off, HM Dialog) right under the page title. Story ID, OrgChart packages
and public API are unchanged.

Align the Story browser checks (P7, P8, P9, P9.2-P9.5, geometry, popup
parity, hierarchy, HM Story) with the preview: setting-only scenarios
are removed, chart rendering, collapse, Zoom/Pan/Fit and HM Dialog checks
run on the fixed state. Move/Drag & Drop coverage stays in the Vanilla
Core checks (verify-p9-3-core, verify-p9-4-core).

Verified: tsc, test:guard 94/94, node --check on 11 scripts, changed
browser sections PASS. Pre-existing P7 story-menu, P8 Department
long-name, P9 Expanded tb/runner failures remain separate issues.
verify-p9-5-popup-parity was not run (needs the Vanilla example server).
2026-10-22 17:51:21 +09:00

53 lines
3.5 KiB
JavaScript

import assert from 'node:assert/strict';
import http from 'node:http';
import path from 'node:path';
import { readFile, writeFile } from 'node:fs/promises';
import { fileURLToPath, pathToFileURL } from 'node:url';
// Target only the affected existing Story and the unchanged Fixed composition.
const evidence = fileURLToPath(new URL('../test-results/org-chart-minimal-install/', import.meta.url));
const root = path.join(evidence, 'storybook');
const mime = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.svg': 'image/svg+xml', '.png': 'image/png', '.woff2': 'font/woff2' };
const server = http.createServer(async (request, response) => {
const filename = path.resolve(root, '.' + decodeURIComponent(new URL(request.url, 'http://localhost').pathname));
if (!filename.startsWith(root + path.sep)) { response.writeHead(403).end(); return; }
try { const bytes = await readFile(filename); response.writeHead(200, { 'Content-Type': mime[path.extname(filename)] || 'application/octet-stream' }).end(bytes); }
catch { response.writeHead(404).end(); }
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
assert.ok(process.env.ORGCHART_PLAYWRIGHT_MODULE, 'Set ORGCHART_PLAYWRIGHT_MODULE');
const { chromium } = await import(pathToFileURL(process.env.ORGCHART_PLAYWRIGHT_MODULE).href);
const browser = await chromium.launch({ headless: true, executablePath: process.env.ORGCHART_CHROME || 'C:/Program Files/Google/Chrome/Application/chrome.exe' });
const errors = [], results = [];
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
page.on('pageerror', error => errors.push(error.message));
page.on('console', message => { if (message.type() === 'error') errors.push(message.text()); });
for (const id of ['orgchart--expanded-org-chart', 'orgchart--full-composition']) {
await page.goto(`http://127.0.0.1:${server.address().port}/iframe.html?id=${id}&viewMode=story`);
const card = page.locator('.hm-orgchart-employee').first();
await card.waitFor(); await card.focus(); await page.keyboard.press('Enter');
const hm = page.locator('[data-component="HMOrgChartEmployeeDialog"]');
const core = page.locator('dialog.hm-orgchart-employee-dialog');
if (id.includes('expanded')) {
await hm.waitFor({ state: 'visible' });
assert.equal(await core.evaluate(e => e.open), false);
await page.screenshot({ path: path.join(evidence, 'storybook-expanded-hm.png') });
await page.keyboard.press('Escape'); await hm.waitFor({ state: 'hidden' });
assert.equal(await card.evaluate(e => e.getRootNode().activeElement === e), true);
// Expanded is preview-only (2026-10-22): no popup selector. Core popup stays covered by Fixed below.
results.push({ story: id, status: 'PASS', checks: ['Existing default HM Dialog', 'Escape and focus restoration'] });
} else {
await core.waitFor({ state: 'visible' }); assert.equal(await hm.count(), 0);
await page.screenshot({ path: path.join(evidence, 'storybook-fixed-core.png') });
await page.keyboard.press('Escape'); await core.waitFor({ state: 'hidden' });
results.push({ story: id, status: 'PASS', checks: ['Existing Fixed render and Core popup', 'Escape'] });
}
}
assert.deepEqual(errors, []);
await writeFile(path.join(evidence, 'storybook-browser.json'), JSON.stringify({ status: 'PASS', results, errors }, null, 2));
console.log(JSON.stringify({ status: 'PASS', results, errors }));
} finally {
await browser.close(); await new Promise(resolve => server.close(resolve));
}