diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6f0fb00..e63b662 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -289,8 +289,9 @@ jobs: - name: Fetch the framework's browser test harness working-directory: site run: | - version=$(ddev composer show pollora/framework --format=json | jq -r '.versions[0]') - ref=$([ "$version" = "dev-develop" ] && echo develop || echo "$version") + # develop is aliased (13.x-dev), so dev-develop is not always the first version listed. + ref=$(ddev composer show pollora/framework --format=json \ + | jq -r '.versions | if index("dev-develop") then "develop" else .[0] end') echo "Harness from pollora/framework@$ref" git clone --quiet --depth 1 --branch "$ref" https://github.com/Pollora/framework.git ../framework mkdir -p ../framework/tests/e2e/specs/apiary diff --git a/app/inc/woocommerce/core.php b/app/inc/woocommerce/core.php index a78eb79..6430381 100644 --- a/app/inc/woocommerce/core.php +++ b/app/inc/woocommerce/core.php @@ -22,3 +22,11 @@ function is_woocommerce_activated(): bool return class_exists('woocommerce'); } } + +// The layout already opens div#primary and main#main; WooCommerce's default +// wrapper opened them a second time on every shop page: two main landmarks, +// two elements with the same id. +Action::add('woocommerce_init', function () { + Action::remove('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10, 0); + Action::remove('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10, 0); +}); diff --git a/bin/tests/e2e/shop.spec.ts b/bin/tests/e2e/shop.spec.ts index 58c0f2f..535c2a1 100644 --- a/bin/tests/e2e/shop.spec.ts +++ b/bin/tests/e2e/shop.spec.ts @@ -162,3 +162,20 @@ test('a product search finds the product', async ({ page }) => { expect(errors, 'no uncaught page error').toEqual([]); }); + +test('each shop page has one main landmark', async ({ page }) => { + // The layout opens main#main; WooCommerce's default content wrapper opened a second one + // inside it, with the same id, on every page it renders. + const pages = { + 'product grid': wp('eval', `echo get_term_link(${category.id}, "product_cat");`), + 'product page': simple.permalink, + 'product search': homeUrl('/?s=E2E&post_type=product'), + cart: cartUrl, + }; + + for (const [name, url] of Object.entries(pages)) { + await page.goto(url); + await expect(page.locator('main'), `${name}: main elements`).toHaveCount(1); + await expect(page.locator('[id="main"]'), `${name}: elements with id="main"`).toHaveCount(1); + } +});