Merge pull request #37907 from KerollesFathy/workspace-route-conflict

fix: route conflict not detected when workspace matches existing doctype
This commit is contained in:
Ejaaz Khan 2026-03-11 14:22:36 +05:30 committed by GitHub
commit 9e93965315
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -13,6 +13,15 @@ class TestWorkspace(IntegrationTestCase):
frappe.db.delete("DocType", {"module": "Test Module"})
frappe.delete_doc("Module Def", "Test Module")
def test_workspace_conflicts_with_existing_doctype(self):
"""Workspace name should not conflict with existing DocType names."""
create_doctype("Test", "Test Module")
workspace = create_workspace(name="Test", label="Test", public=1, title="Test")
with self.assertRaises(frappe.NameError):
workspace.insert()
# TODO: FIX ME - flaky test!!!
# def test_workspace_with_cards_specific_to_a_country(self):
# workspace = create_workspace()
@ -65,6 +74,8 @@ def create_workspace(**args):
workspace.category = args.category or "Modules"
workspace.is_standard = args.is_standard or 1
workspace.module = "Test Module"
workspace.public = args.public or 0
workspace.title = args.title or "Test Workspace"
return workspace

View file

@ -17,7 +17,11 @@ def validate_route_conflict(doctype, name):
all_names = []
for _doctype in ["Page", "Workspace", "DocType"]:
all_names.extend(
[slug(d) for d in frappe.get_all(_doctype, pluck="name") if (doctype != _doctype and d != name)]
[
slug(d)
for d in frappe.get_all(_doctype, pluck="name")
if not (doctype == _doctype and d == name)
]
)
if slug(name) in all_names: