fix: CSV import drops contact_email; add incognito browser launch to dev_run.sh
- outreach_import(): contact_email was extracted + used for dedup but missing from the INSERT — added it to the column list and values tuple - test_import_creates_prospects: strengthen to assert contact_email is actually persisted (regression test for the above bug) - dev_run.sh: after server ready, open incognito/private browser window at dev-login URL; tries google-chrome → chromium → firefox in order Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -169,4 +169,25 @@ run_with_label "$COLOR_APP" "app " uv run granian --interface asgi --host 1
|
|||||||
run_with_label "$COLOR_WORKER" "worker" uv run python -u -m padelnomics.worker
|
run_with_label "$COLOR_WORKER" "worker" uv run python -u -m padelnomics.worker
|
||||||
run_with_label "$COLOR_CSS" "css " make css-watch
|
run_with_label "$COLOR_CSS" "css " make css-watch
|
||||||
|
|
||||||
|
# Open a private/incognito browser window once the server is ready.
|
||||||
|
# Polls /auth/dev-login until it responds, then launches the browser.
|
||||||
|
(
|
||||||
|
DEV_URL="http://localhost:5000/auth/dev-login?email=dev@localhost"
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
sleep 0.5
|
||||||
|
if curl -s -o /dev/null -w "%{http_code}" "$DEV_URL" 2>/dev/null | grep -qE "^[23]"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if command -v google-chrome >/dev/null 2>&1; then
|
||||||
|
google-chrome --incognito "$DEV_URL" &>/dev/null &
|
||||||
|
elif command -v chromium >/dev/null 2>&1; then
|
||||||
|
chromium --incognito "$DEV_URL" &>/dev/null &
|
||||||
|
elif command -v chromium-browser >/dev/null 2>&1; then
|
||||||
|
chromium-browser --incognito "$DEV_URL" &>/dev/null &
|
||||||
|
elif command -v firefox >/dev/null 2>&1; then
|
||||||
|
firefox --private-window "$DEV_URL" &>/dev/null &
|
||||||
|
fi
|
||||||
|
) &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|||||||
@@ -2973,9 +2973,9 @@ async def outreach_import():
|
|||||||
await execute(
|
await execute(
|
||||||
"""INSERT INTO suppliers
|
"""INSERT INTO suppliers
|
||||||
(name, slug, country_code, region, category, website,
|
(name, slug, country_code, region, category, website,
|
||||||
tier, outreach_status, created_at)
|
contact_email, tier, outreach_status, created_at)
|
||||||
VALUES (?, ?, ?, 'Europe', ?, ?, 'free', 'prospect', ?)""",
|
VALUES (?, ?, ?, 'Europe', ?, ?, ?, 'free', 'prospect', ?)""",
|
||||||
(name, slug, country_code, category, website, now),
|
(name, slug, country_code, category, website, contact_email, now),
|
||||||
)
|
)
|
||||||
existing_emails.add(contact_email)
|
existing_emails.add(contact_email)
|
||||||
imported += 1
|
imported += 1
|
||||||
|
|||||||
@@ -393,11 +393,14 @@ class TestCSVImport:
|
|||||||
assert resp.status_code == 302
|
assert resp.status_code == 302
|
||||||
|
|
||||||
rows = await core.fetch_all(
|
rows = await core.fetch_all(
|
||||||
"SELECT name, outreach_status FROM suppliers WHERE outreach_status = 'prospect'"
|
"SELECT name, contact_email, outreach_status FROM suppliers WHERE outreach_status = 'prospect'"
|
||||||
)
|
)
|
||||||
names = {r["name"] for r in rows}
|
by_name = {r["name"]: r for r in rows}
|
||||||
assert "BuildCo" in names
|
assert "BuildCo" in by_name
|
||||||
assert "CourtTech" in names
|
assert "CourtTech" in by_name
|
||||||
|
# contact_email must be persisted (regression: was silently dropped)
|
||||||
|
assert by_name["BuildCo"]["contact_email"] == "build@example.com"
|
||||||
|
assert by_name["CourtTech"]["contact_email"] == "court@example.com"
|
||||||
|
|
||||||
async def test_import_deduplicates_by_email(self, admin_client, db):
|
async def test_import_deduplicates_by_email(self, admin_client, db):
|
||||||
await _insert_supplier(db, name="Existing", contact_email="dupe@example.com", outreach_status=None)
|
await _insert_supplier(db, name="Existing", contact_email="dupe@example.com", outreach_status=None)
|
||||||
|
|||||||
Reference in New Issue
Block a user