Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Pull] Enable notifications by default #2448

Merged
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
1 change: 1 addition & 0 deletions js/src/components/enable-new-product-sync-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EnableNewProductSyncNotice = () => {
// Do not render if already switch to new product sync.
if (
! hasGoogleMCAccountFinishedResolution ||
! googleMCAccount.notification_service_enabled ||
googleMCAccount.wpcom_rest_api_status
) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ const ConnectedGoogleMCAccountCard = ( {
const showErrorNotificationsNotice =
! hideNotificationService &&
googleMCAccount.wpcom_rest_api_status &&
googleMCAccount.notification_service_enabled &&
googleMCAccount.wpcom_rest_api_status !==
GOOGLE_WPCOM_APP_CONNECTED_STATUS.APPROVED &&
googleMCAccount.wpcom_rest_api_status !==
GOOGLE_WPCOM_APP_CONNECTED_STATUS.DISABLED;
GOOGLE_WPCOM_APP_CONNECTED_STATUS.APPROVED;

const showFooter = ! hideAccountSwitch || showDisconnectNotificationsButton;

Expand Down
2 changes: 1 addition & 1 deletion src/API/WP/NotificationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ public function is_ready(): bool {
* @return bool
*/
public function is_enabled(): bool {
return apply_filters( 'woocommerce_gla_notifications_enabled', false );
return apply_filters( 'woocommerce_gla_notifications_enabled', true );
}
}
27 changes: 23 additions & 4 deletions src/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,30 @@

<?php if ( $blog_token ) { ?>
<?php
$wp_api_status = $this->container->get( OptionsInterface::class )->get( OptionsInterface::WPCOM_REST_API_STATUS );
$options = $this->container->get( OptionsInterface::class );
$wp_api_status = $options->get( OptionsInterface::WPCOM_REST_API_STATUS );
$notification_service = new NotificationsService( $this->container->get( MerchantCenterService::class ) );
$notification_service->set_options_object( $options );

Check warning on line 656 in src/ConnectionTest.php

View check run for this annotation

Codecov / codecov/patch

src/ConnectionTest.php#L653-L656

Added lines #L653 - L656 were not covered by tests
?>
<h2 class="title">Partner API Pull Integration</h2>
<form action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" method="GET">
<table class="form-table" role="presentation">
<tr>
<th><label>Notification Service Enabled:</label></th>
<td>
<p>
<code><?php echo $notification_service->is_enabled() ? 'yes' : 'no' ?></code>

Check warning on line 665 in src/ConnectionTest.php

View check run for this annotation

Codecov / codecov/patch

src/ConnectionTest.php#L665

Added line #L665 was not covered by tests
</p>
</td>
</tr>
<tr>
<th><label>Notification Service Ready:</label></th>
<td>
<p>
<code><?php echo $notification_service->is_ready() ? 'yes' : 'no' ?></code>

Check warning on line 673 in src/ConnectionTest.php

View check run for this annotation

Codecov / codecov/patch

src/ConnectionTest.php#L673

Added line #L673 was not covered by tests
</p>
</td>
</tr>
<tr>
<th><label>WPCOM REST API Status:</label></th>
<td>
Expand Down Expand Up @@ -693,7 +712,7 @@
<tr>
<th><label>API Pull Integration Status:</label></th>
<td>
<p>
<p>
<a class="button" href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'action' => 'partner-integration-status' ], $url ), 'partner-integration-status' ) ); ?>">Get API Pull Integration Status</a>
</p>
</td>
Expand All @@ -714,7 +733,7 @@
<code><?php echo isset( $this->integration_status_response['is_healthy'] ) && $this->integration_status_response['is_healthy'] === true ? 'Healthy' : 'Unhealthy'; ?></code>
</p>
</td>
</tr>
</tr>
<tr>
<th><label>Last Jetpack Contact:</label></th>
<td>
Expand Down Expand Up @@ -746,7 +765,7 @@
<code><?php echo isset( $this->integration_status_response['errors'] ) ? wp_kses_post( json_encode( $this->integration_status_response['errors'] ) ) ?? '' : '-'; ?></code>
</p>
</td>
</tr>
</tr>
<?php } ?>
</table>
<?php wp_nonce_field( 'partner-notification' ); ?>
Expand Down
7 changes: 4 additions & 3 deletions src/MerchantCenter/AccountService.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ public function get_connected_status(): array {
$wpcom_rest_api_status = $this->options->get( OptionsInterface::WPCOM_REST_API_STATUS );

$status = [
'id' => $id,
'status' => $id ? 'connected' : 'disconnected',
'wpcom_rest_api_status' => $notifications_service->is_enabled() ? $wpcom_rest_api_status : 'disabled',
'id' => $id,
'status' => $id ? 'connected' : 'disconnected',
'notification_service_enabled' => $notifications_service->is_enabled(),
'wpcom_rest_api_status' => $wpcom_rest_api_status,
];

$incomplete = $this->state->last_incomplete_step();
Expand Down
23 changes: 13 additions & 10 deletions tests/Unit/MerchantCenter/AccountServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,10 @@ public function test_get_connected_status() {

$this->assertEquals(
[
'id' => self::TEST_ACCOUNT_ID,
'status' => 'connected',
'wpcom_rest_api_status' => 'approved',
'id' => self::TEST_ACCOUNT_ID,
'status' => 'connected',
'notification_service_enabled' => true,
'wpcom_rest_api_status' => 'approved',
],
$this->account->get_connected_status()
);
Expand All @@ -788,9 +789,10 @@ public function test_get_connected_status_when_notifications_disabled() {

$this->assertEquals(
[
'id' => self::TEST_ACCOUNT_ID,
'status' => 'connected',
'wpcom_rest_api_status' => 'disabled',
'id' => self::TEST_ACCOUNT_ID,
'status' => 'connected',
'notification_service_enabled' => false,
'wpcom_rest_api_status' => 'approved',
],
$this->account->get_connected_status()
);
Expand All @@ -811,10 +813,11 @@ public function test_get_connected_status_incomplete() {

$this->assertEquals(
[
'id' => self::TEST_ACCOUNT_ID,
'status' => 'incomplete',
'step' => 'verify',
'wpcom_rest_api_status' => null,
'id' => self::TEST_ACCOUNT_ID,
'status' => 'incomplete',
'step' => 'verify',
'notification_service_enabled' => true,
'wpcom_rest_api_status' => null,
],
$this->account->get_connected_status()
);
Expand Down