Add visitor phone lookup flow

This commit is contained in:
wangxuming
2026-07-15 11:26:37 +08:00
parent 331e30894b
commit 7f751bebae
21 changed files with 971 additions and 104 deletions

View File

@@ -2,10 +2,12 @@ package httpapi
import (
"encoding/json"
"net/http/httptest"
"strings"
"testing"
"time"
"calllinesystem/server/internal/config"
"calllinesystem/server/internal/model"
)
@@ -28,3 +30,27 @@ func TestDisplayBatchDTOCannotSerializePersonalFields(t *testing.T) {
t.Fatalf("public ticket number missing: %s", encoded)
}
}
func TestPublicPhoneLookupIsDisabledInProduction(t *testing.T) {
server := &Server{config: config.Config{Environment: "production"}}
recorder := httptest.NewRecorder()
request := httptest.NewRequest("POST", "/api/public/status/search", strings.NewReader(`{"phone":"13800138000"}`))
server.publicStatusByPhone(recorder, request)
if recorder.Code != 404 {
t.Fatalf("production phone lookup status = %d, want 404", recorder.Code)
}
}
func TestPublicPhoneLookupRejectsInvalidPhone(t *testing.T) {
server := &Server{config: config.Config{Environment: "development"}}
recorder := httptest.NewRecorder()
request := httptest.NewRequest("POST", "/api/public/status/search", strings.NewReader(`{"phone":"123"}`))
server.publicStatusByPhone(recorder, request)
if recorder.Code != 422 {
t.Fatalf("invalid phone lookup status = %d, want 422", recorder.Code)
}
}