fix: 简化真实采购创建并恢复客户端选择 (#112)
This commit is contained in:
+25
-3
@@ -128,6 +128,18 @@ func TestMainPagesReturnOK(t *testing.T) {
|
||||
if usersResponse.Code != http.StatusForbidden {
|
||||
t.Fatalf("采购员 GET /users = %d,期望 403", usersResponse.Code)
|
||||
}
|
||||
for _, client := range []model.Client{
|
||||
{ClientID: "CLIENT-LIVE", Name: "真实采购机", Capabilities: `{"purchase_mode":"live"}`},
|
||||
{ClientID: "CLIENT-DRY", Name: "未授权机", Capabilities: `{"purchase_mode":"dry_run"}`},
|
||||
} {
|
||||
if err := service.RegisterClient(db, client, true); err != nil {
|
||||
t.Fatalf("准备采购客户端失败: %v", err)
|
||||
}
|
||||
}
|
||||
if _, err := db.Exec(`UPDATE clients SET last_seen_at=? WHERE client_id=?`,
|
||||
time.Now().UTC().Add(-time.Hour).Format(model.TimeLayout), "CLIENT-LIVE"); err != nil {
|
||||
t.Fatalf("准备离线 live 客户端失败: %v", err)
|
||||
}
|
||||
|
||||
sybRequest := httptest.NewRequest(http.MethodGet, "/syb", nil)
|
||||
addAuth(sybRequest)
|
||||
@@ -139,17 +151,27 @@ func TestMainPagesReturnOK(t *testing.T) {
|
||||
`name="date_from"`, `name="date_to"`,
|
||||
`name="stage"`, "处理阶段", "下一步", `data-detail-url=`,
|
||||
"按顺运宝货运单创建日期(UTC+8)同步",
|
||||
"真实下单安全确认", "确认创建真实采购任务",
|
||||
`name="live_acknowledged"`, `name="live_confirmation"`,
|
||||
"创建真实采购任务", "未启用真实采购",
|
||||
} {
|
||||
if !strings.Contains(sybResponse.Body.String(), want) {
|
||||
t.Errorf("顺运宝页面缺少 %q", want)
|
||||
}
|
||||
}
|
||||
for _, want := range []string{
|
||||
`value="CLIENT-LIVE" selected`,
|
||||
`value="CLIENT-DRY" disabled`,
|
||||
"未授权机(CLIENT-DRY) — 未启用真实采购",
|
||||
"离线客户端也可以提前指派",
|
||||
} {
|
||||
if !strings.Contains(sybResponse.Body.String(), want) {
|
||||
t.Errorf("采购客户端候选缺少 %q", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(sybResponse.Body.String(), "指定日期同步") {
|
||||
t.Error("顺运宝页面不应再显示旧的指定日期同步入口")
|
||||
}
|
||||
for _, removed := range []string{`name="execution_mode"`, "采购演练", "仅演练", "支持真实下单"} {
|
||||
for _, removed := range []string{`name="execution_mode"`, "采购演练", "仅演练", "支持真实下单",
|
||||
"真实下单安全确认", `name="live_acknowledged"`, `name="live_confirmation"`, `data-confirm-submit=`} {
|
||||
if strings.Contains(sybResponse.Body.String(), removed) {
|
||||
t.Errorf("固定真实采购弹窗不应显示 %q", removed)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user