SBE Scenario 2: 過濾訂單狀態與日期
場景描述
店員使用過濾功能篩選訂單,支援狀態多選、日期範圍與金額區間過濾。
Given(前置條件)
系統狀態
- 當前日期: 2025-11-03
- 當前租戶:
ABC(ABC 花店) - 已登入用戶: 張店員 (ROLE_SALES)
測試資料
現有訂單(共 10 筆)
[
{
"orderId": "ABC-20251101-0001",
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251101-0002",
"status": "pending_confirmation",
"deliveryDate": "2025-11-06",
"totalAmount": 1800
},
{
"orderId": "ABC-20251102-0001",
"status": "confirmed",
"deliveryDate": "2025-11-07",
"totalAmount": 3500
},
{
"orderId": "ABC-20251102-0002",
"status": "confirmed",
"deliveryDate": "2025-11-08",
"totalAmount": 4200
},
{
"orderId": "ABC-20251103-0001",
"status": "in_production",
"deliveryDate": "2025-11-09",
"totalAmount": 1500
},
{
"orderId": "ABC-20251103-0002",
"status": "ready_for_delivery",
"deliveryDate": "2025-11-10",
"totalAmount": 2800
},
{
"orderId": "ABC-20251104-0001",
"status": "out_for_delivery",
"deliveryDate": "2025-11-04",
"totalAmount": 3200
},
{
"orderId": "ABC-20251104-0002",
"status": "delivered",
"deliveryDate": "2025-11-03",
"totalAmount": 2500
},
{
"orderId": "ABC-20251105-0001",
"status": "completed",
"deliveryDate": "2025-11-02",
"totalAmount": 5000
},
{
"orderId": "ABC-20251105-0002",
"status": "cancelled",
"deliveryDate": "2025-11-01",
"totalAmount": 1200
}
]
When(執行操作)
測試案例 1: 過濾訂單狀態(多選)
步驟 1: 展開過濾條件
- 店員點擊「過濾條件」區域(若摺疊)
- 系統展開過濾條件面板
步驟 2: 選擇狀態
- 店員在「狀態」下拉選單中勾選「待確認」和「已確認」
- 系統顯示已選擇的狀態標籤
步驟 3: 套用過濾
- 店員點擊「套用過濾」按鈕
Then(預期結果 - 測試案例 1)
API 請求
端點: GET /api/v1/orders?status=pending_confirmation,confirmed
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251101-0002",
"status": "pending_confirmation",
"deliveryDate": "2025-11-06",
"totalAmount": 1800
},
{
"orderId": "ABC-20251102-0001",
"status": "confirmed",
"deliveryDate": "2025-11-07",
"totalAmount": 3500
},
{
"orderId": "ABC-20251102-0002",
"status": "confirmed",
"deliveryDate": "2025-11-08",
"totalAmount": 4200
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 4,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 4 筆訂單(2 筆待確認 + 2 筆已確認)
- 顯示已套用的過濾條件標籤:
- 「狀態: 待確認」
- 「狀態: 已確認」
- 顯示「顯示 1-4 筆,共 4 筆訂單」
When(執行操作)
測試案例 2: 過濾配送日期範圍
步驟 1: 選擇日期範圍
- 店員在「配送日期」選擇器中選擇:
- 開始日期: 2025-11-01
- 結束日期: 2025-11-05
步驟 2: 套用過濾
- 店員點擊「套用過濾」按鈕
Then(預期結果 - 測試案例 2)
API 請求
端點: GET /api/v1/orders?deliveryDateFrom=2025-11-01&deliveryDateTo=2025-11-05
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251104-0001",
"status": "out_for_delivery",
"deliveryDate": "2025-11-04",
"totalAmount": 3200
},
{
"orderId": "ABC-20251104-0002",
"status": "delivered",
"deliveryDate": "2025-11-03",
"totalAmount": 2500
},
{
"orderId": "ABC-20251105-0001",
"status": "completed",
"deliveryDate": "2025-11-02",
"totalAmount": 5000
},
{
"orderId": "ABC-20251105-0002",
"status": "cancelled",
"deliveryDate": "2025-11-01",
"totalAmount": 1200
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 5,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 5 筆訂單(配送日期在 2025-11-01 至 2025-11-05 之間)
- 顯示已套用的過濾條件標籤:
- 「配送日期: 2025-11-01 至 2025-11-05」
When(執行操作)
測試案例 3: 過濾金額區間
步驟 1: 設定金額區間
- 店員在「金額區間」輸入:
- 最低金額: NT$2,000
- 最高金額: NT$3,500
步驟 2: 套用過濾
- 店員點擊「套用過濾」按鈕
Then(預期結果 - 測試案例 3)
API 請求
端點: GET /api/v1/orders?amountMin=2000&amountMax=3500
API 響應
{
"orders": [
{
"orderId": "ABC-20251101-0001",
"status": "pending_confirmation",
"deliveryDate": "2025-11-05",
"totalAmount": 2520
},
{
"orderId": "ABC-20251102-0001",
"status": "confirmed",
"deliveryDate": "2025-11-07",
"totalAmount": 3500
},
{
"orderId": "ABC-20251103-0002",
"status": "ready_for_delivery",
"deliveryDate": "2025-11-10",
"totalAmount": 2800
},
{
"orderId": "ABC-20251104-0001",
"status": "out_for_delivery",
"deliveryDate": "2025-11-04",
"totalAmount": 3200
},
{
"orderId": "ABC-20251104-0002",
"status": "delivered",
"deliveryDate": "2025-11-03",
"totalAmount": 2500
}
],
"pagination": {
"currentPage": 1,
"totalPages": 1,
"totalItems": 5,
"itemsPerPage": 20
}
}
UI 顯示
- 顯示 5 筆訂單(金額在 NT$2,000 至 NT$3,500 之間)
- 顯示已套用的過濾條件標籤:
- 「金額: NT$2,000 至 NT$3,500」
When(執行操作)
測試案例 4: 清空過濾條件
步驟 1: 清空過濾
- 店員點擊「清空過濾」按鈕
Then(預期結果 - 測試案例 4)
API 請求
端點: GET /api/v1/orders(無過濾參數)
UI 行為
- 所有過濾條件標籤消失
- 訂單列表顯示所有 10 筆訂單
- 自動跳回第 1 頁
驗證檢查清單
過濾功能
- 支援狀態多選(OR 邏輯)
- 支援日期範圍過濾(閉區間)
- 支援金額區間過濾(閉區間)
- 已套用的過濾條件顯示為標籤
- 清空過濾功能正常
UI 互動
- 過濾條件面板展開/摺疊
- 套用過濾按鈕功能正常
- 清空過濾按鈕功能正常
- 過濾後自動跳回第 1 頁
最後更新: 2025-11-03