Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/inc/woocommerce/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
17 changes: 17 additions & 0 deletions bin/tests/e2e/shop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Loading