feat: 增進 app-map
This commit is contained in:
+22
-1
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { buildAppMap, buildPageContract, extractRegions, inferRegionSpec, summarizeHtml, validatePageContract } from '../src/lib/html.js'
|
||||
import { buildAppMap, buildAppMapWithGuides, buildPageContract, extractRegions, inferRegionSpec, parsePrototypeGuide, summarizeHtml, validatePageContract } from '../src/lib/html.js'
|
||||
|
||||
test('summarizeHtml extracts user-visible contract evidence', () => {
|
||||
const summary = summarizeHtml(`
|
||||
@@ -97,6 +97,27 @@ test('buildAppMap classifies auth, shell references, and feature pages', () => {
|
||||
assert.equal(appMap.modules.find((module) => module.name === 'venue').kind, 'feature-module')
|
||||
})
|
||||
|
||||
test('buildAppMap enriches routes with prototype markdown guide entries', () => {
|
||||
const prototypeDir = '/repo/prototype'
|
||||
const guide = parsePrototypeGuide('venue.md', `
|
||||
# Venue 雛型導覽
|
||||
|
||||
| 雛型檔 | 舊 JSP 來源 | 舊 PB NVO 來源 | 對應 Vue view(M9) |
|
||||
| --- | --- | --- | --- |
|
||||
| [\`query-room.html\`](venue/query-room.html) | \`zte_pro/zte451_02.jsp\` + \`zte451_02_1.jsp\` | \`n_zte451.of_zte451_02\` / \`of_zte451_02_1\` | \`RoomQueryView.vue\` |
|
||||
`)
|
||||
const appMap = buildAppMapWithGuides([
|
||||
buildSpec('/repo/prototype/venue/query-room.html', '<main><h1>全校場地查詢</h1><button>查詢</button></main>')
|
||||
], prototypeDir, [guide])
|
||||
const route = appMap.routes[0]
|
||||
|
||||
assert.equal(appMap.guideSources[0].source, 'venue.md')
|
||||
assert.equal(route.evidence.prototypeGuide, 'venue.md')
|
||||
assert.equal(route.guide.legacyJsp, 'zte_pro/zte451_02.jsp + zte451_02_1.jsp')
|
||||
assert.equal(route.guide.legacyPb, 'n_zte451.of_zte451_02 / of_zte451_02_1')
|
||||
assert.equal(route.guide.targetView, 'RoomQueryView.vue')
|
||||
})
|
||||
|
||||
function buildSpec(source, html) {
|
||||
const regions = extractRegions(html)
|
||||
const domSummary = summarizeHtml(html)
|
||||
|
||||
Reference in New Issue
Block a user