feat: 测试开发学习路径上线阶段 2 模块 3、4(26 章 / 120 小节)
- 新增 modules/s2-03-api-framework(接口自动化测试框架,13 章 / 60 小节) - 新增 modules/s2-04-ui-automation(UI 自动化:Playwright 与 Selenium,13 章 / 60 小节) - index.html 的 PAGES 登记 s2-2 / s2-3;modules-plan.json 完善这两个模块的导语 - 工具链修正:链接检查跳过 pre 内部(代码块里的 href 文本是被讲的文本,不是死链) - 工具链修正:模块目录页「约 N 千字」改为只数正文(剥掉侧栏目录树与代码块),全站口径统一 - README 更新进度表、阶段 2 模块表与目录结构 - 自检:check-chapter --strict 26 页通过、check-pages 163 页通过、check-glossary 162 页无漂移、portal 注册表通过
This commit is contained in:
@@ -64,8 +64,13 @@ stages.forEach((st, si) => {
|
||||
const title = plain(h2[1].replace(/<span class="n">\d+<\/span>/, ""));
|
||||
const sections = [...html.matchAll(/<h3 id="([^"]+)">([\s\S]*?)<\/h3>/g)]
|
||||
.map(x => ({ id: x[1], label: stripNo(plain(x[2])) }));
|
||||
// 字数口径:只统计中文汉字(代码与英文命令不计入「千字」,否则会被严重高估)
|
||||
const chars = (stripTags(html).match(/[\u4e00-\u9fff]/g) || []).length;
|
||||
// 字数口径:只统计中文汉字(代码与英文命令不计入「千字」,否则会被严重高估);
|
||||
// 侧栏目录树(build-nav.js 写入的整本书目录)与代码块(含中文注释)都不属于正文,先剥掉再数
|
||||
const prose = html
|
||||
.replace(/<script[\s\S]*?<\/script>/g, "")
|
||||
.replace(/<nav id="chapters">[\s\S]*?<\/nav>/g, "")
|
||||
.replace(/<pre[\s\S]*?<\/pre>/g, "");
|
||||
const chars = (stripTags(prose).match(/[\u4e00-\u9fff]/g) || []).length;
|
||||
return { file, title, sections, chars };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,8 +162,9 @@ for (const p of files) {
|
||||
// 残留占位
|
||||
if (/<!--\s*(MORE|TODO|PART\d|占位)/i.test(html)) problems.push(`${rel}: 有未完成的占位注释`);
|
||||
|
||||
// 链接与锚点
|
||||
const links = [...markup.matchAll(/href="(?!https?:|mailto:)([^"]+)"/g)].map(m => m[1]);
|
||||
// 链接与锚点(排除 <pre> 内部:代码块里的 href="/cart" 是「被讲的文本」,不是真链接)
|
||||
const linkScope = markup.replace(/<pre[\s\S]*?<\/pre>/g, "");
|
||||
const links = [...linkScope.matchAll(/href="(?!https?:|mailto:)([^"]+)"/g)].map(m => m[1]);
|
||||
for (const l of new Set(links)) {
|
||||
const [file, hash] = l.split("#");
|
||||
const target = file ? path.resolve(path.dirname(p), file) : path.resolve(p);
|
||||
|
||||
@@ -86,7 +86,9 @@ for (const p of pages) {
|
||||
if (o !== c) problems.push(`${rel}: <${t}> 开合不匹配 ${o}/${c}`);
|
||||
}
|
||||
|
||||
const links = [...markup.matchAll(/href="(?!https?:|mailto:)([^"]+)"/g)].map(m => m[1]);
|
||||
// 链接扫描要排除 <pre> 内部:代码块里的 href="/cart" 是「被讲的文本」,不是真链接
|
||||
const linkScope = markup.replace(/<pre[\s\S]*?<\/pre>/g, "");
|
||||
const links = [...linkScope.matchAll(/href="(?!https?:|mailto:)([^"]+)"/g)].map(m => m[1]);
|
||||
for (const l of new Set(links)) {
|
||||
const [file, hash] = l.split("#");
|
||||
const target = file ? path.resolve(path.dirname(p), file) : path.resolve(p);
|
||||
|
||||
@@ -122,14 +122,14 @@
|
||||
"title": "接口自动化测试框架",
|
||||
"sub": "分层设计 · Go 请求与断言 · 数据管理 · 报告与推送",
|
||||
"hours": "建议投入 32–42 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 2 的第 3 个模块,也是这一阶段的第一个大交付物。<br><br><b>学完之后你应该能:</b>用 Go 从零写出一个接口自动化框架:用例层、业务封装层与基础层职责分明,换一个环境只改配置不改代码。<br><br><b>学习方式:</b>边写边被真实用例折磨,框架的每个设计决定都要能回答「它替我解决了哪个重复劳动」。"
|
||||
"lead": "<b>模块定位:</b>阶段 2 的第 3 个模块,也是这一阶段的第一个大交付物。手工接口用例只能证明「这一次是对的」,只有跑得起来、看得懂、维护得住的框架,才能把它变成「每一次都是对的」。<br><br><b>学完之后你应该能:</b>用 Go 从零写出一个接口自动化框架:基础层(请求、配置、日志、断言)、业务封装层(API Object)、用例层职责分明;换一个环境只改配置不改代码;一轮 3 分钟内出报告、失败原因一眼可见;并留出接手 Python 存量脚本(requests 加 pytest)的适配入口。<br><br><b>学习方式:</b>边写边被真实用例折磨。每加一层抽象都要能回答「它替我消灭了哪个重复劳动」,答不出来就说明这一层是过度设计。"
|
||||
},
|
||||
{
|
||||
"dir": "s2-04-ui-automation",
|
||||
"title": "UI 自动化:Playwright 与 Selenium",
|
||||
"sub": "元素定位 · 等待机制 · PO 模式 · 稳定性治理",
|
||||
"hours": "建议投入 24–32 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 2 的第 4 个模块。UI 自动化是性价比争议最大的一层,学它的目的不是追求覆盖率,而是知道它在哪一段划得来、怎么让它连续跑十天不红。<br><br><b>学完之后你应该能:</b>用 Playwright 写出带自动等待、失败录屏与 trace 的冒烟用例,并能对每次失败给出归因。<br><br><b>学习方式:</b>先把定位与等待这两件事做对,再谈框架。选择器散落在用例里,写多少条都会烂掉。"
|
||||
"lead": "<b>模块定位:</b>阶段 2 的第 4 个模块,也是性价比争议最大的一层。UI 自动化的失败几乎都来自两件事:定位写歪了、等待写错了。学它的目的不是追求覆盖率,而是知道它在哪一段划得来、怎么让它连续跑十天不红。<br><br><b>学完之后你应该能:</b>用 Playwright 写出带自动等待、页面对象与失败录屏 / trace 的核心链路冒烟用例,并对每一次失败给出归因(真缺陷 / 环境问题 / 用例自身);能说清哪些用例值得上 UI 自动化、哪些必须留在人工。<br><br><b>学习方式:</b>先把定位与等待这两件事做对,再谈框架。选择器散落在用例里,写多少条都会烂掉;先跟开发谈成 data-testid 约定,再动手写第一个页面对象。"
|
||||
},
|
||||
{
|
||||
"dir": "s2-05-mobile-automation",
|
||||
|
||||
Reference in New Issue
Block a user