From 478533ae6017f082e9daf4812aaefbcf5e543648 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Wed, 22 Jan 2020 08:14:06 +0100 Subject: [PATCH 1/5] fix laravel 6 compartibility of tests; remove duplicated pipeline execution --- .github/workflows/ci.yml | 2 +- packages/Webkul/Core/src/Helpers/Laravel5Helper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f74da491..46fc3a4aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push, pull_request] +on: push jobs: tests: diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index 99a4f1a1e..7b8cfb7f2 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -74,7 +74,7 @@ class Laravel5Helper extends Laravel5 'product_id' => $product->id, 'inventory_source_id' => 1, ])); - Event::fire('catalog.product.create.after', $product); + Event::dispatch('catalog.product.create.after', $product); return $product; } private function createAttributeValues($id, array $attributeValues = []) From 8ee311859715b9c0c7ab6b4e1a87bafbfcd3f1fe Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Wed, 22 Jan 2020 08:31:20 +0100 Subject: [PATCH 2/5] extend failing test; add test artifacts in pipeline --- .github/workflows/ci.yml | 6 ++ tests/functional/Shop/GuestCheckoutCest.php | 103 ++++++++++++-------- 2 files changed, 67 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46fc3a4aa..a9baec3c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,3 +54,9 @@ jobs: - name: Execute trigger tests run: set -e && vendor/bin/codecept run trigger + + - name: Persist test artifacts + uses: actions/upload-artifact@v1 + with: + name: test_artifacts + path: tests/_output diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php index d6a66f732..ea712b673 100644 --- a/tests/functional/Shop/GuestCheckoutCest.php +++ b/tests/functional/Shop/GuestCheckoutCest.php @@ -1,6 +1,8 @@ faker = Factory::create(); $pConfigDefault = [ - 'productInventory' => ['qty' => $this->faker->randomNumber(2)], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, + 'productInventory' => ['qty' => $this->faker->randomNumber(2)], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, 'guest_checkout' => 0 ], ]; $pConfigGuestCheckout = [ - 'productInventory' => ['qty' => $this->faker->randomNumber(2)], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, + 'productInventory' => ['qty' => $this->faker->randomNumber(2)], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, 'guest_checkout' => 1 ], ]; @@ -38,53 +41,69 @@ class GuestCheckoutCest $this->productGuestCheckout->refresh(); } - public function testGuestCheckout(FunctionalTester $I) { + /** + * @param FunctionalTester $I + * @param Example $example + * + * @dataProvider guestCheckoutProvider + */ + public function testGuestCheckout(FunctionalTester $I, Example $example): void + { + $product = ($example['guest_product']) ? $this->productGuestCheckout : $this->productNoGuestCheckout; + $I->amGoingTo('try to add products to cart with guest checkout turned on or off'); - $scenarios = [ + $I->wantTo('test conjunction "' . $example['name'] . '" with globalConfig = ' . $example['globalConfig'] . ' && product config = ' . $product->getAttribute('guest_checkout')); + $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $example['globalConfig']]); + $I->assertEquals($example['globalConfig'], + core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')); + $I->amOnRoute('shop.home.index'); + $I->see($product->name, '//div[@class="product-information"]/div[@class="product-name"]'); + $I->click(__('shop::app.products.add-to-cart'), + '//form[input[@name="product_id"][@value="' . $product->id . '"]]/button'); + $I->seeInSource(__('shop::app.checkout.cart.item.success')); + $I->amOnRoute('shop.checkout.cart.index'); + $I->see('Shopping Cart', '//div[@class="title"]'); + $I->makeHtmlSnapshot('guestCheckout_' . $example['globalConfig'] . '_' . $product->getAttribute('guest_checkout')); + $I->see($product->name, '//div[@class="item-title"]'); + $I->click(__('shop::app.checkout.cart.proceed-to-checkout'), + '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); + $I->seeCurrentRouteIs($example['expectedRoute']); + $cart = Cart::getCart(); + $I->assertTrue(Cart::removeItem($cart->items[0]->id)); + } + + protected function guestCheckoutProvider(): array + { + return [ [ - 'name' => 'false / false', - 'globalConfig' => 0, - 'product' => $this->productNoGuestCheckout, + 'name' => 'false / false', + 'globalConfig' => 0, + 'guest_product' => false, + 'product' => $this->productNoGuestCheckout, 'expectedRoute' => 'customer.session.index' ], [ - 'name' => 'false / true', - 'globalConfig' => 0, - 'product' => $this->productGuestCheckout, + 'name' => 'false / true', + 'globalConfig' => 0, + 'guest_product' => true, + 'product' => $this->productGuestCheckout, 'expectedRoute' => 'customer.session.index' ], [ - 'name' => 'true / false', - 'globalConfig' => 1, - 'product' => $this->productNoGuestCheckout, + 'name' => 'true / false', + 'globalConfig' => 1, + 'guest_product' => false, + 'product' => $this->productNoGuestCheckout, 'expectedRoute' => 'customer.session.index' ], [ - 'name' => 'true / true', - 'globalConfig' => 1, - 'product' => $this->productGuestCheckout, + 'name' => 'true / true', + 'globalConfig' => 1, + 'guest_product' => true, + 'product' => $this->productGuestCheckout, 'expectedRoute' => 'shop.checkout.onepage.index' ], ]; - - foreach ($scenarios as $scenario) { - $I->wantTo('test conjunction "' . $scenario['name'] . '" with globalConfig = ' . $scenario['globalConfig'] . ' && product config = ' . $scenario['product']->getAttribute('guest_checkout')); - $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $scenario['globalConfig']]); - $I->assertEquals($scenario['globalConfig'], core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')); - $I->amOnRoute('shop.home.index'); - $I->see($scenario['product']->name, '//div[@class="product-information"]/div[@class="product-name"]'); - $I->click(__('shop::app.products.add-to-cart'), - '//form[input[@name="product_id"][@value="' . $scenario['product']->id . '"]]/button'); - $I->seeInSource(__('shop::app.checkout.cart.item.success')); - $I->amOnRoute('shop.checkout.cart.index'); - $I->see('Shopping Cart', '//div[@class="title"]'); - $I->makeHtmlSnapshot('guestCheckout_'.$scenario['globalConfig'].'_'.$scenario['product']->getAttribute('guest_checkout')); - $I->see($scenario['product']->name, '//div[@class="item-title"]'); - $I->click( __('shop::app.checkout.cart.proceed-to-checkout'), '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); - $I->seeCurrentRouteIs($scenario['expectedRoute']); - $cart = Cart::getCart(); - $I->assertTrue(Cart::removeItem($cart->items[0]->id)); - } } } \ No newline at end of file From 3243437329b4c47755840cefc8424ed113634ebf Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Wed, 22 Jan 2020 08:35:19 +0100 Subject: [PATCH 3/5] fix test artifacts in pipeline --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9baec3c6..a60d6952a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,7 @@ jobs: - name: Persist test artifacts uses: actions/upload-artifact@v1 + if: always() with: name: test_artifacts path: tests/_output From 00ec9b8c907df67adc7b19aefb635af778002d43 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Wed, 22 Jan 2020 08:43:10 +0100 Subject: [PATCH 4/5] add missing directory in storage/app for test pipeline --- storage/app/db-blade-compiler/views/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 storage/app/db-blade-compiler/views/.gitignore diff --git a/storage/app/db-blade-compiler/views/.gitignore b/storage/app/db-blade-compiler/views/.gitignore new file mode 100755 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/app/db-blade-compiler/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 78ccaf7ec0ae977776c8c4ea7f8ff5bca80d7d80 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Wed, 22 Jan 2020 09:03:07 +0100 Subject: [PATCH 5/5] reenable pipeline when pr is created --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a60d6952a..829a18122 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: push +on: [push, pull_request] jobs: tests: