diff --git a/Makefile b/Makefile index 7025c43..2ad0032 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,9 @@ export VENV := .venv UVICORN := $(VENV)/bin/uvicorn TEST_DEPS := $(VENV)/.test-deps +K3S_BTCDATA_PORT := 4100 -.PHONY: clean run run-local run-citadel tailwind test venv +.PHONY: clean run run-local run-citadel run-k3s tailwind test venv venv: $(UVICORN) @@ -26,6 +27,12 @@ run-local: venv run-citadel: venv BTCDATA_URL=$(BTCDATA_URL) $(UVICORN) app.main:app --host 0.0.0.0 --port 4000 --reload +run-k3s: venv + kubectl -n btcdata port-forward service/btcdata $(K3S_BTCDATA_PORT):4101 & \ + port_forward_pid=$$!; \ + trap 'kill $$port_forward_pid' EXIT INT TERM; \ + BTCDATA_URL=http://127.0.0.1:$(K3S_BTCDATA_PORT) $(UVICORN) app.main:app --host 0.0.0.0 --port 4000 --reload + tailwind: npm run css:watch diff --git a/app/main.py b/app/main.py index 243a53c..c813b22 100644 --- a/app/main.py +++ b/app/main.py @@ -47,6 +47,7 @@ HOME_HTML = """\

BTC Price

+

 

@@ -78,14 +79,50 @@ HOME_HTML = """\
@@ -250,7 +288,7 @@ def price_json_to_html(text: str) -> str: formatted_price = f'${da_fmt(",.2f", p)}' html = ( - f'
' + f'
' '
' '
' f'

{formatted_price}

' diff --git a/tests/test_health.py b/tests/test_health.py index fbc6517..6c68a3c 100644 --- a/tests/test_health.py +++ b/tests/test_health.py @@ -37,7 +37,16 @@ def test_home_updates_title_from_latest_price(): assert response.status_code == 200 assert "new MutationObserver(updateTitleFromPrice)" in response.text - assert "document.title = price + ' | BTC Price'" in response.text + assert "currentPrice - midnightPrice" in response.text + assert "document.title = price + ' | ' + formattedChange" in response.text + assert '

BTC Price

' in response.text + assert "page-title" not in response.text + assert 'id="midnight-change"' in response.text + assert "midnightChange.textContent = formattedChange" in response.text + assert "since 00:00" not in response.text + assert "change > 0 ? 'text-green-600' : change < 0 ? 'text-red-600'" in response.text + assert "formatPriceChange(change)" in response.text + assert "midnight.setHours(0, 0, 0, 0)" in response.text def test_price_fragment_exposes_formatted_price_for_title(): @@ -46,6 +55,7 @@ def test_price_fragment_exposes_formatted_price_for_title(): ) assert 'data-title-price="$67.432,10"' in html + assert 'data-price-value="67432.1"' in html assert ">$67.432,10

" in html