Adds what the customer sees of expiry (docs/prd-point-coin.md F6, F12, PC-504). GET /customer/wallet/expiring lists everything that will expire, per currency and day, soonest first. GET /customer/wallet already had the nearest expiry per currency. The expiry job now also sends reminders, with the settings of note N4 as decided: once, reminder_days before (7 by default, 0 for none), per currency. A customer gets one FCM push per currency and expiry day, however many lots make it up: "150 EnakPoint akan kedaluwarsa pada 31 Okt 2026. Pakai sebelum hangus.", with type WALLET_EXPIRING, the currency, amount and expiry_date in its data. Reminders cover whatever falls within the window, so a run that was missed catches up rather than skipping a day. Migration 000097 adds wallet_expiry_reminders, one row per customer, currency and expiry day. The row is written before the push is sent, so several instances of the job or a restart never remind twice; a push that then fails is logged and not retried. Lots that expire later on the same day as an earlier reminder are not reminded of again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.1 KiB
Go
60 lines
2.1 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/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)
|
|
}
|
|
}
|