[tests] Cut product export E2E from 4 titles to 1, moving the export screen to PHPUnit - #68649
Open
vladolaru wants to merge 2 commits into
Open
[tests] Cut product export E2E from 4 titles to 1, moving the export screen to PHPUnit#68649vladolaru wants to merge 2 commits into
vladolaru wants to merge 2 commits into
Conversation
Three of the four product export browser titles were checking what the export screen renders when you arrive from the product list with a selection: which products are listed, what the clear link points at, and what the screen shows when nothing is selected. That is a view assertion, and a view is cheaper and more precisely testable from PHP than through wp-admin. The retained title, `preserves multiple selection through export and clear`, is the one that needs a browser: it starts on the product list, carries a real selection across a navigation, and then clears it. Nothing below the browser can prove that handoff. Two PHP additions take the rest: - WC_Admin_Product_Export_View_Test renders includes/admin/views/html-admin-page-product-export.php directly and asserts what the screen shows for a selection and for none. - WC_Product_CSV_Exporter_Test gains test_selected_product_ids_restrict_export_rows, which proves the exporter scopes its rows to the selected products and their variations. Knowingly dropped: the product list's "Export N selected" button is written by jQuery on a different screen, so neither PHP test can reach it. The retained title still covers it for two products; the singular N=1 wording and the default button text before any selection are no longer verified anywhere. class-wc-product-csv-exporter-test.php had moved on trunk since this work branched: #68567 added a regression test for exporting a product whose global attribute was deleted. Rather than take the frozen state blind and drop that method, trunk's copy was kept and only this branch's method re-applied on top. The file's diff against trunk is purely additive; both methods are present and the class goes from 5 tests to 6. Carries the mega-branch commits: - aba55f9 test(e2e): Reduce Product Export browser coverage - d4d6e9e test: Fix migration branch lint Refs TESTOPS-288 Refs #68046 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Draft
15 tasks
vladolaru
marked this pull request as ready for review
September 13, 2026 14:06
Contributor
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Submission Review Guidelines:
Changes proposed in this Pull Request:
Three of the four product export browser titles were checking what the export screen renders when you arrive from the product list with a selection: which products it lists, where the clear link points, and what it shows when nothing is selected. That is a view assertion, and a view is cheaper and more precisely testable from PHP than through wp-admin. Those three move down a layer; the one that genuinely needs a browser stays.
Refs TESTOPS-288
Part of the #68046 split.
should allow exporting a single selected simple productWC_Admin_Product_Export_View_Test::test_selected_products_render_exact_export_staterenders the real view template and asserts the hiddenproduct_idsinput and the screen copyExport 1 selectedbutton text and href. See below.should allow exporting multiple selected products (simple and variable)WC_Product_CSV_Exporter_Test::test_selected_product_ids_restrict_export_rows, which proves the exporter scopes its rows to the selected products and their variationsshould allow clearing selection from the export pageproduct_idsshould show the default export screen when no products are selectedWC_Admin_Product_Export_View_Test's second test renders the same template with no selectionThe retained title,
preserves multiple selection through export and clear, is the one no lower layer can replace: it starts on the product list, carries a real selection across a navigation, and then clears it.No test here reads an actual CSV file, and none did before
Worth stating plainly, because "product export" suggests otherwise. Neither the removed browser titles nor the new PHP tests ever generate a CSV and read its bytes. The old titles asserted button text, hrefs and screen copy; the new tests assert the rendered view and the exporter's in-memory row set.
product-export.spec.tshas no download handling at all — the only specs in the suite that wait on a download areanalytics.spec.tsandcustomer-list.spec.ts.So this batch moves assertions sideways, from the browser to PHP. It does not deepen coverage of the export mechanism, and the gap in end-to-end CSV file coverage is pre-existing and untouched.
The one real loss: the product list's export button
The
Export N selectedbutton on the product list is written by jQuery (client/legacy/js/admin/woocommerce_admin.js), not by the view this batch tests, so no PHP test can reach it.The singular case is less of a loss than it first looks. The button text is a single string with
%dsubstituted —woocommerce_admin.strings.export_selected_products.replace( '%d', count )— with no separate singular branch, soExport 1 selectedandExport 2 selectedtravel the same code path, and the retained title still exercises it with two products.What is genuinely unverified now is the other branch: restoring the button's original text and href when the last checkbox is unchecked. Nothing covers that any more.
This file had moved on trunk, and the branch's version was not taken blind
class-wc-product-csv-exporter-test.phpgained a method on trunk after this work branched: #68567 addedtest_export_row_for_product_loaded_before_its_global_attribute_is_deleted. Checking out the migration branch's copy wholesale would have deleted it.Instead trunk's file was kept and only this branch's method re-applied on top. The result is checkable rather than asserted: both methods are present, the file's diff against trunk has zero deleted lines, and the class goes from 5 tests to 6.
Screenshots or screen recordings:
Not applicable. Test-only change.
How to test the changes in this Pull Request:
pnpm install --frozen-lockfilefrom the repository root.pnpm --filter=@woocommerce/plugin-woocommerce env:test.WC_Tests_Product_CSV_Exporterexists, and PHPUnit's--filteris an unanchored substring regex, so a loose filter runs more than it claims.pnpm --filter=@woocommerce/plugin-woocommerce test:php:env -- --filter '/^WC_Product_CSV_Exporter_Test::/'— expectOK (6 tests, 32 assertions).pnpm --filter=@woocommerce/plugin-woocommerce test:php:env -- --filter '/^WC_Admin_Product_Export_View_Test::/'— expectOK (2 tests, 21 assertions).pnpm --filter=@woocommerce/plugin-woocommerce env:e2e.pnpm --filter=@woocommerce/plugin-woocommerce test:e2e:with-env default --project=core-parallel --retries=0 --workers=1 tests/e2e/tests/product/product-export.spec.ts. The retained title should pass; the summary reads3 passedand1 skipped, the 3 being that title plus theglobal authenticationandsite setupprojects.plugins/woocommerce/includes/admin/views/html-admin-page-product-export.php, find the branch that echoes the hiddenproduct_idsinput and change itsif ( $is_exporting_product_ids ) {toif ( false ) {. Re-run the first command in step 3 and expecttest_selected_products_render_exact_export_stateto fail withFailed asserting that null is identical to '10'.. Revert.plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php, inprepare_data_to_export, change$args['include'] = $this->product_ids_to_export;to$args['include'] = array();. Re-run the first command in step 3 and expecttest_selected_product_ids_restrict_export_rowsto fail on an array-identity assertion, admitting an unrelated product and omitting the selected variations. Revert.$clear_url = remove_query_arg( 'product_ids' );to$clear_url = add_query_arg( 'product_ids', implode( ',', $product_ids_to_export ) );. Re-run step 5 and expect a failure readingExpected substring: not "product_ids=", with the URL still carrying the selected IDs. Revert.Testing that has already taken place:
Everything below ran on this branch against a local WordPress, with retries disabled and one worker. Trunk was at
adefb5f971.WC_Product_CSV_Exporter_TestwasOK (5 tests, 29 assertions)under the anchored filter. So the environment was known good and the merge result is measured against a real starting point.--retries=0 --workers=1.WC_Product_CSV_Exporter_TestOK (6 tests, 32 assertions);WC_Admin_Product_Export_View_TestOK (2 tests, 21 assertions).includescoping, and the view's clear-link URL.lint:changes:branchexits 0 with one pre-existing warning and no errors.oxlintattributes no new finding to the change.phpstan.neonscopes towoocommerce.php,src/andincludes/; this batch touches onlytests/.Milestone
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment
Created manually:
plugins/woocommerce/changelog/testops-288-products-admin-export.Use of AI Tools
The migration was produced by an agent-run campaign with per-test mutation verification (see #68046). This PR was assembled, verified in isolation, and reviewed by an agent; the author reviewed the diff and takes responsibility for it.
🤖 Generated with Claude Code