-
Notifications
You must be signed in to change notification settings - Fork 69
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
Allow non-account-owner admin users to submit the payment activity survey #8739
Merged
Jinksi
merged 8 commits into
develop
from
fix/8710-payment-activity-survey-all-admin-users
May 2, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5b27f94
Use `remote_request` when requesting survey endpoint to allow non-acc…
Jinksi ef896f3
Use Jetpack connection owner user token when making POST request
Jinksi 71a3161
Add `remote_request` `$use_user_token` docblock detail to mention it …
Jinksi a581fed
Add changelog entry
Jinksi f9e7096
Update test `test_valid_request_forwards_data_to_jetpack` to use `rem…
Jinksi 66a13f8
Merge branch 'develop' into fix/8710-payment-activity-survey-all-admi…
Jinksi 8315a22
Merge branch 'develop' into fix/8710-payment-activity-survey-all-admi…
shendy-a8c 2334113
Merge branch 'develop' into fix/8710-payment-activity-survey-all-admi…
Jinksi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fix | ||
Comment: Part of Payment Activity Card behind feature flag. Allow non-accountholder users to submit the feedback survey. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ public function setUp(): void { | |
// Set the user so that we can pass the authentication. | ||
wp_set_current_user( 1 ); | ||
|
||
$this->http_client_stub = $this->getMockBuilder( WC_Payments_Http::class )->disableOriginalConstructor()->setMethods( [ 'wpcom_json_api_request_as_user' ] )->getMock(); | ||
$this->http_client_stub = $this->getMockBuilder( WC_Payments_Http::class )->disableOriginalConstructor()->setMethods( [ 'remote_request' ] )->getMock(); | ||
$this->controller = new WC_REST_Payments_Survey_Controller( $this->http_client_stub ); | ||
} | ||
|
||
|
@@ -63,33 +63,42 @@ public function test_empty_rating_returns_400_status_code() { | |
$this->assertEquals( 400, $response->get_status() ); | ||
} | ||
|
||
|
||
public function test_valid_request_forwards_data_to_jetpack() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How important and useful is this e2e test, considering that the survey has a limited lifespan? |
||
$request_url = WC_Payments_API_Client::ENDPOINT_BASE . '/marketing/survey'; | ||
|
||
$this->http_client_stub | ||
->expects( $this->any() ) | ||
->method( 'wpcom_json_api_request_as_user' ) | ||
->method( 'remote_request' ) | ||
->with( | ||
$this->stringContains( '/marketing/survey' ), | ||
$this->anything(), | ||
$this->anything(), | ||
// Check the request argument URL is the same. | ||
$this->callback( | ||
function ( $argument ) use ( $request_url ) { | ||
return $request_url === $argument['url']; | ||
} | ||
), | ||
$this->logicalAnd( | ||
$this->arrayHasKey( 'survey_id' ), | ||
$this->arrayHasKey( 'survey_responses' ), | ||
$this->callback( | ||
function ( $argument ) { | ||
return 'wcpay-payment-activity' === $argument['survey_id']; | ||
$json_body = json_decode( $argument, true ); | ||
return 'wcpay-payment-activity' === $json_body['survey_id']; | ||
} | ||
), | ||
$this->callback( | ||
function ( $argument ) { | ||
return 'happy' === $argument['survey_responses']['rating']; | ||
$json_body = json_decode( $argument, true ); | ||
return 'happy' === $json_body['survey_responses']['rating']; | ||
} | ||
), | ||
$this->callback( | ||
function ( $argument ) { | ||
return 'test comment' === $argument['survey_responses']['comments']['text']; | ||
$json_body = json_decode( $argument, true ); | ||
return 'test comment' === $json_body['survey_responses']['comments']['text']; | ||
} | ||
) | ||
) | ||
), | ||
), | ||
$this->isTrue(), | ||
$this->isTrue(), | ||
) | ||
->willReturn( | ||
[ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I've added this distinction here, which would have helped me resolve this issue.
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.
Should we change the name of this param?
user_token
seems misleading.