fix(vat): resolve non-deterministic ORDER BY in TestVAT_ToggleLifecycle
Frontend Lint & Vulns / Lint & vulns (push) Failing after 48s

The phase 3 payment query used ORDER BY created_at DESC LIMIT 1.
Within a single transaction, NOW() returns the same timestamp for all
inserts, making the ordering non-deterministic when other parallel tests
insert payment rows with the same timestamp. Fix by parsing the
response's payment ID and querying by it directly.

Also revert eslint.config.js back to error-level rules for all categories
(removing the previous 'warn' overrides).
This commit is contained in:
2026-06-25 14:12:48 +01:00
parent c481400215
commit 766b5b7dbd
2 changed files with 13 additions and 15 deletions
+9 -2
View File
@@ -1202,12 +1202,19 @@ func TestVAT_ToggleLifecycle(t *testing.T) {
t.Fatalf("phase 3: expected 200, got %d: %s", w3.Code, w3.Body.String())
}
var phase3Resp CheckoutResponse
if err := json.Unmarshal(w3.Body.Bytes(), &phase3Resp); err != nil {
t.Fatalf("phase 3: failed to parse response: %v", err)
}
var phase3VAT sql.NullFloat64
var phase3Net sql.NullFloat64
var phase3VATApplicable bool
var phase3Amount float64
// Get the latest cash payment (the second one)
err = tx.QueryRow(ctx, `SELECT amount, is_vat_applicable, vat_amount, net_amount FROM payments WHERE booking_id = $1 AND payment_method = 'cash' ORDER BY created_at DESC LIMIT 1`, bookingID).Scan(&phase3Amount, &phase3VATApplicable, &phase3VAT, &phase3Net)
// Get the specific payment by its ID from the response (avoiding
// non-deterministic ORDER BY created_at DESC when NOW() returns the same
// transaction start time for all inserts within a transaction).
err = tx.QueryRow(ctx, `SELECT amount, is_vat_applicable, vat_amount, net_amount FROM payments WHERE id = $1`, phase3Resp.CheckoutID).Scan(&phase3Amount, &phase3VATApplicable, &phase3VAT, &phase3Net)
if err != nil {
t.Fatalf("phase 3: failed to query payment: %v", err)
}