mirror of
https://github.com/apache/superset.git
synced 2026-08-12 11:11:01 +00:00
fix(dashboards): remove thumbnail_url from list API to reduce cache cost (#38567)
This commit is contained in:
@@ -67,11 +67,14 @@ class TestThumbnailsSeleniumLive(LiveServerTestCase):
|
||||
"""
|
||||
Thumbnails: Simple get async dashboard screenshot
|
||||
"""
|
||||
with patch("superset.dashboards.api.DashboardRestApi.get") as mock_get: # noqa: F841
|
||||
rv = self.client.get(DASHBOARD_URL)
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
thumbnail_url = resp["result"][0]["thumbnail_url"]
|
||||
rv = self.client.get(DASHBOARD_URL)
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
obj_id = resp["result"][0]["id"]
|
||||
rv = self.client.get(f"{DASHBOARD_URL}{obj_id}")
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
thumbnail_url = resp["result"]["thumbnail_url"]
|
||||
|
||||
with patch("superset.dashboards.api.DashboardRestApi.get"):
|
||||
response = self.url_open_auth(
|
||||
ADMIN_USERNAME,
|
||||
thumbnail_url,
|
||||
@@ -194,11 +197,31 @@ class TestThumbnails(SupersetTestCase):
|
||||
# SHA-256 hash of "foo_bar" (default HASH_ALGORITHM is sha256)
|
||||
digest_hash = "4928cae8b37b3d1113f5e01e60c967df6c2b9e826dc7d91488d23a62fec715ba"
|
||||
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_dashboard_list_omits_thumbnail_url(self):
|
||||
"""
|
||||
Thumbnails: dashboard list response must not include thumbnail_url
|
||||
"""
|
||||
self.login(ADMIN_USERNAME)
|
||||
rv = self.client.get(DASHBOARD_URL)
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
assert rv.status_code == 200
|
||||
assert len(resp["result"]) > 0
|
||||
for dashboard in resp["result"]:
|
||||
assert "thumbnail_url" not in dashboard, (
|
||||
"thumbnail_url should not appear in list responses; "
|
||||
"it is only available on the detail endpoint"
|
||||
)
|
||||
|
||||
def _get_id_and_thumbnail_url(self, url: str) -> tuple[int, str]:
|
||||
rv = self.client.get(url)
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
obj = resp["result"][0]
|
||||
return obj["id"], obj["thumbnail_url"]
|
||||
obj_id = resp["result"][0]["id"]
|
||||
# Fetch thumbnail_url from the detail endpoint since it's
|
||||
# not included in list responses
|
||||
rv = self.client.get(f"{url}{obj_id}")
|
||||
resp = json.loads(rv.data.decode("utf-8"))
|
||||
return obj_id, resp["result"]["thumbnail_url"]
|
||||
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
@with_feature_flags(THUMBNAILS=False)
|
||||
|
||||
Reference in New Issue
Block a user