Skip to content

Added sandbox mode - #85

Open
jimjasson wants to merge 3 commits into
developfrom
add/sandbox-mode
Open

Added sandbox mode#85
jimjasson wants to merge 3 commits into
developfrom
add/sandbox-mode

Conversation

@jimjasson

@jimjasson jimjasson commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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_mode WordPress option and does not add a public UI setting.

The sandbox mode:

  • Simulates completed onboarding and a connected Snapchat account.
  • Provides dummy organization, ad account, and pixel details.
  • Keeps sandbox conversion and PII settings isolated from production settings.
  • Prevents remote requests to WordPress.com and Snapchat.
  • Suppresses usage tracking while sandbox mode is active.
  • Prevents automatic product catalog exports and remote product-feed synchronization.
  • Disables account disconnect and CSV generation actions.
  • Adds hover explanations to disabled actions.
  • Displays a persistent sandbox-mode notice on the settings page.
  • Keeps the implementation isolated through WordPress hooks and a dedicated sandbox service.

Screenshots:

Markup on 2026-08-12 at 14:43:24

Detailed test instructions:

  1. Ensure that on a fresh site you can connect Snapchat without issues and all the features that work in the latest stable version continue to work.
  2. On a fresh site where Snapchat is not onboarded yet, run the following command to enable Sandbox mode: wp option update snapchat_sandbox_mode yes.
  3. Go to Marketing > Snapchat.
  4. Ensure that onboarding does not start automatically, and instead the post-onboarding settings are rendered.
  5. Ensure that you see a message that notifies you that you are in sandbox mode.
  6. Ensure that a dummy account details show up in the connected account section.
  7. Ensure that CSV generation and disconnecting accounts are disabled with an explanation.
  8. Ensure that you can change the rest of the settings.
  9. Run: wp option update snapchat_sandbox_mode no`.
  10. Go to Marketing > Snapchat.
  11. Ensure that onboarding starts.

Additional details:

Changelog entry

Dev - Added sandbox mode.

@jimjasson jimjasson self-assigned this Aug 12, 2026
@github-actions github-actions Bot added the status: e2e tests passing E2E tests are passing on the PR label Aug 12, 2026
@jimjasson jimjasson added the changelog: dev Developer-facing only change. label Aug 12, 2026
@jimjasson
jimjasson requested a lite review from Copilot August 12, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SandboxMode service 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.

Comment thread js/src/components/sandbox-disabled-control/index.js Outdated
Comment thread includes/SandboxMode.php
Comment thread includes/Connection/WcsClient.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 integer 1), 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 in SandboxDisabledControl, 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 } />
		);

@jimjasson
jimjasson marked this pull request as ready for review August 12, 2026 14:36

@asvinb asvinb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimjasson I left some notes on the PR. Can you kindly check them out please? Thanks!

Comment thread js/src/pages/settings/index.js Outdated
Comment thread js/src/pages/settings/product-catalog/index.js Outdated
Comment thread js/src/components/sandbox-disabled-control/index.js Outdated
@jimjasson
jimjasson requested a review from asvinb August 17, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: dev Developer-facing only change. status: e2e tests passing E2E tests are passing on the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants