Added sandbox mode - #85
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a sandbox mode to Snapchat for WooCommerce, controlled by the snapchat_sandbox_mode WP option, to let merchants explore the post-onboarding settings experience without connecting real accounts or triggering remote side effects.
Changes:
- Introduces a
SandboxModeservice that simulates connected/onboarded state, blocks selected REST mutations, disables tracking options, and blocks WCS remote requests. - Updates the settings UI to show a persistent sandbox notice and disables key actions (CSV generation, disconnect) with hover explanations.
- Adds unit coverage for core sandbox behaviors (option enablement, virtual onboarding state, REST interception, tracking/request blocking) and documents sandbox usage in the README.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/SandboxModeTest.php | Adds unit tests validating sandbox mode behavior and isolation. |
| README.md | Documents how to enable/disable sandbox mode via WP-CLI. |
| js/src/utils/tracks.js | Suppresses plugin event tracking while sandbox mode is active. |
| js/src/pages/settings/product-catalog/index.js | Disables CSV generation UI and prevents auto-export triggers in sandbox. |
| js/src/pages/settings/linked-accounts.js | Disables disconnect UI in sandbox and adds tooltip explanation wrapper. |
| js/src/pages/settings/index.scss | Styles the sandbox-mode settings notice container. |
| js/src/pages/settings/index.js | Displays a persistent sandbox-mode notice on the settings page. |
| js/src/components/snapchat-account-card/connected-snapchat-account-card.js | Disables account switch control in sandbox mode. |
| js/src/components/sandbox-disabled-control/index.scss | Adds styling to present disabled controls as non-interactive while allowing hover. |
| js/src/components/sandbox-disabled-control/index.js | Adds a wrapper component for tooltip explanations on disabled controls in sandbox. |
| includes/SandboxMode.php | Implements sandbox mode via option filters, REST interception, and export-hook disabling. |
| includes/Plugin.php | Registers sandbox hooks during plugin bootstrap. |
| includes/Connection/WcsClient.php | Blocks WCS proxy requests while sandbox is enabled. |
| includes/Admin/Assets.php | Exposes sandboxMode to the admin JS via localized data. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tests/Unit/SandboxModeTest.php:87
SandboxMode::is_enabled()explicitly treats the string value'1'as enabled (in addition to integer1), but the data provider doesn’t cover the'1'case. Adding it would ensure the most common DB-stored representation is tested.
public function enabled_values_provider(): array {
return array(
'yes' => array( 'yes' ),
'true' => array( true ),
'integer' => array( 1 ),
'on' => array( 'on' ),
);
js/src/components/snapchat-account-card/connected-snapchat-account-card.js:20
- In sandbox mode the “connect a different Snapchat account” action is disabled via
disabled={ sfwData.sandboxMode }, but unlike the disconnect/CSV actions it isn’t wrapped inSandboxDisabledControl, so there’s no hover/focus explanation for why the control is disabled. This looks inconsistent with the PR goal of providing explanations for disabled actions in sandbox mode.
return (
<SwitchAccountButton isTertiary disabled={ sfwData.sandboxMode } />
);
asvinb
left a comment
There was a problem hiding this comment.
@jimjasson I left some notes on the PR. Can you kindly check them out please? Thanks!
Changes proposed in this Pull Request:
Closes STRPAR-140
This PR adds an isolated sandbox mode that lets merchants explore the post-onboarding Snapchat for WooCommerce experience without connecting WordPress.com or Snapchat accounts.
Sandbox mode is controlled through the
snapchat_sandbox_modeWordPress option and does not add a public UI setting.The sandbox mode:
Screenshots:
Detailed test instructions:
wp option update snapchat_sandbox_mode yes.Additional details:
Changelog entry