背景
承接 #61 (已關閉)的成果。Phase 1 完成 10 個 sub-issue、8 個 PR,從 283 tests 增加到 502 tests(+77%) 。
Phase 1 成果 :
目前覆蓋缺口
1. 程式碼.js Backend Wiring(607 行,coverage 0%)
現況 :logic 已用 DI mock 在 backend.test.js 間接測試,但 v8 instrument 追蹤不到(測的是 tests/lib/ 提取副本)。
風險 :GAS API 呼叫的 wiring(SpreadsheetApp, LockService, DriveApp)在重構時可能斷裂。
建議 :
2. .html Inline Script Wiring(~3555 行)
現況 :已提取 pure logic 到 tests/lib/(1573 行, 98.7% coverage),但 .html 檔中的 DOM wiring / event binding / render 呼叫未測。
缺口明細 :
檔案
行數
已提取 logic
殘餘 wiring
JavaScript.html
1442
stateHelpers, utilityFunctions, dataCollectionHelpers, interactionHelpers
global init, event listeners, API bridge
UI.js.html
787
uiHelpers
DOM render, classList, innerHTML
Interaction.js.html
761
interactionHelpers
drag-drop DOM events, click handlers
Modals.js.html
445
frontendUtils (partial)
modal DOM lifecycle, form validation
History.js.html
120
historyHelpers
undo/redo stack DOM binding
建議 :
3. 完全未測試的檔案
檔案
行數
說明
Elements.js.html
109
DOM element factory functions
Api.js.html
24
GAS↔frontend API bridge
Config.js.html
31
設定常數
建議 :
4. PHP 覆蓋缺口
現況 :33 tests covering functions.php(Phase 1 新增 filterScheduleByTags + jsonEncodeSafe)。
缺口 :
5. 覆蓋率基礎設施
6. 重構前 Smoke Test
本 issue 是 #61 (Phase 1) 的直接後續。Phase 1 建立了 DI extraction + test pattern 和基礎設施;Phase 2 補齊殘餘缺口,為大規模 architecture 重構提供完整安全網。
優先順序建議
P0(重構前必做) :Coverage threshold ratchet ([Security] Missing permission check in saveData backend API #5 ) + 程式碼.js wiring contract ([onboarding] classroombooking 接手 — 專案探索 + 建立開發 baseline #1 )
P1(重構時同步做) :.html wiring contracts ([infra] 開發流程對齊 talented-easyorder — 建立 CI / dispatch book / 測試鏈 / 開發基礎設施 #2 ) — 重構本身就會消除這些 inline scripts
P2(重構後做) :PHP 完整路徑 ([Security] Stored XSS via unescaped innerHTML interpolation #4 ) + E2E smoke test ([Code-Quality] Draft filtering boolean bug causes data leak in PHP viewer #6 )
P3(nice-to-have) :Elements/Api/Config 小檔 ([Security] Hardcoded AES encryption key in PHP scripts #3 ) + CI coverage gate ([Security] Missing permission check in saveData backend API #5 )
Retro Findings(from Phase 1)
供後續 session 參考:
Fresh worktree 需要 composer install(PHPUnit)
gh pr diff 截斷 >500 行 → 用 gh api pulls/<N>/files
DI extraction pattern 已成熟,可作 template
stateHelpers.fixtures.js 應列入 Required Reads(factory helper pattern)
Dispatch 帶 source line numbers 可加速 spike
背景
承接 #61(已關閉)的成果。Phase 1 完成 10 個 sub-issue、8 個 PR,從 283 tests 增加到 502 tests(+77%)。
Phase 1 成果:
目前覆蓋缺口
1.
程式碼.jsBackend Wiring(607 行,coverage 0%)現況:logic 已用 DI mock 在
backend.test.js間接測試,但 v8 instrument 追蹤不到(測的是tests/lib/提取副本)。風險:GAS API 呼叫的 wiring(SpreadsheetApp, LockService, DriveApp)在重構時可能斷裂。
建議:
程式碼.js的 exported functions 與tests/lib/提取版本的 signature 一致性(類似 [Test-Coverage] Module factory contracts + cross-module integration chains #93 factory contracts 的做法)程式碼.js改成 ES module,讓 vitest 直接 instrument2.
.htmlInline Script Wiring(~3555 行)現況:已提取 pure logic 到
tests/lib/(1573 行, 98.7% coverage),但.html檔中的 DOM wiring / event binding / render 呼叫未測。缺口明細:
.html加 wiring contract test(類似 factory contracts — 驗證 exported 方法清單)tests/setup/dom.js)3. 完全未測試的檔案
4. PHP 覆蓋缺口
現況:33 tests covering
functions.php(Phase 1 新增filterScheduleByTags+jsonEncodeSafe)。缺口:
index.phprouting logic($_GET參數處理、schedule 載入)generate_iframe.phpaccess control 完整路徑($allowed_emails驗證、POST 處理)5. 覆蓋率基礎設施
vitest.config.js從 25% 提升到 55%(防止 regression)validatejob 加入 coverage check6. 重構前 Smoke Test
index.php載入 → 回傳 200 + 正確 HTML 結構與 #61 的關係
本 issue 是 #61 (Phase 1) 的直接後續。Phase 1 建立了 DI extraction + test pattern 和基礎設施;Phase 2 補齊殘餘缺口,為大規模 architecture 重構提供完整安全網。
優先順序建議
Retro Findings(from Phase 1)
供後續 session 參考:
composer install(PHPUnit)gh pr diff截斷 >500 行 → 用gh api pulls/<N>/filesstateHelpers.fixtures.js應列入 Required Reads(factory helper pattern)