Dev Updates

icon picker
System Test

✅ Testing Steps for Summary Metrics Dashboard

🧪 Goal: Verify that each metric card correctly retrieves and displays live data from Supabase.

1. Prepare Queries for Testing

Before deploying in Lovable, verify the SQL logic directly in Supabase.
In Supabase SQL Editor, run each of the following:
sql
CopyEdit
-- Total Proposals
select count(*) as total_proposals from proposals;

-- Approved Proposals
select count(*) as approved_proposals from proposals where status = 'Approved';

-- Total Simulations
select count(*) as total_simulations from simulations;

-- Recent Proposals (last 7 days)
select count(*) as recent_proposals from proposals where created_at > now() - interval '7 days';

✅ Confirm that each returns an integer (not null or error).
✅ Confirm that the data matches what’s in your tables.

2. Add and Render Metric Cards in Lovable

Go to the page (e.g. Governance Dashboard) where the cards will live.
Paste in the MetricCard JSON definitions one by one or as a block.
Assign each to a grid or card layout if needed for responsiveness.

3. Verify Live Data Render

✅ Confirm that each card displays a non-zero value if data exists.
✅ Confirm correct icon and title appear.
🟨 If empty, check that your table contains valid test entries.

4. Modify Data and Observe Change

Add a new Proposal or Simulation via UI or SQL.
Reload the Lovable page or trigger a data refresh.
✅ The relevant metric (e.g., Total Proposals) should increment.
Optional:
Change a proposal's status to 'Approved' to test the Approved count.
Change the created_at to test if it appears in Recent (7d) metric.

5. Error Handling (if any)

❌ If a card returns “undefined” or shows loading indefinitely:
Check if the query is correct and bound to value: {{ result_name }}
Verify you don’t need authentication permissions or row-level access updates
Check if query returns a result with an alias (e.g., as total_proposals)

6. Optional: Convert to Supabase View (for reuse)

If metrics are stable, you can convert queries into views for caching and ease of use:
sql
CopyEdit
create view total_proposals_view as
select count(*) as total_proposals from proposals;

Then bind the Lovable card to select * from total_proposals_view;.
Let me know if you’d like this formatted into a downloadable test plan or included in a documentation system.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.