Adds GET /customer/orders and GET /customer/orders/:id for the customer app: the orders linked to the logged-in customer across their organization's outlets, newest first, paginated (limit 1-100, default 20). The list shows the order number, outlet, type, status, total, item count, void/refund flags and the EnakPoint and EnakCoin it earned. The detail adds the amounts, the items with product and variant names, weight and unit for weighed lines, modifiers and notes, and the payments with the method and, for EnakPoint, the points used. Costs, cashier and other internal fields are left out. Another customer's order answers 404 like one that does not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.2 KiB
Go
63 lines
2.2 KiB
Go
package router
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"apskel-pos-be/config"
|
|
"apskel-pos-be/internal/middleware"
|
|
)
|
|
|
|
// Gin panics at startup when two routes disagree on a path parameter's name at the
|
|
// same position (say /outlets/:id/x next to /outlets/:outlet_id/y). Registering every
|
|
// route here catches that in a test instead of on deploy. Handlers are nil: nothing is
|
|
// served, only registered.
|
|
func TestAllRoutesRegister(t *testing.T) {
|
|
r := &Router{
|
|
config: &config.Config{},
|
|
authMiddleware: middleware.NewAuthMiddleware(nil),
|
|
customerAuthMiddleware: middleware.NewCustomerAuthMiddleware("test"),
|
|
}
|
|
engine := r.Init()
|
|
|
|
registered := map[string]bool{}
|
|
for _, route := range engine.Routes() {
|
|
registered[route.Method+" "+route.Path] = true
|
|
}
|
|
for _, want := range []string{
|
|
"GET /api/v1/customer/wallet",
|
|
"GET /api/v1/customer/wallet/transactions",
|
|
"GET /api/v1/customer/wallet/expiring",
|
|
"GET /api/v1/marketing/customers/:id/wallet",
|
|
"POST /api/v1/marketing/customers/:id/wallet/adjust",
|
|
"GET /api/v1/marketing/wallet-transactions/:id/trace",
|
|
"GET /api/v1/outlets/:outlet_id/loyalty-settings",
|
|
"PUT /api/v1/outlets/:outlet_id/loyalty-settings",
|
|
"GET /api/v1/marketing/loyalty-settings",
|
|
"PUT /api/v1/marketing/loyalty-settings",
|
|
"GET /api/v1/marketing/loyalty-settings/history",
|
|
"POST /api/v1/customer/wallet/payment-code",
|
|
"GET /api/v1/customer/wallet/exchange/preview",
|
|
"POST /api/v1/customer/wallet/exchange",
|
|
"GET /api/v1/customer/wallet/transfer/recipient",
|
|
"POST /api/v1/customer/wallet/transfer",
|
|
"PUT /api/v1/customer/devices",
|
|
"DELETE /api/v1/customer/devices/:device_id",
|
|
"GET /api/v1/customer/outlets",
|
|
"GET /api/v1/customer/orders",
|
|
"GET /api/v1/customer/orders/:id",
|
|
"GET /api/v1/orders/:id/point-payment/preview",
|
|
"POST /api/v1/customer/orders/:id/pay-with-points",
|
|
"GET /api/v1/customer/pin/status",
|
|
"POST /api/v1/customer/pin/otp",
|
|
"POST /api/v1/customer/pin",
|
|
"PUT /api/v1/customer/pin",
|
|
"POST /api/v1/customer/pin/reset",
|
|
"DELETE /api/v1/marketing/customers/:id/pin",
|
|
"GET /api/v1/marketing/customers/:id/security-events",
|
|
} {
|
|
assert.True(t, registered[want], want)
|
|
}
|
|
}
|