fix(dashboard): stabilize four-column widget placement
This commit is contained in:
@@ -83,6 +83,7 @@ class DashboardLayoutApiTests(unittest.TestCase):
|
||||
"instance_id": "instance-1",
|
||||
"widget_id": "dashboard.installed-modules",
|
||||
"size": "wide",
|
||||
"column_start": 2,
|
||||
"configuration": {
|
||||
"maxItems": 5,
|
||||
"showVersions": False,
|
||||
@@ -118,6 +119,10 @@ class DashboardLayoutApiTests(unittest.TestCase):
|
||||
False,
|
||||
original.json()["placements"][0]["configuration"]["showVersions"],
|
||||
)
|
||||
self.assertEqual(
|
||||
2,
|
||||
original.json()["placements"][0]["column_start"],
|
||||
)
|
||||
|
||||
def test_stale_revision_is_rejected(self) -> None:
|
||||
payload = {
|
||||
@@ -174,6 +179,48 @@ class DashboardLayoutApiTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(422, response.status_code)
|
||||
|
||||
def test_widget_span_must_fit_the_four_column_grid(self) -> None:
|
||||
response = self.client.put(
|
||||
"/api/v1/dashboard/layout",
|
||||
json={
|
||||
"expected_revision": 0,
|
||||
"layout_version": 1,
|
||||
"placements": [
|
||||
{
|
||||
"instance_id": "instance-1",
|
||||
"widget_id": "example.widget",
|
||||
"size": "medium",
|
||||
"column_start": 4,
|
||||
"configuration": {},
|
||||
}
|
||||
],
|
||||
"known_widget_ids": ["example.widget"],
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(422, response.status_code)
|
||||
|
||||
def test_legacy_placement_without_column_is_still_accepted(self) -> None:
|
||||
response = self.client.put(
|
||||
"/api/v1/dashboard/layout",
|
||||
json={
|
||||
"expected_revision": 0,
|
||||
"layout_version": 1,
|
||||
"placements": [
|
||||
{
|
||||
"instance_id": "instance-1",
|
||||
"widget_id": "example.widget",
|
||||
"size": "medium",
|
||||
"configuration": {},
|
||||
}
|
||||
],
|
||||
"known_widget_ids": ["example.widget"],
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertIsNone(response.json()["placements"][0]["column_start"])
|
||||
|
||||
def test_account_layout_context_limit_is_enforced(self) -> None:
|
||||
with self.session_factory() as session:
|
||||
session.add_all(
|
||||
|
||||
Reference in New Issue
Block a user