From ffc43e4f47b4295a10566937e50114770586bc7a Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Feb 2025 22:13:35 +0100 Subject: [PATCH 1/3] [CLEANUP] Remove unused variables in GitLab CI Relates: #256 --- .gitlab-ci.yml | 41 ++++++++++------------------------------- Build/phpstan.neon | 2 +- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b3d5fae..8ea0e3ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,14 +5,7 @@ cache: - .php_cs.cache variables: - COMPOSER_CACHE_DIR: ".composer" - TYPO3_PATH_WEB: "$CI_PROJECT_DIR/.build/public" - MYSQL_DATABASE: "typo3" - MYSQL_ROOT_PASSWORD: "joh316" - typo3DatabaseName: "typo3" - typo3DatabaseHost: "mysql" - typo3DatabaseUsername: "root" - typo3DatabasePassword: "joh316" + TYPO3_VERSION: ^13.4 before_script: - apk add git --update @@ -69,6 +62,7 @@ phpstan:analyse: - composer config platform.php 8.2 - composer install --no-progress --no-ansi --no-interaction script: + - vendor/bin/codecept build - vendor/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M .test_php: &test_php @@ -86,26 +80,20 @@ phpstan:analyse: - vendor/bin/phpunit -c Build/UnitTests.xml - typo3DatabaseDriver=pdo_sqlite vendor/bin/phpunit -c Build/FunctionalTests.xml -# Build in PHP 8.2 and TYPO3 13.4 -test:php82:typo3_13: +test:php82: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.2:main - TYPO3_VERSION: ^13.4 -# Build in PHP 8.3 and TYPO3 13.4 -test:php83:typo3_13: +test:php83: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main - TYPO3_VERSION: ^13.4 -# Build in PHP 8.4 and TYPO3 13.4 -test:php84:typo3_13: +test:php84: <<: *test_php variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.4:main - TYPO3_VERSION: ^13.4 .test_codeception: &test_codeception stage: test @@ -131,33 +119,24 @@ test:php84:typo3_13: expire_in: 1 day when: always -# Build in PHP 8.2 and TYPO3 13.4 -test:codception:php82:typo3_13: +codeception:php82: <<: *test_codeception variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.2:main - TYPO3_VERSION: ^13.4 - GECKODRIVER_VERSION: v0.34.0 -# Build in PHP 8.3 and TYPO3 13.4 -test:codception:php83:typo3_13: +codeception:php83: <<: *test_codeception needs: - - test:codception:php82:typo3_13 + - codeception:php82 variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.3:main - TYPO3_VERSION: ^13.4 - GECKODRIVER_VERSION: v0.34.0 -# Build in PHP 8.4 and TYPO3 13.4 -test:codception:php84:typo3_13: +codeception:php84: <<: *test_codeception needs: - - test:codception:php83:typo3_13 + - codeception:php83 variables: CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.4:main - TYPO3_VERSION: ^13.4 - GECKODRIVER_VERSION: v0.34.0 documentation: stage: documentation diff --git a/Build/phpstan.neon b/Build/phpstan.neon index c166ea3c..f9aa6f76 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -7,4 +7,4 @@ parameters: - ../ext_emconf.php - ../ext_localconf.php excludePaths: - - ../Tests/Acceptance + - ../Tests/Acceptance/Support/_generated From 194519781d992dc15edea1eec11ecb6791c31d10 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Mon, 24 Feb 2025 13:51:19 +0100 Subject: [PATCH 2/3] [CLEANUP] Replace wait() in test with waitForElementNotVisible() With this change the partial with the timeout could be overritten. This makes the tests more stable. Relates: #256 --- ...ableProductWithStockHandlingToCartCest.php | 32 ++++------ ...eProductWithoutStockHandlingToCartCest.php | 15 ++--- ...mpleProductWithStockHandlingToCartCest.php | 27 ++++----- ...eProductWithoutStockHandlingToCartCest.php | 15 ++--- .../Configuration/TypoScript/setup.typoscript | 6 +- .../Private/Partials/Product/CartForm.html | 58 +++++++++++++++++++ 6 files changed, 97 insertions(+), 56 deletions(-) create mode 100644 Tests/Fixtures/cart_products_test/Resources/Private/Partials/Product/CartForm.html diff --git a/Tests/Acceptance/AddConfigurableProductWithStockHandlingToCartCest.php b/Tests/Acceptance/AddConfigurableProductWithStockHandlingToCartCest.php index 4e9cb1b1..d2fa9aa3 100644 --- a/Tests/Acceptance/AddConfigurableProductWithStockHandlingToCartCest.php +++ b/Tests/Acceptance/AddConfigurableProductWithStockHandlingToCartCest.php @@ -32,10 +32,9 @@ public function testAddDifferentItemsWithinAvailableAmountToCart(Tester $I): voi $I->see('Item was added to cart.', '#product-6 .form-message .form-success'); $I->dontSeeElement('#product-6 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 2); $I->selectOption('tx_cart_cart[beVariants][1]', 'M - green'); @@ -44,10 +43,9 @@ public function testAddDifferentItemsWithinAvailableAmountToCart(Tester $I): voi $I->see('2 Items were added to cart.', '#product-6 .form-message .form-success'); $I->dontSeeElement('#product-6 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 4); $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); @@ -56,10 +54,9 @@ public function testAddDifferentItemsWithinAvailableAmountToCart(Tester $I): voi $I->see('4 Items were added to cart.', '#product-6 .form-message .form-success'); $I->dontSeeElement('#product-6 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); } public function testAddMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void @@ -80,10 +77,8 @@ public function testAddMoreItemsThanInStockOfASimpleProductToCart(Tester $I): vo $I->dontSeeElement('#product-6 .form-message .form-success'); $I->see('Desired number of this item not available.', '#product-6 .form-message .form-error'); - $I->wait(3); - - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); } public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void @@ -103,10 +98,9 @@ public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Test $I->see('Item was added to cart.', '#product-6 .form-message .form-success'); $I->dontSeeElement('#product-6 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 5); $I->selectOption('tx_cart_cart[beVariants][1]', 'XL - red'); @@ -116,9 +110,7 @@ public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Test $I->dontSeeElement('#product-6 .form-message .form-success'); $I->see('Desired number of this item not available.', '#product-6 .form-message .form-error'); - $I->wait(3); - - $I->dontSeeElement('#product-6 .form-message .form-success'); - $I->dontSeeElement('#product-6 .form-message .form-error'); + $I->waitForElementNotVisible('#product-6 .form-message .form-success'); + $I->waitForElementNotVisible('#product-6 .form-message .form-error'); } } diff --git a/Tests/Acceptance/AddConfigurableProductWithoutStockHandlingToCartCest.php b/Tests/Acceptance/AddConfigurableProductWithoutStockHandlingToCartCest.php index 9312d955..bb28676b 100644 --- a/Tests/Acceptance/AddConfigurableProductWithoutStockHandlingToCartCest.php +++ b/Tests/Acceptance/AddConfigurableProductWithoutStockHandlingToCartCest.php @@ -31,10 +31,9 @@ public function testAddDifferentItemsToCart(Tester $I): void $I->see('Item was added to cart.', '#product-5 .form-message .form-success'); $I->dontSeeElement('#product-5 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-5 .form-message .form-success'); - $I->dontSeeElement('#product-5 .form-message .form-error'); + $I->waitForElementNotVisible('#product-5 .form-message .form-success'); + $I->waitForElementNotVisible('#product-5 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 2); $I->selectOption('tx_cart_cart[beVariants][1]', 'green'); @@ -42,10 +41,9 @@ public function testAddDifferentItemsToCart(Tester $I): void $I->see('2 Items were added to cart.', '#product-5 .form-message .form-success'); $I->dontSeeElement('#product-5 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-5 .form-message .form-success'); - $I->dontSeeElement('#product-5 .form-message .form-error'); + $I->waitForElementNotVisible('#product-5 .form-message .form-success'); + $I->waitForElementNotVisible('#product-5 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 100); $I->selectOption('tx_cart_cart[beVariants][1]', 'red'); @@ -53,9 +51,8 @@ public function testAddDifferentItemsToCart(Tester $I): void $I->see('100 Items were added to cart.', '#product-5 .form-message .form-success'); $I->dontSeeElement('#product-5 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-5 .form-message .form-success'); - $I->dontSeeElement('#product-5 .form-message .form-error'); + $I->waitForElementNotVisible('#product-5 .form-message .form-success'); + $I->waitForElementNotVisible('#product-5 .form-message .form-error'); } } diff --git a/Tests/Acceptance/AddSimpleProductWithStockHandlingToCartCest.php b/Tests/Acceptance/AddSimpleProductWithStockHandlingToCartCest.php index d54be8ca..b0e2ae20 100644 --- a/Tests/Acceptance/AddSimpleProductWithStockHandlingToCartCest.php +++ b/Tests/Acceptance/AddSimpleProductWithStockHandlingToCartCest.php @@ -30,20 +30,18 @@ public function testAddDifferentItemsWithinAvailableAmountToCart(Tester $I): voi $I->see('Item was added to cart.', '#product-1 .form-message .form-success'); $I->dontSeeElement('#product-1 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-1 .form-message .form-success'); - $I->dontSeeElement('#product-1 .form-message .form-error'); + $I->waitForElementNotVisible('#product-1 .form-message .form-success'); + $I->waitForElementNotVisible('#product-1 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 2); $I->click('#product-1.add-to-cart-form input.btn[type="submit"]'); $I->see('2 Items were added to cart.', '#product-1 .form-message .form-success'); $I->dontSeeElement('#product-1 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-1 .form-message .form-success'); - $I->dontSeeElement('#product-1 .form-message .form-error'); + $I->waitForElementNotVisible('#product-1 .form-message .form-success'); + $I->waitForElementNotVisible('#product-1 .form-message .form-error'); } public function testAddMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void @@ -62,10 +60,8 @@ public function testAddMoreItemsThanInStockOfASimpleProductToCart(Tester $I): vo $I->dontSeeElement('#product-1 .form-message .form-success'); $I->see('Desired number of this item not available.', '#product-1 .form-message .form-error'); - $I->wait(3); - - $I->dontSeeElement('#product-1 .form-message .form-success'); - $I->dontSeeElement('#product-1 .form-message .form-error'); + $I->waitForElementNotVisible('#product-1 .form-message .form-success'); + $I->waitForElementNotVisible('#product-1 .form-message .form-error'); } public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Tester $I): void @@ -83,10 +79,9 @@ public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Test $I->see('Item was added to cart.', '#product-1 .form-message .form-success'); $I->dontSeeElement('#product-1 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-1 .form-message .form-success'); - $I->dontSeeElement('#product-1 .form-message .form-error'); + $I->waitForElementNotVisible('#product-1 .form-message .form-success'); + $I->waitForElementNotVisible('#product-1 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 10); $I->click('#product-1.add-to-cart-form input.btn[type="submit"]'); @@ -94,9 +89,7 @@ public function testAddOneAndThanMoreItemsThanInStockOfASimpleProductToCart(Test $I->dontSeeElement('#product-1 .form-message .form-success'); $I->see('Desired number of this item not available.', '#product-1 .form-message .form-error'); - $I->wait(3); - - $I->dontSeeElement('#product-1 .form-message .form-success'); - $I->dontSeeElement('#product-1 .form-message .form-error'); + $I->waitForElementNotVisible('#product-1 .form-message .form-success'); + $I->waitForElementNotVisible('#product-1 .form-message .form-error'); } } diff --git a/Tests/Acceptance/AddSimpleProductWithoutStockHandlingToCartCest.php b/Tests/Acceptance/AddSimpleProductWithoutStockHandlingToCartCest.php index 8d4585cc..df2d2eb5 100644 --- a/Tests/Acceptance/AddSimpleProductWithoutStockHandlingToCartCest.php +++ b/Tests/Acceptance/AddSimpleProductWithoutStockHandlingToCartCest.php @@ -30,29 +30,26 @@ public function testAddDifferentItemsToCart(Tester $I): void $I->see('Item was added to cart.', '#product-2 .form-message .form-success'); $I->dontSeeElement('#product-2 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-2 .form-message .form-success'); - $I->dontSeeElement('#product-2 .form-message .form-error'); + $I->waitForElementNotVisible('#product-2 .form-message .form-success'); + $I->waitForElementNotVisible('#product-2 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 2); $I->click('#product-2.add-to-cart-form input.btn[type="submit"]'); $I->see('2 Items were added to cart.', '#product-2 .form-message .form-success'); $I->dontSeeElement('#product-2 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-2 .form-message .form-success'); - $I->dontSeeElement('#product-2 .form-message .form-error'); + $I->waitForElementNotVisible('#product-2 .form-message .form-success'); + $I->waitForElementNotVisible('#product-2 .form-message .form-error'); $I->fillField('tx_cart_cart[quantity]', 100); $I->click('#product-2.add-to-cart-form input.btn[type="submit"]'); $I->see('100 Items were added to cart.', '#product-2 .form-message .form-success'); $I->dontSeeElement('#product-2 .form-message .form-error'); - $I->wait(3); - $I->dontSeeElement('#product-2 .form-message .form-success'); - $I->dontSeeElement('#product-2 .form-message .form-error'); + $I->waitForElementNotVisible('#product-2 .form-message .form-success'); + $I->waitForElementNotVisible('#product-2 .form-message .form-error'); } } diff --git a/Tests/Fixtures/cart_products_test/Configuration/TypoScript/setup.typoscript b/Tests/Fixtures/cart_products_test/Configuration/TypoScript/setup.typoscript index 57404ed0..20801205 100644 --- a/Tests/Fixtures/cart_products_test/Configuration/TypoScript/setup.typoscript +++ b/Tests/Fixtures/cart_products_test/Configuration/TypoScript/setup.typoscript @@ -1,2 +1,6 @@ page = PAGE -page.10 < styles.content.get \ No newline at end of file +page.10 < styles.content.get + +plugin.tx_cartproducts { + view.partialRootPaths.1 = EXT:cart_products_test/Resources/Private/Partials/ +} diff --git a/Tests/Fixtures/cart_products_test/Resources/Private/Partials/Product/CartForm.html b/Tests/Fixtures/cart_products_test/Resources/Private/Partials/Product/CartForm.html new file mode 100644 index 00000000..292f6648 --- /dev/null +++ b/Tests/Fixtures/cart_products_test/Resources/Private/Partials/Product/CartForm.html @@ -0,0 +1,58 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+ + From f0cb8107c4bf44b6e6141ac9f67926cc789294d4 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Mon, 24 Feb 2025 14:49:45 +0100 Subject: [PATCH 3/3] [CLEANUP] Group php and acceptance test in GitHub Action similar to GitLab CI Resolves: #256 --- .github/workflows/ci.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4d7a0e33..8af1eac2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -88,10 +88,13 @@ jobs: run: |- composer require --no-interaction --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}" + - name: Build codeception tester + run: vendor/bin/codecept build + - name: Code Quality (by PHPStan) run: vendor/bin/phpstan analyse -c Build/phpstan.neon - tests-acceptance: + test-php: runs-on: ubuntu-latest needs: - coding-guideline @@ -121,6 +124,17 @@ jobs: - name: Run Functional Tests PHP8.4 run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional + test-acceptance: + runs-on: ubuntu-latest + needs: + - test-php + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v17 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Run Acceptance Tests PHP8.2 run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-acceptance