feat: 统一顺运宝日期同步并记录历史 (#59)
This commit is contained in:
@@ -47,7 +47,7 @@ func TestSybRedirectLogin_保留指定日期并打开登录弹窗(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSybRedirectRange_保留输入并重新打开日期弹窗(t *testing.T) {
|
||||
func TestSybRedirectRange_保留输入并显示日期错误(t *testing.T) {
|
||||
context, recorder := sybPostContext(t, url.Values{
|
||||
"date_from": {"2026-08-09"},
|
||||
"date_to": {"2026-08-01"},
|
||||
@@ -59,10 +59,43 @@ func TestSybRedirectRange_保留输入并重新打开日期弹窗(t *testing.T)
|
||||
t.Fatalf("解析 Location 失败: %v", err)
|
||||
}
|
||||
query := location.Query()
|
||||
if query.Get("range_sync") != "1" || query.Get("range_error") == "" {
|
||||
t.Fatalf("日期错误后应该重开弹窗并显示错误,Location=%s", location.String())
|
||||
if query.Get("range_error") == "" {
|
||||
t.Fatalf("日期错误后应该显示错误,Location=%s", location.String())
|
||||
}
|
||||
if query.Get("date_from") != "2026-08-09" || query.Get("date_to") != "2026-08-01" {
|
||||
t.Fatalf("日期错误后应该保留两端输入,Location=%s", location.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSybRedirectAfterStart_清除本次日期范围(t *testing.T) {
|
||||
context, recorder := sybPostContext(t, url.Values{
|
||||
"order_no": {"ORDER-1"}, "date_from": {"2026-08-01"}, "date_to": {"2026-08-09"},
|
||||
})
|
||||
(&Handler{}).sybRedirectAfterStart(context, "同步已开始")
|
||||
location, err := url.Parse(recorder.Header().Get("Location"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
query := location.Query()
|
||||
if query.Get("order_no") != "ORDER-1" || query.Get("msg") != "同步已开始" {
|
||||
t.Fatalf("跳转应保留搜索和提示: %s", location.String())
|
||||
}
|
||||
if query.Has("date_from") || query.Has("date_to") {
|
||||
t.Fatalf("启动后不应保留旧日期,否则下一段会误重复: %s", location.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSybHistoryPagination_保留筛选并重开弹窗(t *testing.T) {
|
||||
view := sybHistoryPagination(2, 3, "ORDER-1", "2026-08-01", "2026-08-09")
|
||||
for _, raw := range []string{view.FirstURL, view.PrevURL, view.NextURL, view.LastURL} {
|
||||
location, err := url.Parse(raw)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
query := location.Query()
|
||||
if query.Get("history") != "1" || query.Get("order_no") != "ORDER-1" ||
|
||||
query.Get("date_from") != "2026-08-01" || query.Get("date_to") != "2026-08-09" {
|
||||
t.Fatalf("同步记录翻页链接丢失页面状态: %s", raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user