Files
apskel-pos-backend/internal/router/router_test.go
T
efrilmandClaude Opus 5.5 2c9753fae7 feat(loyalty): remove paying with EnakPoint
EnakPoint can only be redeemed for vouchers now: it can no longer pay for
orders and is never cashed out (docs/enakgame-prd.md §3.2, EG-001,
EG-002). No order was ever paid with EnakPoint, so there is no data to
move.

Removed:
- POST /customer/wallet/payment-code, POST /customer/orders/:id/pay-with-points
  and GET /orders/:id/point-payment/preview, with their processors,
  repositories, services, handlers and tests.
- The point payment method type: paying, splitting and refunding with it,
  the outlet filter on the method list, and the system-method guard.
- points and payment_code on CreatePayment; points_used and point_value
  on payments; accepts_point_payment on the customer outlets.
- The outlet point_payment settings. A PUT that still sends them is
  rejected as an unknown field.
- The EnakPoint split in the payment method analytics.
- PAYMENT and PAYMENT_REFUND from the wallet type rules. Tests that used
  them as a generic EnakPoint debit use REWARD_REDEEM.
- The EnakPoint-paid part from the earning basis, which is
  subtotal − discount again.

Migration 000102 drops the trigger, the point methods and their index,
the payments columns, and the outlet settings, and restores the method
type CHECK without point. payments.payment_method_id is ON DELETE
RESTRICT, so it fails rather than lose a payment made with EnakPoint.

The integration docs list the removed endpoints and fields, and the
EnakPoint & EnakCoin PRD and tasks note what is superseded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:48:29 +07:00

69 lines
2.3 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",
"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/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)
}
// EnakPoint cannot pay for orders (docs/enakgame-prd.md §3.2).
for _, gone := range []string{
"POST /api/v1/customer/wallet/payment-code",
"GET /api/v1/orders/:id/point-payment/preview",
"POST /api/v1/customer/orders/:id/pay-with-points",
} {
assert.False(t, registered[gone], gone)
}
}