gaard-client 0.2.6__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {gaard_client-0.2.6 → gaard_client-0.2.7}/PKG-INFO +2 -2
  2. {gaard_client-0.2.6 → gaard_client-0.2.7}/pyproject.toml +2 -2
  3. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/client-web/assets/main.js +138 -9
  4. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/client-web/assets/styles.css +84 -10
  5. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/main.py +33 -1
  6. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/PKG-INFO +2 -2
  7. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/requires.txt +1 -1
  8. {gaard_client-0.2.6 → gaard_client-0.2.7}/tests/test_client_app.py +55 -0
  9. {gaard_client-0.2.6 → gaard_client-0.2.7}/README.md +0 -0
  10. {gaard_client-0.2.6 → gaard_client-0.2.7}/setup.cfg +0 -0
  11. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/__init__.py +0 -0
  12. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/cli.py +0 -0
  13. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/cli_commands.py +0 -0
  14. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/client-web/assets/getgaard.svg +0 -0
  15. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client/client-web/index.html +0 -0
  16. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/SOURCES.txt +0 -0
  17. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/dependency_links.txt +0 -0
  18. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/entry_points.txt +0 -0
  19. {gaard_client-0.2.6 → gaard_client-0.2.7}/src/gaard_client.egg-info/top_level.txt +0 -0
  20. {gaard_client-0.2.6 → gaard_client-0.2.7}/tests/test_cli.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gaard-client
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: GAARD frontend web services providing client interface
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
- Requires-Dist: gaard-plugin-api<0.3.0,>=0.2.6
7
+ Requires-Dist: gaard-plugin-api<0.3.0,>=0.2.7
8
8
  Requires-Dist: fastapi>=0.111.0
9
9
  Requires-Dist: uvicorn[standard]>=0.30.0
10
10
  Requires-Dist: pydantic>=2.7.0
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gaard-client"
7
- version = "0.2.6"
7
+ version = "0.2.7"
8
8
  description = "GAARD frontend web services providing client interface"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
11
11
 
12
12
  dependencies = [
13
- "gaard-plugin-api>=0.2.6,<0.3.0",
13
+ "gaard-plugin-api>=0.2.7,<0.3.0",
14
14
  "fastapi>=0.111.0",
15
15
  "uvicorn[standard]>=0.30.0",
16
16
  "pydantic>=2.7.0",
@@ -63,6 +63,7 @@ var state = {
63
63
  metricEditDraftLabel: "",
64
64
  metricEditPending: false,
65
65
  metricEditError: "",
66
+ metricDeletePendingKey: "",
66
67
  dashboardLayoutSaveTimer: null
67
68
  };
68
69
  rememberActiveView(state.activeView);
@@ -866,24 +867,94 @@ function renderQueriesView() {
866
867
  </section>`;
867
868
  }
868
869
  function renderMetricsView() {
870
+ const groups = groupSavedMetricsByDatasource(state.savedMetrics);
871
+ const waitingForDatasourceNames = (
872
+ state.token &&
873
+ state.savedMetrics.some((metric) => normalizeMetricDatasourceKey(metric) === "default") &&
874
+ !state.datasourcesLoaded
875
+ );
869
876
  return `
870
877
  <section class="placeholder-view metrics-view">
871
878
  ${state.savedMetricsError ? `<div class="source-error datasource-error" role="alert">${escapeHtml(state.savedMetricsError)}</div>` : ""}
872
879
  ${state.savedMetricsLoading ? renderDashboardLoadingState("Loading saved metrics...", "Please wait while GAARD prepares your saved metrics.") : ""}
880
+ ${!state.savedMetricsLoading && waitingForDatasourceNames ? renderDashboardLoadingState("Loading data sources...", "Please wait while GAARD resolves saved metric sources.") : ""}
873
881
  ${!state.savedMetricsLoading && !state.token ? `<div class="datasource-empty">Log in to manage saved metrics.</div>` : ""}
874
882
  ${!state.savedMetricsLoading && state.token && !state.savedMetrics.length ? `<div class="datasource-empty">No saved metrics yet. Save a successful query from Home first.</div>` : ""}
875
- ${!state.savedMetricsLoading && state.savedMetrics.length ? `
876
- <div class="placeholder-list metrics-list">
877
- ${state.savedMetrics.map(renderSavedMetricCard).join("")}
883
+ ${!state.savedMetricsLoading && !waitingForDatasourceNames && state.savedMetrics.length ? `
884
+ <div class="metrics-groups">
885
+ ${groups.map(renderMetricDatasourceGroup).join("")}
878
886
  </div>` : ""}
879
887
  </section>`;
880
888
  }
889
+ function normalizeMetricDatasourceKey(metric) {
890
+ return String(metric.datasource_key || "default").trim() || "default";
891
+ }
892
+ function formatMetricDatasourceName(datasourceKey) {
893
+ const normalizedKey = String(datasourceKey || "default").trim() || "default";
894
+ if (normalizedKey === "default") {
895
+ return formatDefaultMetricDatasourceName();
896
+ }
897
+ const source = state.datasources.find((item) => (
898
+ String(item.connector_key || "") === normalizedKey
899
+ || String(item.id || "") === normalizedKey
900
+ || String(item.name || "") === normalizedKey
901
+ ));
902
+ if (source) {
903
+ return source.name || source.connector_key || normalizedKey;
904
+ }
905
+ return normalizedKey
906
+ .replace(/[-_](db|database)$/i, "")
907
+ .replace(/[-_]+/g, " ")
908
+ .replace(/\b\w/g, (letter) => letter.toUpperCase());
909
+ }
910
+ function formatDefaultMetricDatasourceName() {
911
+ const activeSource = state.datasources.find((item) => (
912
+ item.active && item.connector_key !== "metadata-db"
913
+ ));
914
+ const defaultSource = state.datasources.find((item) => item.connector_key === "default");
915
+ const source = activeSource || defaultSource;
916
+ const name = source?.name || source?.connector_key || "Default source";
917
+ return `${name} (default)`;
918
+ }
919
+ function groupSavedMetricsByDatasource(metrics) {
920
+ const groups = new Map();
921
+ metrics.forEach((metric) => {
922
+ const key = normalizeMetricDatasourceKey(metric);
923
+ if (!groups.has(key)) {
924
+ groups.set(key, {
925
+ key,
926
+ label: formatMetricDatasourceName(key),
927
+ items: []
928
+ });
929
+ }
930
+ groups.get(key).items.push(metric);
931
+ });
932
+ return Array.from(groups.values()).sort((left, right) => {
933
+ if (left.key === "default") return -1;
934
+ if (right.key === "default") return 1;
935
+ return left.label.localeCompare(right.label);
936
+ });
937
+ }
938
+ function renderMetricDatasourceGroup(group) {
939
+ return `
940
+ <section class="metric-source-group" aria-label="Data Source: ${escapeHtml(group.label)}">
941
+ <header class="metric-source-header">
942
+ <h2>Data Source: ${escapeHtml(group.label)}</h2>
943
+ <span>${group.items.length} ${group.items.length === 1 ? "metric" : "metrics"}</span>
944
+ </header>
945
+ <div class="metrics-list">
946
+ ${group.items.map(renderSavedMetricCard).join("")}
947
+ </div>
948
+ </section>`;
949
+ }
881
950
  function renderSavedMetricCard(metric) {
882
951
  const result = metric.result || {};
883
952
  const rows = getRowsFromResult(result);
884
953
  const typeLabel = metric.widget_type === "scalar" ? "Number-ready" : metric.widget_type === "timeseries" ? "Time series" : "Table";
885
954
  const widgetKey = metric.widget_key || "";
886
- const details = [typeLabel, metric.datasource_key || "default"];
955
+ const deleting = state.metricDeletePendingKey === widgetKey;
956
+ const label = metric.label || metric.widget_key || "Saved metric";
957
+ const details = [typeLabel];
887
958
  if (metric.result) {
888
959
  details.push(`${rows.length} rows`);
889
960
  }
@@ -891,12 +962,17 @@ function renderSavedMetricCard(metric) {
891
962
  <article class="placeholder-item metric-card">
892
963
  ${renderIcon(metric.widget_type === "scalar" ? "metrics" : "dashboards")}
893
964
  <span>
894
- <strong>${escapeHtml(metric.label || metric.widget_key || "Saved metric")}</strong>
965
+ <strong class="metric-title" title="${escapeHtml(label)}">${escapeHtml(label)}</strong>
895
966
  <small>${escapeHtml(details.join(" · "))}</small>
896
967
  </span>
897
- <button class="metric-edit-button" type="button" data-edit-metric="${escapeHtml(widgetKey)}" aria-label="Edit metric name" title="Edit metric name" ${!widgetKey ? "disabled" : ""}>
898
- ${renderIcon("edit")}
899
- </button>
968
+ <div class="metric-card-actions">
969
+ <button class="metric-action-button" type="button" data-edit-metric="${escapeHtml(widgetKey)}" aria-label="Edit metric name" title="Edit metric name" ${!widgetKey || deleting ? "disabled" : ""}>
970
+ ${renderIcon("edit")}
971
+ </button>
972
+ <button class="metric-action-button metric-delete-button" type="button" data-delete-metric="${escapeHtml(widgetKey)}" aria-label="Delete metric" title="Delete metric" ${!widgetKey || deleting ? "disabled" : ""}>
973
+ ${renderIcon("trash")}
974
+ </button>
975
+ </div>
900
976
  </article>`;
901
977
  }
902
978
  function renderDatasourcesView() {
@@ -1076,6 +1152,9 @@ function render(options = {}) {
1076
1152
  document.querySelectorAll("[data-edit-metric]").forEach((button) => {
1077
1153
  button.addEventListener("click", openMetricEditDialog);
1078
1154
  });
1155
+ document.querySelectorAll("[data-delete-metric]").forEach((button) => {
1156
+ button.addEventListener("click", deleteSavedMetric);
1157
+ });
1079
1158
  document.querySelectorAll("[data-close-metric-edit]").forEach((button) => {
1080
1159
  button.addEventListener("click", closeMetricEditDialog);
1081
1160
  });
@@ -1140,7 +1219,7 @@ function formatApiResponseError(response, message) {
1140
1219
  return detail === "Request failed." ? `${prefix}: Request failed.` : `${prefix}: ${detail}`;
1141
1220
  }
1142
1221
  function maybeLoadDatasourcesForActiveView() {
1143
- if (state.activeView === "datasources" && state.token && !state.datasourcesLoaded && !state.datasourcesLoading) {
1222
+ if ((state.activeView === "datasources" || state.activeView === "metrics") && state.token && !state.datasourcesLoaded && !state.datasourcesLoading) {
1144
1223
  void loadDatasources();
1145
1224
  }
1146
1225
  }
@@ -1501,6 +1580,24 @@ function closeMetricEditDialog() {
1501
1580
  function changeMetricEditLabel(event) {
1502
1581
  state.metricEditDraftLabel = event.currentTarget.value || "";
1503
1582
  }
1583
+ function applySavedMetricDelete(widgetKey) {
1584
+ state.savedMetrics = state.savedMetrics.filter((metric) => metric.widget_key !== widgetKey);
1585
+ state.dashboardWidgets = state.dashboardWidgets.filter(
1586
+ (widget) => widget.metric_widget_key !== widgetKey
1587
+ );
1588
+ if (state.dashboardWidgetMetricKey === widgetKey) {
1589
+ state.dashboardWidgetMetricKey = state.savedMetrics[0]?.widget_key || "";
1590
+ state.dashboardWidgetType = state.savedMetrics[0]
1591
+ ? recommendWidgetType(state.savedMetrics[0])
1592
+ : "";
1593
+ }
1594
+ if (state.metricEditWidgetKey === widgetKey) {
1595
+ state.metricEditDialogOpen = false;
1596
+ state.metricEditWidgetKey = "";
1597
+ state.metricEditDraftLabel = "";
1598
+ state.metricEditError = "";
1599
+ }
1600
+ }
1504
1601
  function applySavedMetricUpdate(metric) {
1505
1602
  if (!metric?.widget_key) return;
1506
1603
  state.savedMetrics = state.savedMetrics.map((item) => (
@@ -1524,6 +1621,37 @@ function applySavedMetricUpdate(metric) {
1524
1621
  };
1525
1622
  });
1526
1623
  }
1624
+ async function deleteSavedMetric(event) {
1625
+ const widgetKey = event.currentTarget.dataset.deleteMetric || "";
1626
+ if (!state.token || !widgetKey || state.metricDeletePendingKey) return;
1627
+ if (!window.confirm("Deleting this metric will also remove it from all dashboards.")) {
1628
+ return;
1629
+ }
1630
+ state.metricDeletePendingKey = widgetKey;
1631
+ state.savedMetricsError = "";
1632
+ render();
1633
+ const params = new URLSearchParams({ backend_url: state.backendUrl });
1634
+ try {
1635
+ const response = await fetch(
1636
+ `/api/dashboard-metrics/${encodeURIComponent(widgetKey)}?${params.toString()}`,
1637
+ {
1638
+ method: "DELETE",
1639
+ headers: authHeaders()
1640
+ }
1641
+ );
1642
+ const payload = await response.json().catch(() => ({}));
1643
+ if (!response.ok) {
1644
+ throw new Error(formatApiResponseError(response, extractErrorMessage(payload)));
1645
+ }
1646
+ applySavedMetricDelete(widgetKey);
1647
+ } catch (error) {
1648
+ state.savedMetricsError = error.message || "Metric could not be deleted.";
1649
+ reportApiError(error, "Metric could not be deleted.");
1650
+ } finally {
1651
+ state.metricDeletePendingKey = "";
1652
+ render();
1653
+ }
1654
+ }
1527
1655
  async function saveMetricLabel(event) {
1528
1656
  event.preventDefault();
1529
1657
  if (!state.token || state.metricEditPending) return;
@@ -2603,6 +2731,7 @@ function logout() {
2603
2731
  state.metricEditDraftLabel = "";
2604
2732
  state.metricEditPending = false;
2605
2733
  state.metricEditError = "";
2734
+ state.metricDeletePendingKey = "";
2606
2735
  state.activeView = "home";
2607
2736
  rememberActiveView(state.activeView);
2608
2737
  state.loginOpen = false;
@@ -2554,23 +2554,85 @@ button.primary {
2554
2554
  gap: 14px;
2555
2555
  }
2556
2556
 
2557
+ .metrics-view {
2558
+ gap: 26px;
2559
+ }
2560
+
2561
+ .metrics-groups {
2562
+ display: grid;
2563
+ gap: 28px;
2564
+ }
2565
+
2566
+ .metric-source-group {
2567
+ display: grid;
2568
+ gap: 12px;
2569
+ min-width: 0;
2570
+ }
2571
+
2572
+ .metric-source-header {
2573
+ display: flex;
2574
+ align-items: baseline;
2575
+ justify-content: space-between;
2576
+ gap: 16px;
2577
+ min-width: 0;
2578
+ padding-bottom: 8px;
2579
+ border-bottom: 1px solid #dce5ee;
2580
+ }
2581
+
2582
+ .metric-source-header h2 {
2583
+ min-width: 0;
2584
+ margin: 0;
2585
+ overflow: hidden;
2586
+ color: #152333;
2587
+ font-size: 14px;
2588
+ font-weight: 600;
2589
+ text-overflow: ellipsis;
2590
+ white-space: nowrap;
2591
+ }
2592
+
2593
+ .metric-source-header span {
2594
+ color: #7a8793;
2595
+ font-size: 12px;
2596
+ font-weight: 500;
2597
+ white-space: nowrap;
2598
+ }
2599
+
2557
2600
  .metrics-list {
2558
- grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
2601
+ display: grid;
2602
+ grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
2603
+ gap: 14px;
2559
2604
  }
2560
2605
 
2561
- .metric-card {
2562
- min-height: 88px;
2563
- grid-template-columns: 32px minmax(0, 1fr) 30px;
2606
+ .placeholder-item.metric-card {
2607
+ min-height: 104px;
2608
+ grid-template-columns: 32px minmax(0, 1fr) auto;
2564
2609
  align-items: start;
2565
2610
  }
2566
2611
 
2567
- .metric-edit-button {
2612
+ .metric-card .metric-title {
2613
+ display: -webkit-box;
2614
+ overflow: hidden;
2615
+ line-height: 1.3;
2616
+ text-overflow: clip;
2617
+ white-space: normal;
2618
+ -webkit-box-orient: vertical;
2619
+ -webkit-line-clamp: 2;
2620
+ }
2621
+
2622
+ .metric-card-actions {
2623
+ display: flex;
2624
+ grid-column: 3;
2625
+ grid-row: 1;
2626
+ gap: 4px;
2627
+ align-self: start;
2628
+ justify-self: end;
2629
+ }
2630
+
2631
+ .metric-action-button {
2568
2632
  width: 30px;
2569
2633
  min-height: 30px;
2570
2634
  display: inline-grid;
2571
2635
  place-items: center;
2572
- align-self: start;
2573
- justify-self: end;
2574
2636
  padding: 0;
2575
2637
  border: 0;
2576
2638
  border-radius: 6px;
@@ -2578,19 +2640,31 @@ button.primary {
2578
2640
  color: #6d7a86;
2579
2641
  }
2580
2642
 
2581
- .metric-edit-button:hover,
2582
- .metric-edit-button:focus-visible {
2643
+ .metric-action-button:hover,
2644
+ .metric-action-button:focus-visible {
2583
2645
  background: #eef5ff;
2584
2646
  color: var(--accent);
2585
2647
  }
2586
2648
 
2587
- .metric-card .metric-edit-button svg {
2649
+ .metric-delete-button:hover,
2650
+ .metric-delete-button:focus-visible {
2651
+ background: #fff1f2;
2652
+ color: #b42318;
2653
+ }
2654
+
2655
+ .metric-card .metric-action-button svg {
2588
2656
  width: 16px;
2589
2657
  height: 16px;
2590
2658
  stroke: currentColor;
2591
2659
  stroke-width: 1.8;
2592
2660
  }
2593
2661
 
2662
+ @media (max-width: 760px) {
2663
+ .metrics-list {
2664
+ grid-template-columns: minmax(0, 1fr);
2665
+ }
2666
+ }
2667
+
2594
2668
  .placeholder-item {
2595
2669
  min-height: 96px;
2596
2670
  display: grid;
@@ -23,7 +23,7 @@ DEFAULT_BACKEND_URL = "http://localhost:8000"
23
23
 
24
24
  app = FastAPI(
25
25
  title="GAARD Client",
26
- version="0.2.6",
26
+ version="0.2.7",
27
27
  description="Community client for asking governed natural-language questions.",
28
28
  )
29
29
 
@@ -641,6 +641,38 @@ async def update_dashboard_metric(
641
641
  return cast(dict[str, Any], response.json())
642
642
 
643
643
 
644
+ @app.delete("/api/dashboard-metrics/{widget_key}")
645
+ async def delete_dashboard_metric(
646
+ widget_key: str,
647
+ backend_url: str | None = None,
648
+ authorization: str | None = Header(default=None),
649
+ ) -> dict[str, Any]:
650
+ backend_url = normalize_backend_url(backend_url or get_default_backend_url())
651
+ metric_url = f"{backend_url}/api/v1/dashboards/metrics/{widget_key}"
652
+
653
+ try:
654
+ async with httpx.AsyncClient(timeout=120.0) as client:
655
+ response = await client.delete(
656
+ metric_url,
657
+ headers=backend_auth_headers(authorization),
658
+ )
659
+ except httpx.HTTPError as exc:
660
+ raise HTTPException(
661
+ status_code=502,
662
+ detail=f"Backend request failed: {exc}",
663
+ ) from exc
664
+
665
+ if response.status_code >= 400:
666
+ raise HTTPException(
667
+ status_code=response.status_code,
668
+ detail=response.json()
669
+ if response.headers.get("content-type", "").startswith("application/json")
670
+ else response.text,
671
+ )
672
+
673
+ return cast(dict[str, Any], response.json())
674
+
675
+
644
676
  @app.get("/api/dashboards/{dashboard_id}/widgets")
645
677
  async def list_dashboard_widgets(
646
678
  dashboard_id: str,
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gaard-client
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: GAARD frontend web services providing client interface
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
- Requires-Dist: gaard-plugin-api<0.3.0,>=0.2.6
7
+ Requires-Dist: gaard-plugin-api<0.3.0,>=0.2.7
8
8
  Requires-Dist: fastapi>=0.111.0
9
9
  Requires-Dist: uvicorn[standard]>=0.30.0
10
10
  Requires-Dist: pydantic>=2.7.0
@@ -1,4 +1,4 @@
1
- gaard-plugin-api<0.3.0,>=0.2.6
1
+ gaard-plugin-api<0.3.0,>=0.2.7
2
2
  fastapi>=0.111.0
3
3
  uvicorn[standard]>=0.30.0
4
4
  pydantic>=2.7.0
@@ -57,6 +57,13 @@ def test_client_app_warns_when_response_uses_mock_modes() -> None:
57
57
  assert "Save metric" in response.text
58
58
  assert "data-edit-metric" in response.text
59
59
  assert "Edit metric name" in response.text
60
+ assert "data-delete-metric" in response.text
61
+ assert "Deleting this metric will also remove it from all dashboards." in response.text
62
+ assert "metrics-groups" in response.text
63
+ assert "Data Source:" in response.text
64
+ assert "metric-title" in response.text
65
+ assert "formatDefaultMetricDatasourceName" in response.text
66
+ assert "(default)" in response.text
60
67
  assert "hasLongSeries" in response.text
61
68
  assert "longSeriesWidgetOptions" in response.text
62
69
  assert 'types.push("stacked_bar", "multi_line")' in response.text
@@ -423,6 +430,54 @@ def test_client_app_proxies_saved_metric_update(monkeypatch) -> None:
423
430
  assert captured["json"] == {"label": "New metric name"}
424
431
 
425
432
 
433
+ def test_client_app_proxies_saved_metric_delete(monkeypatch) -> None:
434
+ captured = {}
435
+
436
+ class FakeAsyncClient:
437
+ def __init__(self, *args, **kwargs) -> None:
438
+ pass
439
+
440
+ async def __aenter__(self):
441
+ return self
442
+
443
+ async def __aexit__(self, exc_type, exc, traceback) -> None:
444
+ pass
445
+
446
+ async def delete(self, url, headers=None):
447
+ captured["url"] = url
448
+ captured["headers"] = headers
449
+ request = httpx.Request("DELETE", url)
450
+
451
+ return httpx.Response(
452
+ status_code=200,
453
+ request=request,
454
+ json={
455
+ "status": "deleted",
456
+ "widget_key": "client_metric",
457
+ "removed_dashboard_widgets": 2,
458
+ },
459
+ )
460
+
461
+ monkeypatch.setattr(httpx, "AsyncClient", FakeAsyncClient)
462
+ client = TestClient(app)
463
+
464
+ response = client.delete(
465
+ "/api/dashboard-metrics/client_metric?backend_url=http://backend.example/",
466
+ headers={"Authorization": "Bearer token"},
467
+ )
468
+
469
+ assert response.status_code == 200
470
+ assert response.json() == {
471
+ "status": "deleted",
472
+ "widget_key": "client_metric",
473
+ "removed_dashboard_widgets": 2,
474
+ }
475
+ assert captured["url"] == (
476
+ "http://backend.example/api/v1/dashboards/metrics/client_metric"
477
+ )
478
+ assert captured["headers"] == {"Authorization": "Bearer token"}
479
+
480
+
426
481
  def test_client_app_proxies_dashboard_crud(monkeypatch) -> None:
427
482
  captured: list[dict[str, object]] = []
428
483
 
File without changes
File without changes