test(admin): 補齊四個「做了沒勾」功能的測試+回填 TODO 勾選 - #25
Merged
Conversation
app 的待辦清單已無不需外部資源的項目,改盤點 admin 的 docs/TODO.md。 四個 [ ](登出確認、地圖點擊司機連動、司機搜尋/篩選、司機詳情頁) **其實全部早就實作了**,只是沒回填。 「做了沒勾」的真正代價不是文件難讀,而是**沒人知道它該有測試**: - DriverDetailPage 連測試檔都不存在 - FleetPage popup 的「查看司機」連結沒被覆蓋 - AppLayout 的登出確認沒被覆蓋 - DriversPage 只測過車種篩選,關鍵字搜尋沒測(placeholder 承諾姓名/電話/車牌三路) 補 10 個測試(124 → 134 passed,26 檔): - DriverDetailPage 4 案(明細/直接進入自行取資料/查不到該 id/麵包屑) - FleetPage 3 案(popup 帶連結與正確 id 且保留 href/點連結走 SPA 導向/ 點其他位置不導向)——**兩案做過反向驗證**:拿掉 popup 連結或拿掉委派 handler, 各自只讓對應那一案 FAIL - AppLayout 2 案(取消不清 session/確認才清) - DriversPage 1 案(姓名/電話/車牌大小寫不敏感三路都命中) 踩到的坑:**antd 對「剛好兩個中文字」的按鈕會插入空格**(DOM 實際是「登 出」「取 消」), getByRole name 精確比對查不到;確認框標題同時出現在 ant-modal-title 與 ant-modal-confirm-title 兩處,getByText 會 Found multiple。已在測試裡註明。 驗收:`npm test` 134 passed、`npm run lint` 乾淨、`tsc --noEmit` exit 0。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
thothawei
added a commit
that referenced
this pull request
Jul 28, 2026
2026-07-28 補上四個「做了沒勾」功能的測試後(PR #25),數字從 25 檔 123 tests 變成 26 檔 134 tests,README 沒同步。 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
為什麼有這個 PR
app 的待辦清單已經沒有不需外部資源的項目(A2 缺 Firebase、A5 缺實機,兩者當日實查都仍不在),所以改盤點 admin 自己的
docs/TODO.md——三個 repo 各有一份,我先前只讀 app 那份。結果:四個
[ ]全部早就實作了,只是沒回填。AppLayout用App.useApp()的modal.confirm(「確定要登出?」),確認才clearSession()+導向/login[data-driver-link])走 SPA 導向/drivers/:id,href保留當 JS 失效退路Input.Search「搜尋姓名/電話/車牌」(比原規劃多了車牌)+狀態下拉(含「待審核」)+車種下拉(含「未填車輛」)DriverDetailPage+ 路由/drivers/:id;後端確實沒有單筆司機 GET,所以照原規劃退路走列表資料「做了沒勾」的真正代價
不是文件難讀,而是沒人知道它該有測試。這四項裡有三項先前完全沒有測試覆蓋:司機詳情頁連測試檔都不存在,popup 連結與登出確認也都沒被碰過;DriversPage 只測過車種篩選,關鍵字搜尋沒測——而搜尋框的 placeholder 承諾了姓名/電話/車牌三路。
所以這個 PR 的主體是測試,不是改勾選:補 10 個案,124 → 134 passed(26 檔)。
DriverDetailPage.test.tsx(新檔,4 案):明細顯示/直接開網址會自行取資料/查不到該 id 顯示「找不到司機 #999」並留兩處返回/麵包屑回列表FleetPage.test.tsx(3 案):popup 帶連結與正確 driver id 且保留href/點連結走 SPA 導向/點地圖其他位置不導向(負向對照)AppLayout.test.tsx(2 案):按取消什麼都不該發生(只驗確認路徑會讓誤觸防護形同虛設)/確認後才清 sessionDriversPage.test.tsx(1 案):姓名/電話/車牌大小寫不敏感三路都命中反向驗證
FleetPage 兩案各自暫時破壞來源再跑(改動已還原,
git diff為空):container.addEventListener('click', onClick)踩到的坑(已寫進測試註解)
antd 對「剛好兩個中文字」的按鈕會插入空格——DOM 實際是「登 出」「取 消」,
getByRole('button', { name: '登出' })精確比對查不到,要用/登\s*出/。另外確認框標題同時出現在ant-modal-title與ant-modal-confirm-title兩處,getByText會 Found multiple,改成對dialog斷言toHaveTextContent。驗收
npm test134 passed(原 124)、npm run lint乾淨、tsc --noEmitexit 0。沒有動任何產品程式碼(FleetPage.tsx的反向驗證改動已還原)。🤖 Generated with Claude Code