From 766b5b7dbd89fda4b96f637511ed2e428435757c Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Thu, 25 Jun 2026 14:12:48 +0100 Subject: [PATCH] fix(vat): resolve non-deterministic ORDER BY in TestVAT_ToggleLifecycle 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). --- backend/handlers/payments/vat_test.go | 11 +++++++++-- frontend/eslint.config.js | 17 ++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/backend/handlers/payments/vat_test.go b/backend/handlers/payments/vat_test.go index eb42c01..18dae13 100644 --- a/backend/handlers/payments/vat_test.go +++ b/backend/handlers/payments/vat_test.go @@ -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) } diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index d336f76..65cc549 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -27,16 +27,16 @@ export default defineConfig( 'no-undef': 'off', // Allow underscore prefix for unused variables '@typescript-eslint/no-unused-vars': [ - 'warn', + 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' } ], - '@typescript-eslint/no-explicit-any': 'warn', - 'no-useless-escape': 'warn', - 'no-empty': 'warn' + '@typescript-eslint/no-explicit-any': 'error', + 'no-useless-escape': 'error', + 'no-empty': 'error' } }, { @@ -50,15 +50,6 @@ export default defineConfig( } }, rules: { - 'svelte/no-navigation-without-resolve': 'warn', - 'svelte/no-useless-mustaches': 'warn', - 'svelte/no-unused-props': 'warn', - 'svelte/no-dom-manipulating': 'warn', - 'svelte/no-unnecessary-state-wrap': 'warn', - 'svelte/prefer-writable-derived': 'warn', - 'svelte/prefer-svelte-reactivity': 'warn', - 'svelte/valid-prop-names-in-kit-pages': 'warn', - 'svelte/require-each-key': 'warn' } } );