Files
aurora-admin/run-tests.ps1
T
aurora-admin 6fec4ba6f8 v1.3.0: 修复验收链路(iframe 真实渲染+跨帧断言)、基座焦点环、契约第二批 15 个
回归通过率此前不可信:run-tests.ps1 抽取演示页 body 时剥离全部 <script>,
而 79 个 H5 演示页的 DOM 全由内联脚本渲染,且测试页从未引用 frameworks/<组件>.css
—— 断言跑在空 DOM + 无组件样式上,v1.2.0 的 75.1% 属结构性误报。

Fixed — 验收链路
- 测试页改为 iframe 加载真实演示页(_template.html),_runtime.js 跨帧在真实
  渲染结果上断言:帧内 getComputedStyle/styleSheets/outerHTML,用例自动标注 +
  帧内描边,结果 postMessage 上报
- 标注改为容器下钻(.row/.demo-block → 首个含 ≥2 有效子元素的容器,最多 6 层)
- 新增 N/A 语义:静态组件键盘/ARIA 记 skip 而非失败;对比度与 token 检查限定
  在被测组件区,页头文档文字不计
- 通过率分母改为 pass/(pass+fail),tools/run-regression.mjs 与收集器同口径

Added — 设计系统
- 基座 :focus-visible 统一焦点环(colors_and_type.css)。--au-color-focus-ring
  此前只定义未消费,79 个组件样式仅 20 个自带 focus 规则 —— 一次性消除 66 页失败
- tests/_collect.html:零依赖浏览器批量回归收集器(并发 iframe + 汇总)
- tests/_index_template.html:测试总览页模板外置,读数来自 data.json

Added — 契约第二批(展示类 15 个)
- tree/collapse/calendar/carousel/imagepreview/qrcode/countdown/watermark/
  cardlist/treetable/timelinelist/steplist/chartpanel/dashboardcard/employeecard
- 逐份从规格原文(组件2/4/7/9.txt)提炼,含 dims/variants/anatomy/structure/
  usageHints/doNotInvent/unknowns;契约化 21 → 36/79

Changed
- run-tests.ps1 重写:删除失效的快照抽取(占位符替换早已不匹配模板),改生成
  iframe 版测试页;输出 WriteAllText 无 BOM;保持 ASCII-only,中文移入 UTF-8 模板
- 回归基线:960 断言 / 794 通过 / 85.1% / 11 页全通过 / N/A 27
- CHANGELOG/TESTING/改造清单同步;测试总览页与首页通过率联动

验证:浏览器全量 79 页收集器跑通两次,基线一致;详情页契约章节
(含 doNotInvent/unknowns)、chip、首页「通过率 85.1%」、changelog v1.3.0 实测通过
2026-09-10 21:19:09 +08:00

55 lines
2.2 KiB
PowerShell

# run-tests.ps1 - regenerate tests/<slug>.html (one per component) + tests/index.html
#
# Test pages embed an iframe of the real H5 demo (frameworks/<Prefix>.html). Component CSS and the
# demo's inline script actually run inside that frame, and tests/_runtime.js runs every assertion
# against the frame document. Nothing is snapshot-copied here: copying body HTML while stripping
# <script> produced empty test pages, because all 79 demos render their DOM from inline JS.
#
# Output is UTF-8 WITHOUT BOM (PS5.1 `Set-Content -Encoding UTF8` would prepend a BOM).
# This script is intentionally ASCII-only: PS5.1 reads BOM-less files as ANSI, so any non-ASCII
# literal here would be mangled. Chinese labels live in the UTF-8 templates instead.
$ErrorActionPreference = 'Stop'
$lib = ".design_library/aurora-admin"
$idx = Get-Content "$lib/components/index.json" -Raw -Encoding UTF8 | ConvertFrom-Json
$template = Get-Content "tests/_template.html" -Raw -Encoding UTF8
$indexTemplate = Get-Content "tests/_index_template.html" -Raw -Encoding UTF8
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
function Write-NoBom([string]$path, [string]$content) {
$full = [System.IO.Path]::GetFullPath((Join-Path (Get-Location).Path $path))
[System.IO.File]::WriteAllText($full, $content, $utf8NoBom)
}
New-Item -ItemType Directory -Force -Path tests | Out-Null
$count = 0
$missing = @()
foreach ($c in $idx.components) {
$slug = $c.slug
$prefix = $c.frameworksPrefix
$zh = ($c.name -split ' ')[0]
# SLUG_ZH_PLACEHOLDER must be replaced first: it contains SLUG_PLACEHOLDER as a substring.
$html = $template
$html = $html.Replace('SLUG_ZH_PLACEHOLDER', $zh)
$html = $html.Replace('PREFIX_PLACEHOLDER', $prefix)
$html = $html.Replace('SLUG_PLACEHOLDER', $slug)
Write-NoBom "tests/$slug.html" $html
if (-not (Test-Path "frameworks/$prefix.html")) { $missing += $prefix }
$count++
}
$indexHtml = $indexTemplate.Replace('__COUNT__', [string]$count)
Write-NoBom "tests/index.html" $indexHtml
Write-Output ("generated {0} test pages + tests/index.html" -f $count)
if ($missing.Count -gt 0) {
Write-Output ("WARNING missing demo pages ({0}): {1}" -f $missing.Count, ($missing -join ', '))
}
Write-Output "done."