fix(admin): 評價降序時沒評分的司機被排到最前面 - #24
Merged
Merged
Conversation
司機管理頁的「評價」欄升序正確(低分在前、沒評分墊底),但**點第二次切降序後, 沒評分的司機浮到最頂端**:實測得到「新司機, 高分司機, 低分司機」。 機制:antd 做降序的方式是**把 sorter 的比較結果整個反轉**, 所以「沒評分回 1 讓它沉底」的特例也跟著反轉成 -1,變成浮頂。 原本的測試只點一次(升序)就斷言,測不到這條。 修法:用 antd 傳給 sorter 的第三個參數 sortOrder,降序時把特例的正負號跟著翻, 讓「沒評分」在兩個方向都沉底。0 則不代表差,不管升序降序都不該混進名單頭。 驗收:tsc 無誤、oxlint 乾淨、vitest 124 passed(新增 1 案專測降序)。 Co-Authored-By: Claude Opus 4.8 <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.
症狀
司機管理頁「評價」欄升序正確(低分在前、沒評分墊底),但點第二次切降序後,沒評分的司機浮到最頂端:
機制
antd 做降序的方式是把 sorter 的比較結果整個反轉。我的特例:
在降序時被反轉成
-1→ 沉底變浮頂。「0 則不代表差、不該混進名單頭」這個意圖只在升序成立。為什麼原本的測試沒抓到
上一版的排序測試只點一次表頭(升序)就斷言,從未驗證降序。
這是我自己寫的測試留下的盲區——斷言了想要的那一半。
修法
用 antd 傳給 sorter 的第三個參數
sortOrder,降序時把特例的正負號跟著翻:驗收
tsc無誤、oxlint乾淨、vitest124 passed(新增 1 案專測降序:連點兩次表頭)。expected ['新司機','高分司機','低分司機'] to deeply equal ['高分司機','低分司機','新司機']),修正後綠。🤖 Generated with Claude Code