Repository: SFDO-Tooling/CumulusCI
Pull request #3411 (2022-10-25 19:05:38)

Fixed bug preventing the `deploy_omni_studio_site_settings` task from deploying to scratch orgs with the new `.scratch.` domain names
# Changes

Altered the omnistudio remote site setting endpoints to properly handle scratch org domain urls.

_warning_ need to figure out elegant way to handle all [partitioned domains](https://help.salesforce.com/s/articleView?id=sf.domain_name_partitioned_domains.htm&type=5).



Patch:
diff --git a/cumulusci/tasks/vlocity/vlocity.py b/cumulusci/tasks/vlocity/vlocity.py
index 92d8b1847..6d523e7e1 100644
--- a/cumulusci/tasks/vlocity/vlocity.py
+++ b/cumulusci/tasks/vlocity/vlocity.py
@@ -112,15 +112,24 @@ class OmniStudioDeployRemoteSiteSettings(AddRemoteSiteSettings):
 
     def _get_options(self) -> RSSOptions:
         namespace = self.options.get("namespace") or OMNI_NAMESPACE
-
-        visualforce_url: str = self.org_config.instance_url.replace(
-            ".my.salesforce.com",
-            f"--{namespace}.{self.org_config.instance_name}.visual.force.com",
-        )
-        legacy_visualforce_url: str = self.org_config.instance_url.replace(
-            ".my.salesforce.com",
-            f"--{namespace}.vf.force.com",
-        )
+        if ".scratch.my" in self.org_config.instance_url:
+            visualforce_url: str = self.org_config.instance_url.replace(
+                ".scratch.my.salesforce.com",
+                f"--{namespace}.scratch.{self.org_config.instance_name}.visual.force.com",
+            )
+            legacy_visualforce_url: str = self.org_config.instance_url.replace(
+                ".scratch.my.salesforce.com",
+                f"--{namespace}.scratch.vf.force.com",
+            )
+        else:
+            visualforce_url: str = self.org_config.instance_url.replace(
+                ".my.salesforce.com",
+                f"--{namespace}.{self.org_config.instance_name}.visual.force.com",
+            )
+            legacy_visualforce_url: str = self.org_config.instance_url.replace(
+                ".my.salesforce.com",
+                f"--{namespace}.vf.force.com",
+            )
         lightning_url: str = self.org_config.instance_url.replace(
             ".my.salesforce.com", ".lightning.force.com"
         )
diff --git a/cumulusci/version.txt b/cumulusci/version.txt
index f49ec37e1..b62170299 100644
--- a/cumulusci/version.txt
+++ b/cumulusci/version.txt
@@ -1,1 +1,1 @@
-3.68.0.dev1
+3.68.0.dev2


Test patch:
diff --git a/cumulusci/tasks/vlocity/tests/test_vlocity.py b/cumulusci/tasks/vlocity/tests/test_vlocity.py
index 9a77a9728..eb7b1d75a 100644
--- a/cumulusci/tasks/vlocity/tests/test_vlocity.py
+++ b/cumulusci/tasks/vlocity/tests/test_vlocity.py
@@ -110,13 +110,45 @@ def test_vlocity_build_tool_missing(project_config):
             task._init_task()
 
 
-namespace = "cci"
+namespace = "omnistudio"
 test_cases = [
     (TaskConfig(config={}), OMNI_NAMESPACE),
     (TaskConfig(config={"options": {"namespace": namespace}}), namespace),
 ]
 
 
+@pytest.mark.parametrize("task_config,expected_namespace", test_cases)
+def test_deploy_omni_studio_site_settings_scratch(
+    project_config, task_config, expected_namespace
+):
+    org_config = mock.Mock(
+        installed_packages=[],
+        instance_url="https://inspiration-velocity-34802-dev-ed.scratch.my.salesforce.com/",
+        instance_name="CS28",
+        scratch=True,
+    )
+
+    task = OmniStudioDeployRemoteSiteSettings(project_config, task_config, org_config)
+    rss_options = task._get_options()
+    records = rss_options.records
+
+    expected_site_names = set([VF_RSS_NAME, VF_LEGACY_RSS_NAME, LWC_RSS_NAME])
+    actual_site_names = set([r.full_name for r in records])
+    assert expected_site_names == actual_site_names
+
+    # when no 'namespace' option is specified, we default to the omni studio namespace
+    expected_urls = set(
+        [
+            f"https://inspiration-velocity-34802-dev-ed--{expected_namespace}.scratch.{org_config.instance_name}.visual.force.com/",
+            "https://inspiration-velocity-34802-dev-ed.scratch.lightning.force.com/",
+            f"https://inspiration-velocity-34802-dev-ed--{expected_namespace}.scratch.vf.force.com/",
+        ]
+    )
+
+    actual_urls = set([r.url for r in records])
+    assert expected_urls == actual_urls
+
+
 @pytest.mark.parametrize("task_config,expected_namespace", test_cases)
 def test_deploy_omni_studio_site_settings(
     project_config, task_config, expected_namespace