-
Notifications
You must be signed in to change notification settings - Fork 328
Enhancement/#11643 - Add amp mode to Google Proxy features request #11774
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
Enhancement/#11643 - Add amp mode to Google Proxy features request #11774
Conversation
|
Build files for 3a7a560 have been deleted. |
ankitrox
left a comment
There was a problem hiding this 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. 👍🏼
techanvil
left a comment
There was a problem hiding this 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.
| 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.' ); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
… consolidate feature retrieval logic.
techanvil
left a comment
There was a problem hiding this 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!
✅
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist