feat(huya): 礼包名默认空白,改用「常用礼包」备选按钮
新建协作单以前会把「上次选的礼包」自动填进礼包名(localStorage huya.collab.lastGift)。连开几单同一个礼包是省事,但每开一单都顶着上一次的 选择,稍不留神就按错礼包建单;而且这个自动值会被草稿自动保存吃进去, 下次打开又「恢复」出来。 - 新建弹窗**不再预填礼包名**:删掉 lastGift 的读写,字段默认空白。 - 草稿恢复只带订单号 / 店铺 / CK / 截图 / 备注,礼包名留空; hasDraftContent() 也不再认「只有礼包名」的草稿(否则被旧逻辑自动填过的 那份草稿会一直弹「已恢复上次未提交的草稿」)。 - 新增 GET /external-orders/gifts/frequent:按台账里的使用次数排序 (次数相同看最近一次使用),新建与补资料弹窗在字段上方渲染最多 6 个按钮, 只显示**当前礼包缓存里还有的**(活动换 SID 后老礼包会整批下架)。 - 新增 5 例测试,并做了 3 次反向验证(去掉次数排序 / 改成升序 / 去掉空名过滤)。 补资料弹窗的初值仍是「这一单自己的礼包」,详情抽屉编辑也不动 —— 那不是 「上次选的」。
This commit is contained in:
@@ -2259,6 +2259,62 @@ class TestCollabActivityScopeSplit(TestCollabBase):
|
||||
assert row["last_verdict_message"]
|
||||
|
||||
|
||||
class TestCollabFrequentGifts(TestCollabBase):
|
||||
"""「常用礼包」:礼包名默认空白,只在上面留几个用得最多的备选(2026-10-18 用户要求)。
|
||||
|
||||
以前新建会自动带上「上次选的那个」礼包,每开一单都顶着上一次的选择、
|
||||
没注意就建错单。现在改成:**字段默认空白**,想要少点两下就点「常用礼包」按钮。
|
||||
"""
|
||||
|
||||
def test_orders_by_usage_count_then_recency(self):
|
||||
for index in range(3):
|
||||
self._create(order_no=f"FREQ-A{index}", gift_name="甲礼包")
|
||||
self._create(order_no="FREQ-B1", gift_name="乙礼包")
|
||||
self._create(order_no="FREQ-B2", gift_name="乙礼包")
|
||||
self._create(order_no="FREQ-C1", gift_name="丙礼包")
|
||||
|
||||
rows = collab.frequent_gift_names(self.db)
|
||||
|
||||
assert [row["name"] for row in rows] == ["甲礼包", "乙礼包", "丙礼包"]
|
||||
assert [row["used"] for row in rows] == [3, 2, 1]
|
||||
|
||||
def test_blank_gift_name_is_not_a_gift(self):
|
||||
self._create(order_no="FREQ-EMPTY1")
|
||||
self._create(order_no="FREQ-EMPTY2")
|
||||
self._create(order_no="FREQ-ONE", gift_name="真礼包")
|
||||
|
||||
rows = collab.frequent_gift_names(self.db)
|
||||
|
||||
assert [row["name"] for row in rows] == ["真礼包"]
|
||||
|
||||
def test_same_count_falls_back_to_most_recently_used(self):
|
||||
self._create(order_no="FREQ-R1", gift_name="老礼包")
|
||||
self._create(order_no="FREQ-R2", gift_name="新礼包")
|
||||
|
||||
rows = collab.frequent_gift_names(self.db)
|
||||
|
||||
assert [row["name"] for row in rows] == ["新礼包", "老礼包"]
|
||||
|
||||
def test_limit_caps_the_list(self):
|
||||
for index in range(4):
|
||||
self._create(order_no=f"FREQ-L{index}", gift_name="同次数礼包")
|
||||
|
||||
rows = collab.frequent_gift_names(self.db, limit=1)
|
||||
|
||||
assert [row["name"] for row in rows] == ["同次数礼包"]
|
||||
|
||||
def test_api_returns_name_and_used(self):
|
||||
self._create(order_no="FREQ-API1", gift_name="接口礼包")
|
||||
self._create(order_no="FREQ-API2", gift_name="接口礼包")
|
||||
|
||||
rows = collab_api.external_orders_frequent_gifts(
|
||||
limit=8, db=self.db, _current=self.user
|
||||
)
|
||||
|
||||
assert rows[0]["name"] == "接口礼包"
|
||||
assert rows[0]["used"] == 2
|
||||
|
||||
|
||||
class TestCollabCkExport(TestCollabBase):
|
||||
"""勾选导出 CK(写剪贴板):凭据外带要留痕,但审计里不许出现 CK 本体。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user