small fixes

This commit is contained in:
counterweight 2025-12-27 12:52:43 +01:00
parent 86c92a7c65
commit 43b250e157
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 18 additions and 7 deletions

View file

@ -17,6 +17,7 @@ from models import (
TradeDirection, TradeDirection,
) )
from price_fetcher import PAIR_BTC_EUR, SOURCE_BITFINEX from price_fetcher import PAIR_BTC_EUR, SOURCE_BITFINEX
from shared_constants import EUR_TRADE_INCREMENT
def tomorrow() -> date: def tomorrow() -> date:
@ -213,7 +214,7 @@ class TestExchangePriceEndpoint:
assert config["eur_max_buy"] == 300000 assert config["eur_max_buy"] == 300000
assert config["eur_min_sell"] == 12000 assert config["eur_min_sell"] == 12000
assert config["eur_max_sell"] == 320000 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_buy"] == 5
assert config["premium_sell"] == 6 assert config["premium_sell"] == 6
@ -659,6 +660,11 @@ class TestCreateExchange:
"""EUR amount not a multiple of increment is rejected.""" """EUR amount not a multiple of increment is rejected."""
target_date = await setup_availability_and_price(client_factory, admin_user) 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): with mock_price_fetcher(20000.0):
async with client_factory.create(cookies=regular_user["cookies"]) as client: async with client_factory.create(cookies=regular_user["cookies"]) as client:
response = await client.post( response = await client.post(
@ -667,7 +673,7 @@ class TestCreateExchange:
"slot_start": f"{target_date}T09:00:00Z", "slot_start": f"{target_date}T09:00:00Z",
"direction": "buy", "direction": "buy",
"bitcoin_transfer_method": "onchain", "bitcoin_transfer_method": "onchain",
"eur_amount": 11500, # €115, not multiple of €20 "eur_amount": invalid_amount,
}, },
) )

View file

@ -41,15 +41,15 @@ test.describe("Admin Pricing Page - Admin Access", () => {
await expect(page.getByText("Configure premium pricing and trade amount limits")).toBeVisible(); 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) // 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.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(/Small Trade Threshold/i)).toBeVisible();
await expect(page.getByText(/Extra Premium for Small Trades/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(/Minimum Amount/i).first()).toBeVisible();
await expect(page.getByText(/Maximum 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 // Check save button is present
await expect(page.getByRole("button", { name: /Save Changes/i })).toBeVisible(); await expect(page.getByRole("button", { name: /Save Changes/i })).toBeVisible();

View file

@ -91,7 +91,12 @@ test.describe("Availability Page - Admin Access", () => {
// Wait for "No availability" to disappear first, indicating slots have been loaded // Wait for "No availability" to disappear first, indicating slots have been loaded
await expect(targetCard.getByText("No availability")).not.toBeVisible({ timeout: 10000 }); 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 }); await expect(targetCard.getByText("09:00 - 17:00")).toBeVisible({ timeout: 5000 });
// Now clear it - click on the same card using the testid // Now clear it - click on the same card using the testid