feat: 支持主列表选择每页条数 (#242)
This commit is contained in:
@@ -43,61 +43,67 @@ func assertRedirectQuery(t *testing.T, recorder *httptest.ResponseRecorder, want
|
||||
func Test列表写操作跳转保留筛选和页码(t *testing.T) {
|
||||
t.Run("蝦皮", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/shopee/save", url.Values{
|
||||
"q": {"店铺 A"}, "search_field": {"shop_name"}, "status": {"no_link"}, "unlinked": {"1"}, "page": {"2"},
|
||||
"q": {"店铺 A"}, "search_field": {"shop_name"}, "status": {"no_link"}, "unlinked": {"1"}, "page": {"2"}, "page_size": {"50"},
|
||||
})
|
||||
(&Handler{}).shopeeRedirect(context, "完成")
|
||||
assertRedirectQuery(t, recorder, "/shopee", map[string]string{
|
||||
"q": "店铺 A", "search_field": "shop_name", "status": "no_link", "unlinked": "1", "page": "2", "msg": "完成",
|
||||
"q": "店铺 A", "search_field": "shop_name", "status": "no_link", "unlinked": "1", "page": "2", "page_size": "50", "msg": "完成",
|
||||
})
|
||||
})
|
||||
t.Run("顺运宝", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/syb/associate-pdd", url.Values{
|
||||
"order_no": {"SYB-1"}, "shop": {"测试店铺"}, "stage": {"pdd_missing"}, "page": {"3"},
|
||||
"order_no": {"SYB-1"}, "shop": {"测试店铺"}, "stage": {"pdd_missing"}, "page": {"3"}, "page_size": {"100"},
|
||||
})
|
||||
(&Handler{}).sybRedirect(context, "完成")
|
||||
assertRedirectQuery(t, recorder, "/syb", map[string]string{
|
||||
"order_no": "SYB-1", "shop": "测试店铺", "stage": "pdd_missing", "page": "3", "msg": "完成",
|
||||
"order_no": "SYB-1", "shop": "测试店铺", "stage": "pdd_missing", "page": "3", "page_size": "100", "msg": "完成",
|
||||
})
|
||||
})
|
||||
t.Run("PDD", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/pdd/delete", url.Values{
|
||||
"q": {"737"}, "status": {"pending"}, "page": {"3"},
|
||||
"q": {"737"}, "status": {"pending"}, "page": {"3"}, "page_size": {"50"},
|
||||
})
|
||||
(&Handler{}).pddRedirect(context, "完成")
|
||||
assertRedirectQuery(t, recorder, "/pdd", map[string]string{
|
||||
"q": "737", "status": "pending", "page": "3", "msg": "完成",
|
||||
"q": "737", "status": "pending", "page": "3", "page_size": "50", "msg": "完成",
|
||||
})
|
||||
})
|
||||
t.Run("任务", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/tasks/delete", url.Values{
|
||||
"q": {"TASK"}, "type": {"collect"}, "status": {"pending"}, "creator": {"buyer-a"}, "page": {"2"},
|
||||
"q": {"TASK"}, "type": {"collect"}, "status": {"pending"}, "creator": {"buyer-a"}, "page": {"2"}, "page_size": {"100"},
|
||||
})
|
||||
context.Set(currentUserKey, &model.User{Role: model.RoleAdmin})
|
||||
(&Handler{}).taskRedirect(context, "完成")
|
||||
assertRedirectQuery(t, recorder, "/tasks", map[string]string{
|
||||
"q": "TASK", "type": "collect", "status": "pending", "creator": "buyer-a", "page": "2", "msg": "完成",
|
||||
"q": "TASK", "type": "collect", "status": "pending", "creator": "buyer-a", "page": "2", "page_size": "100", "msg": "完成",
|
||||
})
|
||||
})
|
||||
t.Run("客户端", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/clients/assign", url.Values{
|
||||
"name": {"仓库"}, "page": {"4"},
|
||||
"name": {"仓库"}, "page": {"4"}, "page_size": {"50"},
|
||||
})
|
||||
redirectClients(context, "完成", "")
|
||||
assertRedirectQuery(t, recorder, "/clients", map[string]string{
|
||||
"name": "仓库", "page": "4", "msg": "完成",
|
||||
"name": "仓库", "page": "4", "page_size": "50", "msg": "完成",
|
||||
})
|
||||
})
|
||||
t.Run("用户", func(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/users/status", url.Values{
|
||||
"q": {"buyer"}, "list_status": {"active"}, "page": {"5"},
|
||||
"q": {"buyer"}, "list_status": {"active"}, "page": {"5"}, "page_size": {"100"},
|
||||
})
|
||||
redirectUsers(context, "完成", "")
|
||||
assertRedirectQuery(t, recorder, "/users", map[string]string{
|
||||
"q": "buyer", "status": "active", "page": "5", "msg": "完成",
|
||||
"q": "buyer", "status": "active", "page": "5", "page_size": "100", "msg": "完成",
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func Test列表写操作跳转归一化非法每页条数(t *testing.T) {
|
||||
context, recorder := listPostContext(t, "/pdd/delete", url.Values{"page_size": {"9999"}})
|
||||
(&Handler{}).pddRedirect(context, "")
|
||||
assertRedirectQuery(t, recorder, "/pdd", map[string]string{"page_size": "20"})
|
||||
}
|
||||
|
||||
func Test蝦皮分页详情和状态条保留分类搜索(t *testing.T) {
|
||||
values := url.Values{
|
||||
"q": {"店铺 A"}, "search_field": {"shop_name"}, "status": {"has_link"}, "unlinked": {"1"},
|
||||
|
||||
Reference in New Issue
Block a user