Repository navigation
Payments admin JS: keep other gateways' Capture row hidden, show Refunded status without reload #3616
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
base: master
Are you sure you want to change the base?
Payments admin JS: keep other gateways' Capture row hidden, show Refunded status without reload #3616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,33 @@ public function test_maybe_use_decimal() { | |
| $this->assertSame( '111.500', $amount ); | ||
|
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.
|
||
| } | ||
|
|
||
| public function test_echo_capture_payment_upsell_is_hidden_unless_stripe_is_selected() { | ||
| $action = new FrmTransLiteAction(); | ||
|
|
||
| $this->assertStringContainsString( 'display: none', $this->get_capture_payment_upsell( $action, array( 'paypal' ) ) ); | ||
|
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.
|
||
| $this->assertStringContainsString( 'display: none', $this->get_capture_payment_upsell( $action, array( 'square' ) ) ); | ||
|
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.
|
||
| $this->assertStringNotContainsString( 'display: none', $this->get_capture_payment_upsell( $action, array( 'stripe' ) ) ); | ||
|
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.
|
||
| } | ||
|
|
||
| public function test_actions_js_localizes_the_refunded_label() { | ||
| FrmTransLiteActionsController::actions_js(); | ||
|
|
||
| $data = wp_scripts()->get_data( 'frmtrans_admin', 'data' ); | ||
| $this->assertStringContainsString( '"refunded":"' . FrmTransLiteAppHelper::show_status( 'refunded' ) . '"', $data ); | ||
|
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.
|
||
| } | ||
|
|
||
| /** | ||
| * @param FrmTransLiteAction $action | ||
| * @param array $gateway | ||
| * | ||
| * @return string | ||
| */ | ||
| private function get_capture_payment_upsell( $action, $gateway ) { | ||
| ob_start(); | ||
| $action->echo_capture_payment_upsell( $gateway ); | ||
| return ob_get_clean(); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $amount | ||
| * @param array $currency | ||
|
|
||
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.
Non-blocking: this duplicates the hide-other-gateway-rows loop in
toggleGateway()(thetoggleOff.forEachblock). Consider one shared helper, or scoping thetoggleOpts( this, ! show, '.frm_gateway_no_recur' )call intoggleSub()so it never reveals rows that belong to an unselected gateway.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.
Keeping this as is. The two loops don't select the same set:
toggleGateway()hides every.show_<other gateway>element in the action unless it carries the selected gateway's class, whilehideOtherGatewayRows()only touches.frm_gateway_no_recurrows, the onestoggleOpts()just revealed. Sharing one helper means changing whattoggleGateway()hides, and that handler has no JS test. Scoping thetoggleOpts()call instead means a third selector form in a function that is also used for thefrm_trans_sub_optsslide. I would rather do either as its own change with a way to test it. Happy to open a follow-up.