Skip to content

Commit 3ef5948

Browse files
pieternclaude
andauthored
Fix dashboard tests for Lakeview API behavior change (#4640)
## Changes The server-side Lakeview API changed behavior in two ways: 1. `lakeview update` now returns the full `serialized_dashboard` in its response, even when the update only changed other fields (e.g. `display_name`). Previously it returned "{}". 2. `lakeview update` now clears fields not included in the request (e.g. `warehouse_id`). Previously unspecified fields were preserved. Both changes are consistent with a move from partial update (merge) to full replace semantics on the Lakeview API's mutable fields. ## Tests Update acceptance tests, testserver, and integration test to match. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0c0b80f commit 3ef5948

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

acceptance/bundle/generate/dashboard-inplace/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Deployment complete!
2121
"path":"/Users/[USERNAME]/.bundle/dashboard update inplace/default/resources/test dashboard.lvdash.json",
2222
"serialized_dashboard":"{\"a\":\"b\"}\n",
2323
"update_time":"[TIMESTAMP]",
24-
"warehouse_id":"my-warehouse-1234"
24+
"warehouse_id":""
2525
}
2626

2727
=== update the dashboard file using bundle generate

acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.direct.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"method": "PATCH",
33
"path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]",
44
"body": {
5-
"serialized_dashboard": "{}"
5+
"serialized_dashboard": "{}",
6+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
67
}
78
}
89
{

acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.terraform.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"method": "PATCH",
33
"path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]",
44
"body": {
5-
"serialized_dashboard": "{}"
5+
"serialized_dashboard": "{}",
6+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
67
}
78
}
89
{

acceptance/bundle/resources/dashboards/detect-change/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name,page_display_name: (.ser
2929

3030
title "Make an out of band modification to the dashboard and confirm that it is detected:\n"
3131
RESOURCE_ID=$($CLI workspace get-status "${DASHBOARD_PATH}" | jq -r '.resource_id')
32-
DASHBOARD_JSON='{"serialized_dashboard": "{}"}'
32+
DASHBOARD_JSON="{\"serialized_dashboard\": \"{}\", \"warehouse_id\": \"$TEST_DEFAULT_WAREHOUSE_ID\"}"
3333
$CLI lakeview update "${RESOURCE_ID}" --json "${DASHBOARD_JSON}" | jq '{lifecycle_state}'
3434

3535
title "Try to redeploy the bundle and confirm that the out of band modification is detected:"

acceptance/bundle/resources/dashboards/generate_inplace/output.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Deployment complete!
99
"{\n \"uiSettings\": {\n \"theme\": {\n \"widgetHeaderAlignment\": \"ALIGNMENT_UNSPECIFIED\"\n }\n }\n}\n"
1010

1111
=== Update dashboard
12-
"{}\n"
12+
"{\n \"uiSettings\": {\n \"theme\": {\n \"widgetHeaderAlignment\": \"ALIGNMENT_UNSPECIFIED\"\n }\n }\n}\n"
1313

1414
>>> [CLI] bundle generate dashboard --resource already_exists
1515
Error: dashboard.lvdash.json already exists. Use --force to overwrite
@@ -30,7 +30,13 @@ Exit code: 1
3030
Writing dashboard to dashboard.lvdash.json
3131

3232
>>> cat dashboard.lvdash.json
33-
{}
33+
{
34+
"uiSettings": {
35+
"theme": {
36+
"widgetHeaderAlignment": "ALIGNMENT_UNSPECIFIED"
37+
}
38+
}
39+
}
3440

3541
>>> [CLI] bundle destroy --auto-approve
3642
The following resources will be deleted:

integration/assumptions/dashboard_assumptions_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ func TestDashboardAssumptions_WorkspaceImport(t *testing.T) {
8888
current, err := convert.FromTyped(currentDashboard, dyn.NilValue)
8989
require.NoError(t, err)
9090

91-
// Collect updated paths.
91+
// Collect updated and deleted paths.
9292
var updatedFieldPaths []string
93+
var deletedFieldPaths []string
9394
_, err = merge.Override(previous, current, merge.OverrideVisitor{
9495
VisitDelete: func(basePath dyn.Path, left dyn.Value) error {
95-
assert.Fail(t, "unexpected delete operation")
96+
deletedFieldPaths = append(deletedFieldPaths, basePath.String())
9697
return nil
9798
},
9899
VisitInsert: func(basePath dyn.Path, right dyn.Value) (dyn.Value, error) {
@@ -111,5 +112,10 @@ func TestDashboardAssumptions_WorkspaceImport(t *testing.T) {
111112
"etag",
112113
"update_time",
113114
}, updatedFieldPaths)
115+
116+
// The warehouse_id field is cleared after workspace import.
117+
assert.ElementsMatch(t, []string{
118+
"warehouse_id",
119+
}, deletedFieldPaths)
114120
}
115121
}

libs/testserver/dashboards.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ func (s *FakeWorkspace) DashboardUpdate(req Request) Response {
198198
datasetSchema := req.URL.Query().Get("dataset_schema")
199199
dashboard.SerializedDashboard = transformSerializedDashboard(updateReq.SerializedDashboard, datasetCatalog, datasetSchema)
200200
}
201-
if updateReq.WarehouseId != "" {
202-
dashboard.WarehouseId = updateReq.WarehouseId
203-
}
201+
dashboard.WarehouseId = updateReq.WarehouseId
204202
dashboard.UpdateTime = time.Now().UTC().Format(time.RFC3339)
205203

206204
s.Dashboards[dashboardId] = dashboard

0 commit comments

Comments
 (0)