mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-14 09:08:32 +00:00
Merge branch '3452-creating-an-element-with-an-invalid-parent_element_id-fails-hard' into 'develop'
Resolve "Creating an element with an invalid parent_element_id fails hard." Closes #3452 See merge request baserow/baserow!3156
This commit is contained in:
commit
07a0b40c25
3 changed files with 24 additions and 0 deletions
backend
src/baserow/contrib/builder/api/elements
tests/baserow/contrib/builder/api/elements
changelog/entries/unreleased/bug
|
@ -134,6 +134,7 @@ class ElementsView(APIView):
|
||||||
@map_exceptions(
|
@map_exceptions(
|
||||||
{
|
{
|
||||||
PageDoesNotExist: ERROR_PAGE_DOES_NOT_EXIST,
|
PageDoesNotExist: ERROR_PAGE_DOES_NOT_EXIST,
|
||||||
|
ElementDoesNotExist: ERROR_ELEMENT_DOES_NOT_EXIST,
|
||||||
ElementNotInSamePage: ERROR_ELEMENT_NOT_IN_SAME_PAGE,
|
ElementNotInSamePage: ERROR_ELEMENT_NOT_IN_SAME_PAGE,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -206,6 +206,22 @@ def test_create_element_page_does_not_exist(api_client, data_fixture):
|
||||||
assert response.json()["error"] == "ERROR_PAGE_DOES_NOT_EXIST"
|
assert response.json()["error"] == "ERROR_PAGE_DOES_NOT_EXIST"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_create_element_parent_does_not_exist(api_client, data_fixture):
|
||||||
|
user, token = data_fixture.create_user_and_token()
|
||||||
|
page = data_fixture.create_builder_page(user=user)
|
||||||
|
|
||||||
|
url = reverse("api:builder:element:list", kwargs={"page_id": page.id})
|
||||||
|
response = api_client.post(
|
||||||
|
url,
|
||||||
|
{"type": "heading", "parent_element_id": 99999999},
|
||||||
|
format="json",
|
||||||
|
HTTP_AUTHORIZATION=f"JWT {token}",
|
||||||
|
)
|
||||||
|
assert response.status_code == HTTP_404_NOT_FOUND
|
||||||
|
assert response.json()["error"] == "ERROR_ELEMENT_DOES_NOT_EXIST"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_update_element(api_client, data_fixture):
|
def test_update_element(api_client, data_fixture):
|
||||||
user, token = data_fixture.create_user_and_token()
|
user, token = data_fixture.create_user_and_token()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"type": "bug",
|
||||||
|
"message": "[Builder] Resolved a bug where creating an element with an invalid parent would raise an error.",
|
||||||
|
"issue_number": 3452,
|
||||||
|
"bullet_points": [],
|
||||||
|
"created_at": "2025-02-14"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue