SBE Scenario 1: 搜尋訂單編號與客戶姓名
場景描述
店員使用搜尋功能快速查找訂單,支援訂單編號與客戶姓名的模糊搜尋。
Given(前置條件)
系統狀態
- 當前日期: 2025-11-03
- 當前租戶:
ABC(ABC 花店) - 已登入用戶: 張店員 (ROLE_SALES)
測試資料
現有訂單
[
{
"orderId": "ABC-20251101-0001",
"orderNumber": "ABC-20251101-0001",
"customer": {
"id": "cust-001",
"name": "李大華",
"phone": "0912-345-678"
},
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251101-0002",
"orderNumber": "ABC-20251101-0002",
"customer": {
"id": "cust-002",
"name": "李小明",
"phone": "0923-456-789"
},
"status": "confirmed",
"deliveryDate": "2025-11-06",
"totalAmount": 1800
},
{
"orderId": "ABC-20251102-0001",
"orderNumber": "ABC-20251102-0001",
"customer": {
"id": "cust-003",
"name": "王小花",
"phone": "0934-567-890"
},
"status": "in_production",
"deliveryDate": "2025-11-07",
"totalAmount": 3500
}
]
When(執行操作)
測試案例 1: 搜尋訂單編號(部分匹配)
步驟 1: 進入訂單列表頁
- 店員進入訂單管理頁面
- 系統顯示所有訂單(共 3 筆)
步驟 2: 搜尋訂單
- 店員在搜尋框輸入「20251101」
- 系統在輸入停止 500ms 後自動執行搜尋
Then(預期結果 - 測試案例 1)
API 請求
端點: GET /api/v1/orders?search=20251101
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"orderNumber": "ABC-20251101-0001",
"customer": {
"id": "cust-001",
"name": "李大華",
"phone": "0912-345-678"
},
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251101-0002",
"orderNumber": "ABC-20251101-0002",
"customer": {
"id": "cust-002",
"name": "李小明",
"phone": "0923-456-789"
},
"status": "confirmed",
"deliveryDate": "2025-11-06",
"totalAmount": 1800
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 2,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 2 筆訂單(ABC-20251101-0001, ABC-20251101-0002)
- 搜尋關鍵字「20251101」在訂單編號中高亮顯示
- 顯示「顯示 1-2 筆,共 2 筆訂單」
When(執行操作)
測試案例 2: 搜尋客戶姓名(部分匹配)
步驟 1: 清空搜尋
- 店員點擊搜尋框右側的「×」按鈕
- 系統清空搜尋並顯示所有訂單
步驟 2: 搜尋客戶
- 店員在搜尋框輸入「李」
- 系統在輸入停止 500ms 後自動執行搜尋
Then(預期結果 - 測試案例 2)
API 請求
端點: GET /api/v1/orders?search=李
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"orderNumber": "ABC-20251101-0001",
"customer": {
"id": "cust-001",
"name": "李大華",
"phone": "0912-345-678"
},
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251101-0002",
"orderNumber": "ABC-20251101-0002",
"customer": {
"id": "cust-002",
"name": "李小明",
"phone": "0923-456-789"
},
"status": "confirmed",
"deliveryDate": "2025-11-06",
"totalAmount": 1800
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 2,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 2 筆訂單(客戶為「李大華」和「李小明」)
- 客戶姓名中的「李」字高亮顯示
When(執行操作)
測試案例 3: 搜尋電話號碼(忽略連字符)
步驟 1: 搜尋電話
- 店員在搜尋框輸入「0912」或「0912345678」
- 系統在輸入停止 500ms 後自動執行搜尋
Then(預期結果 - 測試案例 3)
API 請求
端點: GET /api/v1/orders?search=0912
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"orderNumber": "ABC-20251101-0001",
"customer": {
"id": "cust-001",
"name": "李大華",
"phone": "0912-345-678"
},
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 1,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 1 筆訂單(客戶電話為「0912-345-678」)
- 電話號碼中的「0912」高亮顯示
驗證檢查清單
搜尋功能
- 支援訂單編號搜尋(部分匹配)
- 支援客戶姓名搜尋(部分匹配)
- 支援電話號碼搜尋(忽略連字符)
- 搜尋結果正確顯示
- 搜尋關鍵字高亮顯示
防抖功能
- 輸入停止 500ms 後執行搜尋
- 避免過度 API 請求
UI 互動
- 搜尋框顯示「×」清空按鈕
- 點擊清空按鈕清除搜尋
- 顯示搜尋結果數量
錯誤場景測試
錯誤場景 1: 無匹配結果
- 搜尋關鍵字: 「不存在的訂單」
- 預期結果:
- API 返回空陣列
- UI 顯示「找不到符合條件的訂單」
- 顯示「顯示 0 筆訂單」
最後更新: 2025-11-03