feat: 顺运宝支持输入 PDD 商品 ID (#95)
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cmautobuy/admin/model"
|
||||
"cmautobuy/admin/repository"
|
||||
"cmautobuy/admin/service"
|
||||
)
|
||||
@@ -127,6 +128,33 @@ func TestMainPagesReturnOK(t *testing.T) {
|
||||
t.Error("顺运宝页面不应再显示旧的指定日期同步入口")
|
||||
}
|
||||
|
||||
_, err = repository.UpsertSybOrder(db, model.SybOrder{
|
||||
SybID: "SYB-PDD-ID-INPUT", OrderNo: "ORDER-PDD-ID-INPUT", Title: "输入测试商品",
|
||||
ProductSpec: "黑色,M", ShopeeGoodsID: "SP-PDD-ID-INPUT", Quantity: 1, SybData: `{}`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("准备顺运宝详情测试数据失败: %v", err)
|
||||
}
|
||||
detailRequest := httptest.NewRequest(http.MethodGet, "/syb/detail?id=SYB-PDD-ID-INPUT", nil)
|
||||
addAuth(detailRequest)
|
||||
detailResponse := httptest.NewRecorder()
|
||||
router.ServeHTTP(detailResponse, detailRequest)
|
||||
detailBody := detailResponse.Body.String()
|
||||
if detailResponse.Code != http.StatusOK {
|
||||
t.Fatalf("GET /syb/detail = %d,响应:%s", detailResponse.Code, detailBody)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"PDD 商品链接或商品 ID", `type="text" name="pdd_url"`,
|
||||
"6~24 位纯数字商品 ID",
|
||||
} {
|
||||
if !strings.Contains(detailBody, want) {
|
||||
t.Errorf("顺运宝详情输入区缺少 %q,响应:%s", want, detailBody)
|
||||
}
|
||||
}
|
||||
if strings.Contains(detailBody, `type="url" name="pdd_url"`) {
|
||||
t.Error("顺运宝详情不应继续使用会拦截纯数字的 URL 输入类型")
|
||||
}
|
||||
|
||||
partialRequest := httptest.NewRequest(http.MethodGet,
|
||||
"/syb/sync-history?history_page=1&order_no=ORDER-1&date_from=2026-08-01&date_to=2026-08-09", nil)
|
||||
addAuth(partialRequest)
|
||||
|
||||
Reference in New Issue
Block a user