This change is done to ensure that these tests pass.
Wonky Tests:
- 'can create simple virtual product and add it to the cart'
- 'can create simple non-virtual product and add it to the cart'
It is observed that these tests fail when the following criteria are met:
- Running in headless mode
- Viewport is not set to 960x700
It is observed to pass when:
- Running in non-headless
- Running as an individual test file
The most likely culprit causing this issue is the verifyAndPublish function. More specifically, the element with the selector '.updated.notice' does not show up when the failing criteria are met.
Fixes a PHP Fatal error:
```
PHP Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\MonorepoTools\Changelogger\DateTime' not found in /var/www/woo/wp-content/plugins/woocommerce/tools/changelogger/Formatter.php:143
```
Changes:
- Moved setViewport to the beforeAll block
- Added a afterAll block to log out after each set of tests
- References the MENUS array from specs/data/elements.js
This script takes a menus array which contains selectors for top-level menu items and their associated sub-menus and verifies that they all load successfully.
PHP 7.x and 8.1 will throw a fatal error, thus causing the unit tests
suite to abruptly end, if a method from an implemented interface doesn't
fully match the signature as defined in the interface. In WooCommerce
that's the case for the classes that implement ArrayAccess: in
PHP 8.0+ these signatures have type hints and return types (as in
"offsetUnset( mixed $offset ):void" ) but the code in WooCommerce
doesn't. We can't just add the missing types to the signatures because
then the same error appears in PHP 7.x, in which there aren't
types in the method signatures of ArrayAccess.
The fix consists of adding the ReturnTypeWillChange attribute,
introduced in PHP 8.1, which instructs the runtime to not throw the
error. PHP 7.x doesn't support attributes, but in this case the
attribute declaration is seen as a comment.
See https://php.watch/versions/8.1/ReturnTypeWillChange