Conversation
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
…e to send the customer Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
…rejects Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
vitormattos
left a comment
There was a problem hiding this comment.
The integration test setup looks good overall, and the test structure is much better now.
I left one change request in AccountTest.php. The test for the missing libresign/saas-onboarding pattern is making a known incomplete behavior part of the expected test suite.
I do not think this PR needs to implement the missing pattern, but I think this test should be removed and the missing pattern should be tracked separately.
After this is adjusted, I do not see another blocker in this PR.
| public function test_keeps_the_shop_content_since_the_onboarding_pattern_does_not_exist() { | ||
| $shop = self::factory()->post->create( array( 'post_type' => 'page' ) ); | ||
| update_option( 'woocommerce_shop_page_id', $shop ); | ||
| $this->in_the_loop_of( get_permalink( $shop ) ); | ||
|
|
||
| $this->assertSame( '<p>Shop</p>', libresign_theme_prepend_saas_onboarding_to_content( '<p>Shop</p>' ) ); | ||
| } |
There was a problem hiding this comment.
This test makes the missing libresign/saas-onboarding pattern an expected behavior.
The code in inc/account.php says that this pattern should be added to the shop and checkout pages, so the current behavior does not match the intended behavior.
I do not think we need to fix the missing pattern in this PR because that would increase the scope of this change. But I also do not think we should keep a test that will fail when this known issue is fixed.
Could we remove this test from this PR and track the missing pattern separately?
The theme had no tests beyond a shell smoke test of the deploy webhook. This adds a PHPUnit suite that runs against a real WordPress with WooCommerce, plus a workflow for it.
Suite
composer testrunsphpunit-integration.xml.dist.composer installbrings in WordPress, the WordPress test suite (wp-phpunit) and WooCommerce; the tests only need a MySQL/MariaDB database. The bootstrap loads WooCommerce and activates this theme from the repository folder.tests/Integration/Inc/AccountTest.phpforinc/account.php,tests/Integration/Woocommerce/Myaccount/FormLoginTest.phpfor the login template override.donatj/mock-webserver. Calls toapi.github.comhave fixed URLs, so they are answered throughpre_http_request. Any other outgoing request fails the test.phpunit.ymlruns the suite on the PHP versions fromcomposer.json, with actions pinned by SHA.readme.txtsays how to run it, locally and on the SaaS stack.The tests describe what the theme does today, including a few things worth knowing:
libresign/saas-onboardingpattern thatinc/account.phpprepends to the shop and checkout is not registered, so nothing is prepended.Fixes
Each one comes with a test that failed before the fix.
redirect_toas an array:libresign_theme_get_purchase_redirect_target()passed$_REQUEST['redirect_to']towp_validate_redirect()without checking it is a string, so?redirect_to[]=xended in aTypeError. The function runs on the account page and after login and registration. It now ignores a value that is not a string. A guest opening/?redirect_to[]=xstill gets an error from WooCommerce itself:BlockTypesController::redirect_to_field(), hooked towoocommerce_login_form_end, does the same with$_GET['redirect_to'](also in WooCommerce 11.1.2).CPF/CNPJ placeholder: WooCommerce does not accept
placeholderamong the attributes of an additional checkout field. It dropped it and raised a "called incorrectly" notice on every request, so "Required for customers in Brazil" was never shown. The attribute is removed, and the registration moved from a closure tolibresign_theme_register_cpf_cnpj_field()so the test can register the field again and check that WooCommerce raises no notice.Default deploy workflow: without a saved setting, the webhook only synced a run of a workflow named
Deployon thegh-pagesbranch. InLibreSign/site,Deployruns onmain, and the run ongh-pagesis GitHub'spages build and deployment, so that combination never happened. The default is nowpages build and deployment, the value the Customizer already shows and the one thelibresign-wp-customizationsplugin uses.Verification
composer cipasses: 235 tests.--order-by=random) across repeated runs.