-
Notifications
You must be signed in to change notification settings - Fork 1
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
Product Edit functions optimized #95
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request introduces significant enhancements to the product editing workflow in the test suite. The changes focus on improving the Changes
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant AuthSetup as Authentication Setup
participant ProductsPage as ProductsPage
participant VendorPage as VendorPage
Test->>AuthSetup: Authenticate vendor
AuthSetup->>ProductsPage: Create instance
ProductsPage->>ProductsPage: Get product edit nonce
ProductsPage-->>AuthSetup: Return nonce
AuthSetup->>AuthSetup: Store nonce as env variable
Test->>VendorPage: Navigate to product edit
VendorPage->>VendorPage: Remove row action class
VendorPage->>ProductsPage: Go to product edit page
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
tests/pw/pages/productsPage.ts (3)
Line range hint
1106-1161
: Switch-based inventory logic
While this covers all scenarios, consider refactoring into smaller helper methods for clarity if it grows further.
Line range hint
1171-1218
: Add other options
Another switch-based approach. Similar comment: if logic grows further, consider segregating each sub-option. Otherwise, looks fine.
Line range hint
1558-1603
: Add RMA options
Handles multiple RMA scenarios: “no warranty,” “included,” or “addon.” The logic is large but cohesive.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
tests/pw/pages/productsPage.ts
(40 hunks)tests/pw/pages/vendorPage.ts
(1 hunks)tests/pw/tests/e2e/_auth.setup.ts
(3 hunks)tests/pw/tests/e2e/productsDetails.spec.ts
(4 hunks)tests/pw/types/environment.d.ts
(1 hunks)tests/pw/utils/testData.ts
(1 hunks)
🔇 Additional comments (156)
tests/pw/pages/productsPage.ts (51)
8-8
: Add environment variable usage
The addition of PRODUCT_EDIT_NONCE
in the environment variables aligns with your new product editing flow. No issues noted.
615-621
: Validate regex for nonce extraction
The method correctly retrieves the nonce from the URL and throws an error if not found. Consider verifying that _dokan_edit_product_nonce
never includes special characters outside [\\w\\d]
.
623-625
: Ensure fallback usage
Using nonce: string = PRODUCT_EDIT_NONCE
is convenient, but ensure you handle scenarios where PRODUCT_EDIT_NONCE
is undefined.
810-810
: Consistent edit navigation
Replacing direct edit with goToProductEditById
may improve reliability. Verify all relevant calls align with the new usage.
Line range hint 818-822
: Handle permalink conflicts
This flow updates the permalink. Consider an error check if the permalink is already in use, to prevent collisions.
829-831
: Price update logic
Straightforward approach for setting product price. Looks good.
Line range hint 837-841
: Removing price
Logic for clearing out product price is self-explanatory and robust.
Line range hint 847-851
: Prevent greater discount
This flow properly verifies that an over-discount triggers an error message. Good validation.
Line range hint 857-870
: Add discount with optional schedule
You handle schedule toggling (if hasSchedule
is false, you open it) and then set start/end dates. This is thorough.
Line range hint 876-885
: Remove discount and schedule
Code correctly resets the discounted price and handles schedules. No issues noted.
Line range hint 919-927
: Add product category
Looping through categories and then verifying the selection is clear.
Line range hint 931-939
: Remove product category
Straightforward removal and post-save verification.
944-944
: Navigate by ID
Using goToProductEditById
keeps the edit flow consistent with the nonce-based approach.
Line range hint 950-958
: Add product tags
This loop-based flow is sensible. Written cleanly with proper verification.
Line range hint 964-972
: Remove product tags
Similar approach for tag removal; properly saves and confirms the result.
Line range hint 978-992
: Add product cover image
You remove the previous cover if requested, then upload and verify. Consider checking for possible upload errors in real scenarios.
Line range hint 994-1002
: Remove product cover image
Works as intended, ensuring the new state is empty.
Line range hint 1004-1014
: Add product gallery images
Loop-based upload logic is correct. Final count verification is a good check.
1030-1037
: Remove product gallery images
Removes them one by one, verifying the final count. Nicely done.
1038-1044
: Short description
Clear approach to editing the product’s short description.
1046-1052
: Long description
Implementation matches short description logic. Straightforward.
Line range hint 1054-1068
: Add downloadable options
Proper toggling of the downloadable checkbox and file upload. Good coverage of fields.
Line range hint 1071-1084
: Remove downloadable file
All files are removed, and final fields remain updated. This flow is correct.
Line range hint 1086-1103
: Add virtual option
Good approach—toggling virtual
and verifying shipping container is hidden if needed.
1163-1170
: Remove product inventory
Simple unchecking and verification. Looks good.
Line range hint 1220-1228
: Enable product catalog mode
Clear approach with optional price hide. Works well.
Line range hint 1230-1247
: Disable product catalog mode
Handles toggles correctly for add-to-cart or price.
Line range hint 1251-1267
: Add shipping
Enables shipping, sets dimensions, and verifies. Fine.
1269-1275
: Remove shipping
Disables the shipping requirement and confirms.
Line range hint 1277-1285
: Add tax
Straightforward approach for tax status/class.
Line range hint 1287-1325
: Add linked products
Implementation for up-sells and cross-sells is done thoroughly.
Line range hint 1327-1363
: Remove linked products
Removes each linked product and verifies absence. Well-structured.
Line range hint 1365-1382
: Add product attribute
Everything from label selection to terms is handled. Consider verifying attribute existence in case of custom user input.
1384-1389
: Prevent adding duplicate attribute
Proper disables user from re-adding an existing attribute.
Line range hint 1391-1399
: Remove product attribute
Handles the removal and final verification well.
Line range hint 1401-1412
: Remove product attribute term
Removes a single term and saves. Straightforward approach.
Line range hint 1414-1424
: Add bulk discount
Enables discount and verifies the fields. All good.
Line range hint 1426-1434
: Remove bulk discount
Clears out the discount, ensures final state is not enabled.
Line range hint 1436-1446
: Add geolocation
Unchecks “same as store,” then sets location with a dynamic address search. Nicely implemented.
1448-1454
: Remove geolocation
Reverts the location to “same as store” and checks final state.
Line range hint 1456-1490
: Add EU compliance
A thorough approach, handling multiple fields and verifying them. Consider validating numeric fields in real scenarios.
Line range hint 1492-1530
: Add product addon
You handle the different fields well, including optional toggles. Looks good.
Line range hint 1532-1539
: Import addon
Straightforward approach—deserializing the addon. No issues noted.
1541-1547
: Export addon
Grabs _product_addons
from meta and checks the response. Good approach.
Line range hint 1548-1556
: Remove addon
Deletes the addon entry and finalizes the product.
1605-1611
: Remove RMA options
Straightforward uncheck approach.
Line range hint 1613-1623
: Add wholesale
Enables wholesale and verifies. No issues.
1625-1631
: Remove wholesale
Clears the wholesale field. Looks fine.
Line range hint 1633-1641
: Add min-max
Sets minimum and maximum quantity. Simple approach.
Line range hint 1643-1653
: Prevent invalid min-max
Ensures min can’t exceed max by forcing them to be equal. Good validation.
Line range hint 1655-1661
: Remove min-max
Resets the fields and confirms the changes.
tests/pw/types/environment.d.ts (1)
21-21
: New environment variable
Declaring PRODUCT_EDIT_NONCE: string;
is aligned with the new editing flow.
tests/pw/tests/e2e/_auth.setup.ts (3)
3-3
: Import ProductsPage
Necessary import for retrieving the edit nonce. No concerns.
42-42
: Comment for PRO functionality
This comment clarifies adding store review if DOKAN_PRO
is active. No code issues.
80-82
: Set PRODUCT_EDIT_NONCE
Retrieving nonce from the ProductsPage
after vendor login is a solid approach for consistent test usage.
tests/pw/pages/vendorPage.ts (1)
52-54
: Force row actions visibility
Removing the 'class' attribute might cause style or JS side effects, but it does mitigate flakiness. Switching to clickAndWaitForResponseAndLoadStateUntilNetworkIdle
is consistent. Test carefully.
tests/pw/tests/e2e/productsDetails.spec.ts (99)
18-19
: Rename product identifier variables
Using productIdFull
and productIdBasic
clarifies test coverage for full vs. minimal fields.
27-27
: Initialize ApiUtils
Sets up the new context for API calls. Straightforward.
29-30
: Create product (basic)
Generates a product with only required fields. Good for minimal test coverage.
33-34
: Create product (all fields)
Fallback approach is used if media uploads fail. This ensures coverage even without images.
36-36
: Update product with meta_data
Adds product addon meta. This thoroughly tests advanced product features.
58-59
: Update product title
Checks that we can apply a title to a newly created product. Straightforward.
65-65
: Update product permalink
Ensures the vendor can change the slug/permalink. No issues noted.
71-71
: Add price to basic product
No concerns. Verifies minimal product coverage.
75-75
: Update price on full product
Similar logic, ensuring the advanced product can handle price changes.
79-79
: Remove price
Verifies that price can be cleared on an existing product.
85-85
: Add discount to basic
Applies discount to a minimal product. Proper coverage.
89-89
: Add discount with schedule
Tests scheduling logic. Straightforward.
93-93
: Update discount on full
Ensures advanced product can handle discount and references existing price.
97-97
: Update discount with schedule
Tests more complex discount scenarios on advanced product.
101-101
: Prevent invalid discount
Verifies the error scenario for discount exceeding price.
105-106
: Remove discount
Removes discount on a newly created product with discount fields.
110-111
: Remove discount schedule
Ensures date-based discount can be cleared.
117-117
: Set single category
Adds a clothing category to the full product. No issues.
122-122
: Add multiple categories
Switching DB option to enable multiple category selection. Good test coverage.
128-129
: Remove multiple categories
Ensures we can revert to fewer categories on a multi-category product.
134-134
: Add last multi-step category
Testing multi-step category logic.
139-139
: Add any multi-step category
Tests optional multi-step category behavior.
144-144
: Prevent adding multi-step category
Ensures the setting “off” blocks adding an internal category.
150-150
: Add product tags
Applies tags to the basic product. Straightforward coverage.
154-154
: Remove product tags
Reverts or clears tags from the full product.
158-158
: Create product tags
Tests generation of tags on full product. Good.
164-164
: Add cover image
Adds a cover image to the basic product.
169-170
: Update cover image
Removes previous image if specified, then adds a new one.
175-176
: Remove cover image
Ensures cover image is fully removed from the product.
182-182
: Add gallery image
Applies gallery images to the basic product.
187-188
: Update gallery image
Removes old images, uploads new. Thorough test scenario.
193-194
: Remove gallery image
Ensures we can clear the gallery.
200-200
: Add short description
Stores a short description on the basic product.
204-204
: Update short description
Same logic, but for the full product.
208-208
: Remove short description
Clears the short description. Straightforward.
214-214
: Update description
Sets or updates the long description on the full product.
220-220
: Add downloadable options
Adds file-based data to the basic product.
225-225
: Update downloadable options
Applies to the full product. Good coverage.
230-231
: Remove downloadable file
Ensures we can clear existing downloadable entries.
237-238
: Add virtual option
Creates a new basic product, toggles virtual
.
242-243
: Remove virtual option
Ensures we can revert from virtual to physical.
249-249
: Add inventory (SKU) to basic
Assigns a SKU to the minimal product.
253-253
: Update inventory (SKU) on full
Ensures advanced product can have updated SKU.
257-257
: Remove SKU
Clears SKU on the full product.
261-261
: Add stock-status
Verifies we can set stock status.
265-265
: Add stock management
Turns on inventory management and sets stock fields.
269-269
: Update stock management
Re-applies the same approach, ensuring reusability.
273-273
: Remove stock management
Unchecks management and verifies.
277-277
: Allow single quantity
Enables the limit of one item per order.
281-281
: Disable single quantity
Ensures removal of that limit.
287-287
: Set product status
Changes the product status (draft/pending/publish).
291-291
: Set visibility
Applies catalog visibility changes.
295-295
: Set purchase note
Adds a note to customers upon purchase.
299-299
: Update purchase note
Similar but for the full product.
303-303
: Remove purchase note
Clears that text field.
307-307
: Enable product reviews
Lets customers leave reviews.
311-311
: Disable product reviews
Removes the review capability.
320-320
: Add catalog mode
Hides add-to-cart if that DB option is enabled.
325-325
: Hide product price
Adds an additional hide-price scenario.
330-330
: Remove catalog mode
Disables the add-to-cart hiding.
335-335
: Remove catalog mode - price
Handles the second hide-price scenario.
341-341
: Add shipping
Assigns shipping data to a product.
345-345
: Update shipping
Same logic, on a full product.
349-349
: Remove shipping
Unchecks shipping fields.
353-353
: Add product tax
Sets basic tax fields.
357-357
: Add product tax (with class)
Enables a specific tax class.
363-363
: Add up-sell products
Ensures linking logic is correct.
367-367
: Add cross-sell products
Verifies cross-sell linking.
371-371
: Remove up-sell
Clears out up-sells from the product.
375-375
: Remove cross-sell
Similar logic for cross-sells.
381-381
: Add product attribute
Ensures attributes can be added to a basic product.
385-385
: Prevent duplicate attribute
Checks that the product can’t add an already existing attribute.
392-392
: Create attribute term
Tests synergy of new attribute with product.
399-399
: Remove product attribute
Demonstrates attribute removal at runtime.
407-407
: Remove product attribute term
Removes one term from multiple.
414-414
: Add product bulk discount
Enables quantity-based discounts to a basic product.
418-418
: Update bulk discount
Applies discount again on the full product.
422-422
: Remove bulk discount
Clears the previously added discount.
428-428
: Add individual geolocation
Verifies separate location from store address.
432-432
: Update geolocation
Ensures we can change that location on the full product.
436-436
: Remove geolocation
Re-enables store’s default address.
443-443
: Skip: Add EU compliance
Currently skipped. Implementation logic is fine.
447-447
: Skip: Update EU compliance
Also skipped, but consistent approach.
451-451
: Skip: Remove EU compliance
Would test clearing compliance fields.
459-459
: Add product addon
Tests adding a single addon to a basic product.
464-464
: Import product addon
Uses php-serialize
for more advanced test coverage.
468-469
: Export product addon
Verifies the _product_addons
meta data is exportable.
480-480
: Add RMA (no warranty)
Tests RMA settings. No issues.
484-484
: Add RMA (included, limited)
Introduces a “limited” warranty scenario.
488-488
: Add RMA (included, lifetime)
Slight variation of included warranty.
492-492
: Add RMA (addon warranty)
Ensures the “addon” path is valid.
498-498
: Remove product RMA
Disables RMA entirely.
504-504
: Add wholesale
Tests wholesale pricing for the basic product.
508-508
: Update wholesale
Ensures advanced product can have wholesale pricing.
512-512
: Remove wholesale
Clears the wholesale pricing.
518-518
: Add min-max
Applies min-max constraints on a basic product.
522-522
: Update min-max
Ensures full product min-max is also valid.
526-526
: Prevent invalid min > max
Validation ensuring the minimum does not exceed the maximum.
530-530
: Remove min-max
Clears the constraints.
tests/pw/utils/testData.ts (1)
1176-1176
: Consider URL-encoding the parameters for consistency and safety.
The arguments productId
and nonce
are concatenated into a URL without any encoding. Although typically these parameters might be safe, you could wrap them in encodeURIComponent
or ensure they do not contain any special characters to avoid unexpected behavior.
* Add: product edit nonce to for direct navigation * Add: playwright sharding for parallel job * Update packages * Fix: flaky tests
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
Title
Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.
Before Changes
Describe the issue before changes with screenshots(s).
After Changes
Describe the issue after changes with screenshot(s).
Feature Video (optional)
Link of detailed video if this PR is for a feature.
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
PRODUCT_EDIT_NONCE
variable.Tests