Skip to content

test(e2e): add virtual product creation and shipping field visibility… - #3341

Open
dev-shahed wants to merge 1 commit into
developfrom
e2e/virtual-product-e2e
Open

test(e2e): add virtual product creation and shipping field visibility…#3341
dev-shahed wants to merge 1 commit into
developfrom
e2e/virtual-product-e2e

Conversation

@dev-shahed

@dev-shahed dev-shahed commented Jul 22, 2026

Copy link
Copy Markdown
Member

… tests

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

  • Closes #

How to test the changes in this Pull Request:

  • Steps or issue link

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:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features

    • Added support for creating and managing virtual products.
    • Virtual products hide shipping fields while retaining tax settings.
    • Virtual products can be saved without shipping information and remain virtual when reopened.
    • Added coverage for downloadable products and product-type restrictions.
  • Bug Fixes

    • Improved auction date handling when calendar values are unavailable.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds virtual-product helpers and shipping/tax locators to the product form page object, with end-to-end coverage for virtual shipping behavior, persistence, downloadable products, edge cases, and variable products. It also hardens auction date parsing and removes duplicate navigation logic.

Changes

Virtual Product Form

Layer / File(s) Summary
Virtual product page-object support and form maintenance
tests/pw/tests/e2e/product-form-manager/newProductFormPage.ts, tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts
Adds shipping/tax locators and virtual-product creation helpers, updates test data imports, hardens auction date parsing, and removes duplicate edit navigation.
Virtual shipping happy paths
tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts
Tests Virtual toggle visibility, tax-field retention, reopening behavior, REST persistence, and virtual downloadable products.
Virtual shipping edge and negative cases
tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts
Tests shipping values before toggling, reverting to physical products, missing shipping data, and variable-product restrictions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NewProductFormPage
  participant ProductFormUI
  participant RESTAPI
  NewProductFormPage->>ProductFormUI: Fill product data
  NewProductFormPage->>ProductFormUI: Wait for digital options and enable Virtual
  NewProductFormPage->>ProductFormUI: Save product
  ProductFormUI->>RESTAPI: Persist virtual product
  RESTAPI-->>NewProductFormPage: Return product id
Loading

Possibly related PRs

  • getdokan/dokan#3332: Updates the same page object’s auction date parsing and edit navigation helpers.

Suggested labels: Test Automation

Suggested reviewers: shohan0120

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is mostly the untouched template and lacks concrete change details, test steps, changelog, and before/after context. Replace placeholders with a real summary, testing steps, changelog entry, and any relevant before/after notes or screenshots.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main change: adding E2E coverage for virtual product creation and shipping visibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e/virtual-product-e2e

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
tests/pw/tests/e2e/product-form-manager/newProductFormPage.ts (1)

692-708: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add the @since DOKAN_SINCE placeholder to the new JSDoc blocks.

The new waitForDigitalOptions() and createVirtualProduct() doc comments don't carry a version tag.

📝 Proposed fix
     /**
      * Wait for the async-hydrated "Digital Product Options" group (Virtual /
      * Downloadable) to mount. It renders noticeably later than title/price, so
      * toggling Virtual straight after waitForFormReady() can silently no-op.
+     *
+     * `@since` DOKAN_SINCE
      */
     async waitForDigitalOptions(timeoutMs = 20000): Promise<void> {
         await this.virtualToggle.waitFor({ state: 'attached', timeout: timeoutMs }).catch(() => undefined);
     }

-    /** Create a virtual product (basic info + Virtual) and return its persisted id. */
+    /**
+     * Create a virtual product (basic info + Virtual) and return its persisted id.
+     *
+     * `@since` DOKAN_SINCE
+     */
     async createVirtualProduct(data: ProductData): Promise<number | null> {

As per coding guidelines, "For new code documentation, use the literal placeholder @since DOKAN_SINCE... Never hardcode or guess an unreleased version."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/pw/tests/e2e/product-form-manager/newProductFormPage.ts` around lines
692 - 708, Add the literal `@since DOKAN_SINCE` tag to the JSDoc blocks for
`waitForDigitalOptions()` and `createVirtualProduct()`, without changing their
descriptions or implementation.

Source: Coding guidelines

tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts (1)

148-165: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider reusing createVirtualProduct() instead of re-inlining its steps.

This test repeats fillBasicInfowaitForDigitalOptionsenableVirtual before adding enableDownloadable, duplicating the sequence already encapsulated in NewProductFormPage.createVirtualProduct(). Extending that helper (e.g., an optional downloadable flag) or adding a small createVirtualDownloadableProduct() helper would avoid the duplicate sequence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts` around
lines 148 - 165, The test “vendor can create a virtual downloadable product”
duplicates the virtual-product setup already encapsulated by
NewProductFormPage.createVirtualProduct(). Reuse that helper by extending it
with an optional downloadable behavior or add a focused
createVirtualDownloadableProduct() helper, then update the test to call it
before saving and validating both REST flags.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/pw/tests/e2e/product-form-manager/newProductFormPage.ts`:
- Around line 692-708: Add the literal `@since DOKAN_SINCE` tag to the JSDoc
blocks for `waitForDigitalOptions()` and `createVirtualProduct()`, without
changing their descriptions or implementation.

In `@tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts`:
- Around line 148-165: The test “vendor can create a virtual downloadable
product” duplicates the virtual-product setup already encapsulated by
NewProductFormPage.createVirtualProduct(). Reuse that helper by extending it
with an optional downloadable behavior or add a focused
createVirtualDownloadableProduct() helper, then update the test to call it
before saving and validating both REST flags.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ebed46a-9de2-490e-a71b-b502a929720d

📥 Commits

Reviewing files that changed from the base of the PR and between cea9b11 and bbe572a.

📒 Files selected for processing (2)
  • tests/pw/tests/e2e/product-form-manager/newProductFormPage.ts
  • tests/pw/tests/e2e/product-form-manager/newProductFormTypes.spec.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant