Skip to content

Page slugs become WooCommerceWebDriver module config - #54

Merged
edpittol merged 7 commits into
mainfrom
48-page-slugs-become-woocommercewebdriver-module-config
Jun 19, 2026
Merged

Page slugs become WooCommerceWebDriver module config#54
edpittol merged 7 commits into
mainfrom
48-page-slugs-become-woocommercewebdriver-module-config

Conversation

@edpittol

@edpittol edpittol commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Moves cart, checkout, and my-account page-slug resolution out of the database and into `WooCommerceWebDriver` module config, so browser navigation to these pages never queries the system under test. Implements the page-slug half of ADR-0008.

Implementation

  • `WooCommerceWebDriver` declares three new config keys with WooCommerce-convention defaults: `cartPageSlug` (`/cart`), `checkoutPageSlug` (`/checkout`), `myAccountPageSlug` (`/my-account`). Each is independently overridable in `suite.yml`.
  • `WooCommerceConfig` now holds the declared slug strings instead of taking `WPDb` and resolving page IDs/`post_name` from the database.
  • `WooCommerceModuleSupport::wooCommerceConfig()` builds the config from `_getConfig()` slug keys (no memoization, so a runtime `_reconfigure` takes effect immediately). A misconfigured slug (non-string value) now throws a `ModuleException` immediately rather than silently navigating to the site root. The stale `_initialize` message about reading "WooCommerce configuration" from the DB is corrected — WPDb is still required for product/cart data assertions.

Fixes

  • `CartMethods::seeCartItemQuantity` — added `waitForElement` before `grabAttributeFrom` to fix a flaky failure that occurred when the cart quantity input was not yet in the DOM at the time of the attribute grab.

Tests

  • `WooCommerceConfigTest` (unit) — exposes configured slugs and per-slug overrides verbatim for all three slugs.
  • `WooCommerceWebDriverPageSlugTest` (unit) — module defaults to convention slugs; each slug is independently overridable.
  • `PageSlugCest` (acceptance) — navigation using cart and my-account default slugs. Checkout is omitted: WooCommerce redirects `/checkout` to `/cart` when the cart is empty, making an isolated slug assertion impossible; coverage comes from `CheckoutCest` tests that navigate with items in the cart.
  • Full suite green (199 tests); PHPStan (level max) and PHPCS clean.

Acceptance criteria

  • `cartPageSlug`, `checkoutPageSlug`, `myAccountPageSlug` declared with defaults `/cart`, `/checkout`, `/my-account`.
  • Each slug independently overridable via `suite.yml`.
  • Browser navigation reads the slug from config — no DB lookup for slugs.
  • A non-string slug value throws a `ModuleException` with a clear message.
  • Acceptance test covers cart and my-account default slugs (checkout covered via `CheckoutCest`).
  • Existing acceptance suite stays green.

Closes #48

Move cart, checkout, and my-account page-slug resolution out of the
database and into module config. WooCommerceWebDriver now declares
cartPageSlug (/cart), checkoutPageSlug (/checkout), and myAccountPageSlug
(/my-account) with WooCommerce-convention defaults, each independently
overridable in suite.yml. WooCommerceConfig holds the declared slugs
instead of querying WPDb, so browser navigation to these pages never
touches the system under test.

Implements the page-slug half of the WebDriver store-shape-via-config
decision (docs/adr/0008).

Closes #48
@edpittol edpittol self-assigned this Jun 18, 2026
Comment thread src/WooCommerce/Config/WooCommerceConfig.php Outdated
Comment thread tests/_support/Helper/Acceptance.php Outdated
edpittol added 5 commits June 18, 2026 21:46
- Drop overrideWooCommerceWebDriverConfig() and resetWooCommerceWebDriverConfig()
  from the Acceptance helper — the Codeception _reconfigure/_resetConfig API is
  not part of the public test interface we want to expose.
- Remove testNavigatesToOverriddenCartSlug and the _after hook that depended on
  those helpers; the remaining default-slug tests need no teardown.
- Delete the WooCommerceConfig class docblock — the class name and constructor
  signature are self-documenting.
…uantity

The WooCommerce Cart Block renders quantity inputs via React hydration, which
completes after DOM-ready. grabAttributeFrom does not wait, so the XPath lookup
races the hydration step and fails intermittently. waitForElement makes the
assertion block until the input is present, eliminating the flake.
…ceptance test

- pageSlugConfig() now throws ModuleException when the configured value is
  not a string, instead of silently returning an empty slug
- PageSlugCest covers all three default slugs (cart, checkout, my-account)
@edpittol
edpittol merged commit 771aa19 into main Jun 19, 2026
3 checks passed
@edpittol
edpittol deleted the 48-page-slugs-become-woocommercewebdriver-module-config branch June 19, 2026 02:28
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.

Page slugs become WooCommerceWebDriver module config

1 participant