Skip to content

Conversation

@hussain-t
Copy link
Collaborator

@hussain-t hussain-t commented Nov 16, 2025

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions
Copy link

github-actions bot commented Nov 16, 2025

Build files for 3a7a560 have been deleted.

Copy link
Collaborator

@ankitrox ankitrox left a comment

Choose a reason for hiding this comment

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

Thank you for the nice work @hussain-t.

This looks good to me. Moving this to MR. 👍🏼

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Hey @hussain-t, this looks good but it would be nice to avoid the duplication in the tests.

Comment on lines 442 to 482
public function test_get_features_with_amp_primary() {
// Remove the filter being added by Modules::register() or any other class during bootstrap.
remove_all_filters( 'googlesitekit_feature_metrics' );

list ( $credentials, $site_id, $site_secret ) = $this->get_credentials();

$amp_primary_context = $this->get_amp_primary_context();
$google_proxy = new Google_Proxy( $amp_primary_context );

$expected_url = $google_proxy->url( Google_Proxy::FEATURES_URI );
$expected_success_response = array(
'test.featureName' => array( 'enabled' => true ),
);

$this->mock_http_request( $expected_url, $expected_success_response );
$google_proxy->get_features( $credentials, new OAuth_Client( $amp_primary_context, null, null, $credentials, $google_proxy ) );

// Ensure amp_mode is set to 'primary'.
$this->assertEquals( 'primary', $this->request_args['body']['amp_mode'], 'Get features request should include primary amp_mode.' );
}

public function test_get_features_with_amp_secondary() {
// Remove the filter being added by Modules::register() or any other class during bootstrap.
remove_all_filters( 'googlesitekit_feature_metrics' );

list ( $credentials, $site_id, $site_secret ) = $this->get_credentials();

$amp_secondary_context = $this->get_amp_secondary_context();
$google_proxy = new Google_Proxy( $amp_secondary_context );

$expected_url = $google_proxy->url( Google_Proxy::FEATURES_URI );
$expected_success_response = array(
'test.featureName' => array( 'enabled' => true ),
);

$this->mock_http_request( $expected_url, $expected_success_response );
$google_proxy->get_features( $credentials, new OAuth_Client( $amp_secondary_context, null, null, $credentials, $google_proxy ) );

// Ensure amp_mode is set to 'secondary'.
$this->assertEquals( 'secondary', $this->request_args['body']['amp_mode'], 'Get features request should include secondary amp_mode.' );
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These tests are duplicates other than the AMP context argument passed to new Google_Proxy(), I'd suggest using a data provider to avoid duplicating the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Thanks @hussain-t, that's great. LGTM!

@techanvil techanvil changed the base branch from develop to main November 25, 2025 10:40
@techanvil techanvil merged commit 8935320 into main Nov 25, 2025
28 of 30 checks passed
@techanvil techanvil deleted the enhancement/#11643-extend-features-request-amp-mode branch November 25, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants