shopware / shopware/shopware

Test the behaviour and not the logic within the navigation test

Open
#8,104 2 comments 0 reactions 0 assignees View on GitHub
domain/quality-ops priority/high testing/acceptance
Dominant language
PHP
Stars
3.4k
Forks
1.2k
Avg merge
2d 23h
Merged PRs (30d)
433

Description

Related test: {{tests/acceptance/tests/Categories/NavigateThroughStorefrontMenu.spec.ts}}

*Problem:*

Currently, in the corresponding test, we check 3 times the logic of the DOM ({{

}}, {{}}) and not the behaviour behind the logic. What happens, for example, if the is changed to a ? Then, the behaviour is still as desired, but the test suddenly fails without knowing what is being validated.

{noformat}const breadcrumbNavigationItemTagName = await mainCategoryLocators.breadcrumbNavigationItem.evaluate((el) =>
el.tagName.toLowerCase()
);
await ShopCustomer.expects(breadcrumbNavigationItemTagName).toBe('span');{noformat}

*Solution:*

We could explicitly click on the element to check whether it is “actionable”. According to StackOverflow, you could use the {{trial}} [option|https://playwright.dev/docs/api/class-locator#locator-click-option-trial] in the click handler.

Or create a custom function and box it (see last comment here): [https://github.com/microsoft/playwright/issues/32291|https://github.com/microsoft/playwright/issues/32291|smart-link]

Docs: [https://github.com/microsoft/playwright/pull/6246|https://github.com/microsoft/playwright/pull/6246|smart-link]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.