Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Shares: Hide the widget outside WPCOM Simple, where share counts are never recorded.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ function get_unsupported_widget_types( $context ) {
// the same boundary, which excludes self-hosted Jetpack and Atomic sites.
if ( ! $context['is_wpcom_simple'] ) {
$unsupported[] = 'jpa/file-downloads';

// Share counts are recorded when the share request is processed, which
// only happens on WPCOM Simple. Elsewhere the button click is handled by
// the site itself and never reaches the counter, so the site summary's
// `shares_<service>` fields stay at zero however much the content is
// shared. Calypso excludes the module on the same grounds.
$unsupported[] = 'jpa/shares';
}

return $unsupported;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@ public function test_traffic_default_keeps_simple_only_widgets_on_wpcom_simple()
$this->assertContains( 'jpa/file-downloads', $layout_types );
}

/**
* Shares is Simple-only too, so the Insights default drops it on self-hosted
* Jetpack sites (this test env).
*/
public function test_insights_default_excludes_shares_on_self_hosted() {
$layout_types = array_column( get_dashboard_default_layout_for( DASHBOARD_INSIGHTS_SECTION_ID ), 'type' );

$this->assertNotContains( 'jpa/shares', $layout_types, 'Simple-only widget instances must not be part of the default layout on self-hosted sites.' );
$this->assertContains( 'jpa/tags', $layout_types, 'Regular widget instances remain in the default layout.' );
}

/**
* WPCOM Simple keeps Shares in the Insights default.
*/
public function test_insights_default_keeps_shares_on_wpcom_simple() {
Constants::set_constant( 'IS_WPCOM', true );

$layout_types = array_column( get_dashboard_default_layout_for( DASHBOARD_INSIGHTS_SECTION_ID ), 'type' );

$this->assertContains( 'jpa/shares', $layout_types );
}

/**
* Traffic section aliases resolve to the same default layout.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ private function widget_candidates() {
'name' => 'jpa/file-downloads',
'category' => 'traffic',
),
array(
'name' => 'jpa/shares',
'category' => 'traffic',
),
array(
'name' => 'jpa/hello-world',
'category' => 'demo',
Expand Down Expand Up @@ -155,6 +159,23 @@ public function test_type_policy_keeps_file_downloads_on_simple() {
$this->assertContains( 'jpa/file-downloads', $this->available_names( true ) );
}

/**
* Shares is unavailable outside WPCOM Simple, where nothing records a share.
*/
public function test_type_policy_removes_shares_on_non_simple() {
$names = $this->available_names( false );

$this->assertNotContains( 'jpa/shares', $names );
$this->assertContains( 'jpa/hello-world', $names );
}

/**
* WPCOM Simple keeps Shares.
*/
public function test_type_policy_keeps_shares_on_simple() {
$this->assertContains( 'jpa/shares', $this->available_names( true ) );
}

/**
* Non-array records pass through unchanged.
*/
Expand Down Expand Up @@ -362,9 +383,9 @@ public function test_uncategorized_widgets_are_not_capability_gated() {
}

/**
* The host callback removes File downloads on Atomic.
* The host callback removes the Simple-only types on Atomic.
*/
public function test_registry_callback_removes_file_downloads_on_atomic() {
public function test_registry_callback_removes_simple_only_types_on_atomic() {
Constants::set_constant( 'ATOMIC_SITE_ID', 123 );
Constants::set_constant( 'ATOMIC_CLIENT_ID', 456 );

Expand All @@ -374,12 +395,13 @@ public function test_registry_callback_removes_file_downloads_on_atomic() {
);

$this->assertNotContains( 'jpa/file-downloads', $names );
$this->assertNotContains( 'jpa/shares', $names );
}

/**
* The host callback keeps File downloads on WPCOM Simple.
* The host callback keeps the Simple-only types on WPCOM Simple.
*/
public function test_registry_callback_keeps_file_downloads_on_wpcom_simple() {
public function test_registry_callback_keeps_simple_only_types_on_wpcom_simple() {
Constants::set_constant( 'IS_WPCOM', true );

$names = array_column(
Expand All @@ -388,6 +410,7 @@ public function test_registry_callback_keeps_file_downloads_on_wpcom_simple() {
);

$this->assertContains( 'jpa/file-downloads', $names );
$this->assertContains( 'jpa/shares', $names );
}

/**
Expand Down
Loading