Skip to content

Commit

Permalink
Ensure duplicate menu instances are merged
Browse files Browse the repository at this point in the history
This is sort of a recurrance of an issue I introduced in
#33037 and then fixed in
#33271 See that second PR
description for details

This was then broken in this commit:
8db8f4a
The test created in that second PR above demonstrated that instances in
the second of two modules with the same ID will be propagated to all
forms in both modules, but it neglected to verify that same property of
instances required by the first of those two modules.  That latest commit above
had subsequent menus overwriting instances from earlier ones.
  • Loading branch information
esoergel committed Sep 11, 2023
1 parent 2be6c2f commit ae6f87e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _menu_xpaths_by_command(self):
# multiple menus can have the same ID - merge them first
xpaths_by_menu_id = defaultdict(set)
for menu in self.suite.menus:
xpaths_by_menu_id[menu.id] = menu.get_all_xpaths()
xpaths_by_menu_id[menu.id].update(menu.get_all_xpaths())

return defaultdict(set, {
command.id: xpaths_by_menu_id[menu.id]
Expand Down
6 changes: 5 additions & 1 deletion corehq/apps/app_manager/tests/test_suite_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,18 @@ def test_module_filter_instances_on_all_forms_merged_modules(self):
# and if two modules are display_in_root, then on forms in the other module too
factory = AppFactory(build_version='2.20.0') # enable_module_filtering
self.m0, self.m0f0 = factory.new_basic_module('m0', 'case1')
self.m0.module_filter = "instance('groups')/groups/"
self.m0.put_in_root = True

self.m1, self.m1f0 = factory.new_basic_module('m1', 'case1')
self.m1.module_filter = "instance('locations')/locations/"
self.m1.put_in_root = True

suite = factory.app.create_suite()
instance_xml = "<partial><instance id='locations' src='jr://fixture/locations' /></partial>"
instance_xml = """<partial>
<instance id='groups' src='jr://fixture/user-groups' />
<instance id='locations' src='jr://fixture/locations' />
</partial>"""
self.assertXmlPartialEqual(instance_xml, suite, "entry/command[@id='m0-f0']/../instance")
self.assertXmlPartialEqual(instance_xml, suite, "entry/command[@id='m1-f0']/../instance")

Expand Down

0 comments on commit ae6f87e

Please sign in to comment.