Local Mocks
During development, sometimes you need to mock resources locally. The system serves anything inside of the /mocks
folder from the root of your website when developing locally. This functionality exists to make local development more convenient, but note that mock resources are not available in Production.
Mocking Sites from your Sandbox or Production environments
When running PageBuilder locally, by default, no sites are defined. You configure your sites in Site Service for Arc XP environments. In order to replicate the list of sites and sections you have, you must copy the response of the Site Service’s Arc Admin API response.
- Log in to Arc XP.
- Open your browser’s developer tools and navigate to network tab and type
website
in the filter box in network panel. This shows the site service API call after the next step. - Click PageBuilder Editor. Your Pages page opens, displaying the site service call to your arcpublishing domain. (Ensure you are in the environment you want to copy site service settings from. If you are not in the right environment, open the Arc XP navigation and switch to the environment you want).Â
- Click the Response tab of this request.
- Copy the contents of this network response to your local mock file for the site service, which is located in the
/mocks/siteservice/api/v3/website
file. This file corresponds to the API call you copied the request from. - Save this file. Your PageBuilder Editor and Engine start using the site service configuration you copied in your local instance.
Disabling Privacy Banner
You may want to turn off Arc XP’s Privacy Banner in your local environment to minimize distractions. The banner has no function locally, and, as a result, you cannot permanently dismiss the banner by clicking either Reject or Accept while working in your local PageBuilder instance. To disable the banner permanently, add the "tracking": false
 property to your mocked user object in ./mocks/user
.
Service Workers
One use case for the /mocks
folder is to install a Service Worker at the root scope of your website. You can mock this functionality by placing the service worker script inside the /mocks
folder of our feature pack. This allows you to customize and test the service worker locally.
Moving to Production
If resources are required for your Production website, we recommend that those resources are moved to the /resources
folder of your feature pack. For resources that must be located at the root of your website, the Arc Delivery team can configure your Content Delivery Network to ensure that specific resources are served from the correct location.
Mocking permissions
Your local environment is disconnected from Arc XP’s permissions system. Without mocking the permissions, you are not be able to perform any changes to your local environment. When you receive the initial bundle from Arc XP, a file appears in ./mocks/user
. The permissions in that file are the permissions you need when you first join Arc XP. Over time, you likely add or remove permissions.
For you to have full access in your local environment, use the following updated list and override the content in ./mocks/user
:
{ "displayName": "Local Fusion Developer", "permissions": { "PageBuilder": { "global": [ "W", "D", "P", "VRP", "ERP", "DT", "RE", "RD" ] } }}