From 43b250e157a40d188ff98e8a0a0f8ea2fd2004d8 Mon Sep 17 00:00:00 2001 From: counterweight Date: Sat, 27 Dec 2025 12:52:43 +0100 Subject: [PATCH] small fixes --- backend/tests/test_exchange.py | 10 ++++++++-- frontend/e2e/admin-pricing.spec.ts | 8 ++++---- frontend/e2e/availability.spec.ts | 7 ++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/tests/test_exchange.py b/backend/tests/test_exchange.py index 41d82a0..e2dfa09 100644 --- a/backend/tests/test_exchange.py +++ b/backend/tests/test_exchange.py @@ -17,6 +17,7 @@ from models import ( TradeDirection, ) from price_fetcher import PAIR_BTC_EUR, SOURCE_BITFINEX +from shared_constants import EUR_TRADE_INCREMENT def tomorrow() -> date: @@ -213,7 +214,7 @@ class TestExchangePriceEndpoint: assert config["eur_max_buy"] == 300000 assert config["eur_min_sell"] == 12000 assert config["eur_max_sell"] == 320000 - assert config["eur_increment"] == 20 + assert config["eur_increment"] == EUR_TRADE_INCREMENT assert config["premium_buy"] == 5 assert config["premium_sell"] == 6 @@ -659,6 +660,11 @@ class TestCreateExchange: """EUR amount not a multiple of increment is rejected.""" target_date = await setup_availability_and_price(client_factory, admin_user) + # Calculate an amount that's not a multiple of the increment + # Use a valid base amount (multiple of increment) and add a small offset + base_amount = 11500 # €115.00 + invalid_amount = base_amount + (EUR_TRADE_INCREMENT - 1) # Not a multiple + with mock_price_fetcher(20000.0): async with client_factory.create(cookies=regular_user["cookies"]) as client: response = await client.post( @@ -667,7 +673,7 @@ class TestCreateExchange: "slot_start": f"{target_date}T09:00:00Z", "direction": "buy", "bitcoin_transfer_method": "onchain", - "eur_amount": 11500, # €115, not multiple of €20 + "eur_amount": invalid_amount, }, ) diff --git a/frontend/e2e/admin-pricing.spec.ts b/frontend/e2e/admin-pricing.spec.ts index 9bf73ee..2912617 100644 --- a/frontend/e2e/admin-pricing.spec.ts +++ b/frontend/e2e/admin-pricing.spec.ts @@ -41,15 +41,15 @@ test.describe("Admin Pricing Page - Admin Access", () => { await expect(page.getByText("Configure premium pricing and trade amount limits")).toBeVisible(); // Check all form fields are present (using text + input selector since labels aren't associated) - await expect(page.getByText(/Premium for BUY/i)).toBeVisible(); + await expect(page.getByText(/Premium.*Buys/i)).toBeVisible(); await expect(page.locator('input[type="number"]').first()).toBeVisible(); - await expect(page.getByText(/Premium for SELL/i)).toBeVisible(); + await expect(page.getByText(/Premium.*Sells/i)).toBeVisible(); await expect(page.getByText(/Small Trade Threshold/i)).toBeVisible(); await expect(page.getByText(/Extra Premium for Small Trades/i)).toBeVisible(); - await expect(page.getByText(/Trade Amount Limits.*BUY/i)).toBeVisible(); + await expect(page.getByText(/Trade Amount Limits.*Buying/i)).toBeVisible(); await expect(page.getByText(/Minimum Amount/i).first()).toBeVisible(); await expect(page.getByText(/Maximum Amount/i).first()).toBeVisible(); - await expect(page.getByText(/Trade Amount Limits.*SELL/i)).toBeVisible(); + await expect(page.getByText(/Trade Amount Limits.*Selling/i)).toBeVisible(); // Check save button is present await expect(page.getByRole("button", { name: /Save Changes/i })).toBeVisible(); diff --git a/frontend/e2e/availability.spec.ts b/frontend/e2e/availability.spec.ts index 49fca38..7dcd726 100644 --- a/frontend/e2e/availability.spec.ts +++ b/frontend/e2e/availability.spec.ts @@ -91,7 +91,12 @@ test.describe("Availability Page - Admin Access", () => { // Wait for "No availability" to disappear first, indicating slots have been loaded await expect(targetCard.getByText("No availability")).not.toBeVisible({ timeout: 10000 }); - // Then verify the specific slot text appears - this ensures the component has re-rendered + + // Wait for any slot time text to appear (matches pattern like "09:00 - 17:00") + // This ensures React has finished rendering the slot badges + await expect(targetCard.getByText(/\d{2}:\d{2} - \d{2}:\d{2}/)).toBeVisible({ timeout: 10000 }); + + // Then verify the specific slot text appears await expect(targetCard.getByText("09:00 - 17:00")).toBeVisible({ timeout: 5000 }); // Now clear it - click on the same card using the testid