diff --git a/CHANGELOG.md b/CHANGELOG.md index c74e880c9..44719c24a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to - ♿️(frontend) fix modal aria-label and name #2014 - ♿️(frontend) fix language dropdown ARIA for screen readers #2020 - ♿️(frontend) fix waffle aria-label spacing for new-window links #2030 +- 🐛(backend) stop using add_sibling method to create sandbox document ## [v4.8.1] - 2026-03-17 diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 0cab0945c..d1869e132 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -285,8 +285,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin): ) return - sandbox_document = template_document.add_sibling( - "right", + sandbox_document = Document.add_root( title=template_document.title, content=template_document.content, attachments=template_document.attachments, diff --git a/src/backend/core/tests/test_models_users.py b/src/backend/core/tests/test_models_users.py index cbfa144ed..024d8b0a6 100644 --- a/src/backend/core/tests/test_models_users.py +++ b/src/backend/core/tests/test_models_users.py @@ -216,7 +216,13 @@ def test_models_users_duplicate_onboarding_sandbox_document_creates_sandbox(): When USER_ONBOARDING_SANDBOX_DOCUMENT is set with a valid template document, a new sandbox document should be created for the user with OWNER access. """ + documents_before = factories.DocumentFactory.create_batch(20) template_document = factories.DocumentFactory(title="Getting started with Docs") + documents_after = factories.DocumentFactory.create_batch(20) + + all_documents = documents_before + [template_document] + documents_after + + paths = {document.pk: document.path for document in all_documents} with override_settings(USER_ONBOARDING_SANDBOX_DOCUMENT=str(template_document.id)): user = factories.UserFactory() @@ -233,6 +239,10 @@ def test_models_users_duplicate_onboarding_sandbox_document_creates_sandbox(): access = models.DocumentAccess.objects.get(user=user, document=sandbox_doc) assert access.role == models.RoleChoices.OWNER + for document in all_documents: + document.refresh_from_db() + assert document.path == paths[document.id] + def test_models_users_duplicate_onboarding_sandbox_document_with_invalid_template_id(): """