Skip to content

Commit

Permalink
Merge branch 'Design-v2' of github.com:codingioanniskrikos/CoreShop i…
Browse files Browse the repository at this point in the history
…nto Design-v2

* 'Design-v2' of github.com:codingioanniskrikos/CoreShop:
  [Design-v2] - behat fix feature
  [Design-v2] - behat test, category filter icons
  [Design-v2] - refactor sonarcloud
  [Design-v2] - Behat tests

# Conflicts:
#	src/CoreShop/Bundle/FrontendBundle/Resources/public/build/app.js
#	src/CoreShop/Bundle/FrontendBundle/Resources/public/build/entrypoints.json
#	src/CoreShop/Bundle/FrontendBundle/Resources/public/build/manifest.json
#	src/CoreShop/Bundle/FrontendBundle/Resources/public/build/vendors-node_modules_bootstrap_dist_js_bootstrap_esm_js-node_modules_swiper_swiper-bundle_css-d35cf9.css
#	src/CoreShop/Bundle/FrontendBundle/Resources/public/build/vendors-node_modules_bootstrap_dist_js_bootstrap_esm_js-node_modules_swiper_swiper-bundle_css-d35cf9.js
  • Loading branch information
dpfaffenbauer committed Nov 14, 2024
2 parents 19fbc1e + 76dc279 commit 39c10f7
Show file tree
Hide file tree
Showing 33 changed files with 221 additions and 229 deletions.
4 changes: 2 additions & 2 deletions features/ui/frontend/cart/adding_product_to_cart.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Adding a product to the cart
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart

Scenario: Adding a product to the cart as a logged in customer
Expand All @@ -23,5 +23,5 @@ Feature: Adding a product to the cart
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "RACING CAR"
And this item should have name "Racing Car"
And I should see "Racing Car" with unit price "€1,000.00" in my cart
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Feature: Adding a product to the cart with maximum Quantity to Order
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart

Scenario: Adding product to cart with less than minimum quantity to order
Given the product "TShirt" has a maximum order quantity of "100"
When I add 101 of this product to the cart
Then I should be on the cart summary page
And I should be notified that I can only order a maximum of 100 of TSHIRT
And I should be notified that I can only order a maximum of 100 of TShirt


Scenario: Adding product to cart with less than minimum quantity to order with smaller quantities
Given the product "TShirt" has a maximum order quantity of "2"
When I add 3 of this product to the cart
Then I should be on the cart summary page
And I should be notified that I can only order a maximum of 2 of TSHIRT
And I should be notified that I can only order a maximum of 2 of TShirt

Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Feature: Adding a product to the cart with minimum Quantity to Order
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart

Scenario: Adding product to cart with less than minimum quantity to order
Given the product "TShirt" has a minimum order quantity of "100"
When I add 99 of this product to the cart
Then I should be on the cart summary page
And I should be notified that I need to order at least 100 of TSHIRT
And I should be notified that I need to order at least 100 of TShirt


Scenario: Adding product to cart with less than minimum quantity to order with smaller quantities
Given the product "TShirt" has a minimum order quantity of "2"
When I add 1 of this product to the cart
Then I should be on the cart summary page
And I should be notified that I need to order at least 2 of TSHIRT
And I should be notified that I need to order at least 2 of TShirt

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Feature: Adding a product to the cart with a Product that is tracked and out-of-
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart

Scenario: Adding product to cart with more than stocked quantity
When I add 3 of this product to the cart
Then I should be on the cart summary page
And I should be notified that TSHIRT does not have sufficient stock
And I should be notified that TShirt does not have sufficient stock

Scenario: Adding product, with on-hold stock, to cart with more than stocked quantity
Given the product has 2 on hold
Expand All @@ -31,5 +31,5 @@ Feature: Adding a product to the cart with a Product that is tracked and out-of-
Given the product has 1 on hold
When I add 2 of this product to the cart
Then I should be on the cart summary page
And I should be notified that TSHIRT does not have sufficient stock
And I should be notified that TShirt does not have sufficient stock

4 changes: 2 additions & 2 deletions features/ui/frontend/cart/automatic_cart_price_rule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Getting an automatic cart price rule
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart
And my cart's total should be "€80.00"

Expand All @@ -25,6 +25,6 @@ Feature: Getting an automatic cart price rule
Then I should be on the cart summary page
And I should be notified that the product has been successfully added
And there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
And I should see "TShirt" with unit price "€100.00" in my cart
And my cart's total should be "€70.00"
4 changes: 2 additions & 2 deletions features/ui/frontend/cart/keep_cart_after_login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Feature: Maintaining cart after login
When I log in as "[email protected]" with "cybertruck" password
And I see the summary of my cart
Then there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"

Scenario: Having cart maintained after registration
Given I add this product to the cart
When I register with email "[email protected]" and password "bigbigbooster"
And I see the summary of my cart
Then there should be one item in my cart
And this item should have name "TSHIRT"
And this item should have name "TShirt"
10 changes: 5 additions & 5 deletions features/ui/frontend/category/view_category.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ Feature: Viewing a product details
When I switch to category "Coats" on main menu
Then I should see 3 products in the category list
And I change order to "Name Descending"
And I should see products in order "WINTER COAT,RAIN COAT,JACKET" in list
And I should see products in order "Winter Coat,Rain Coat,Jacket" in list
And I change order to "Name Ascending"
And I should see products in order "JACKET,RAIN COAT,WINTER COAT" in list
And I should see products in order "Jacket,Rain Coat,Winter Coat" in list
When I switch to category "Shoes" on left menu
And I change order to "Name Descending"
And I should see products in order "SHOE 2,SHOE" in list
And I should see products in order "Shoe 2,Shoe" in list
And I switch to view to "grid"
And I should see products in order "SHOE 2,SHOE" in grid
And I should see products in order "Shoe 2,Shoe" in grid
And I change order to "Name Ascending"
And I should see products in order "SHOE,SHOE 2" in grid
And I should see products in order "Shoe,Shoe 2" in grid
1 change: 1 addition & 0 deletions features/ui/frontend/payment/concurrency.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Feature: Create a new order
And the site has a tax rule group "AT"
And the tax rule group has a tax rule for country "Austria" with tax rate "AT"
And the site has a product "T-Shirt" priced at 2000
And the product is active and published and available for store "Austria"
And the product has the tax rule group "AT"
And the site has a customer "[email protected]"
And the customer "[email protected]" has an address with country "Austria", "4600", "Wels", "Freiung", "9-11/N3"
Expand Down
12 changes: 6 additions & 6 deletions src/CoreShop/Behat/Context/Ui/Frontend/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,23 @@ public function shouldBeOnMyCartSummaryPage(): void
*/
public function iShouldBeNotifiedThatItHasBeenSuccessfullyAdded(): void
{
$this->notificationChecker->checkNotification('ITEM ADDED', NotificationType::success());
$this->notificationChecker->checkNotification('Item added', NotificationType::success());
}

/**
* @Then I should be notified that the voucher has been applied
*/
public function iShouldBeNotifiedThatTheVoucherHasBeenApplied(): void
{
$this->notificationChecker->checkNotification('VOUCHER HAS BEEN SUCCESSFULLY APPLIED', NotificationType::success());
$this->notificationChecker->checkNotification('Voucher has been successfully applied', NotificationType::success());
}

/**
* @Then I should be notified that the voucher is invalid
*/
public function iShouldBeNotifiedThatTheVoucherIsInvalid(): void
{
$this->notificationChecker->checkNotification('THIS VOUCHER IS INVALID', NotificationType::error());
$this->notificationChecker->checkNotification('This voucher is invalid', NotificationType::error());
}

/**
Expand All @@ -184,7 +184,7 @@ public function iShouldBeNotifiedThatTheVoucherIsInvalid(): void
public function iShouldBeNotifiedThatItNeedToOrderAtLeastOf(string $quantity, string $productName): void
{
$this->notificationChecker->checkNotification(
sprintf('YOU NEED TO ORDER AT LEAST %s UNITS OF %s.', $quantity, $productName),
sprintf('You need to order at least %s units of %s.', $quantity, $productName),
NotificationType::error(),
);
}
Expand All @@ -195,7 +195,7 @@ public function iShouldBeNotifiedThatItNeedToOrderAtLeastOf(string $quantity, st
public function iShouldBeNotifiedThatICanOnlyOrderAMaximumQuantityOf(string $quantity, string $productName): void
{
$this->notificationChecker->checkNotification(
sprintf('YOU CAN ORDER A MAXIMUM OF %s UNITS OF %s.', $quantity, $productName),
sprintf('You can order a maximum of %s units of %s.', $quantity, $productName),
NotificationType::error(),
);
}
Expand All @@ -206,7 +206,7 @@ public function iShouldBeNotifiedThatICanOnlyOrderAMaximumQuantityOf(string $qua
public function iShouldBeNotifiedThatDoesNotHaveSufficientStock(string $productName): void
{
$this->notificationChecker->checkNotification(
sprintf('%s DOES NOT HAVE SUFFICIENT STOCK.', $productName),
sprintf('%s does not have sufficient stock.', $productName),
NotificationType::error(),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function specifyAddressPhoneNumber(?string $phoneNumber): void

public function acceptTermsOfService(): void
{
$this->getElement('terms_of_service')->check();
$this->getElement('terms_of_service')->click();
}

protected function getDefinedElements(): array
Expand Down
2 changes: 1 addition & 1 deletion src/CoreShop/Behat/Page/Frontend/Checkout/CustomerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function specifyGuestAddressCountry(?int $country): void

public function acceptTermsOfService(): void
{
$this->getElement('terms_of_service')->check();
$this->getElement('terms_of_service')->click();
}

public function submitGuestCheckout(): void
Expand Down
2 changes: 1 addition & 1 deletion src/CoreShop/Behat/Page/Frontend/Checkout/SummaryPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function acceptTermsOfService(): void

public function declineTermsOfService(): void
{
$this->getElement('terms_of_service')->uncheck();
$this->getElement('terms_of_service')->click();
}

public function submitQuote(): void
Expand Down
13 changes: 5 additions & 8 deletions src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,24 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Service\Attribute\SubscribedService;

class CartController extends FrontendController
{
#[Route('/coreshop_get_cart_items', name: 'coreshop_get_cart_items')]
public function widgetAction(Request $request, ShopperContextInterface $shopperContext): Response
public function widgetAction(Request $request): Response
{
$multiCartEnabled = $this->getParameter('coreshop.storage_list.multi_list.order');

$params = [
'cart' => $this->getCart(),
'multi_cart_enabled' => $this->getParameter('coreshop.storage_list.multi_list.order')
'multi_cart_enabled' => $this->getParameter('coreshop.storage_list.multi_list.order'),
];

if ($multiCartEnabled) {
$form = $this->container->get('form.factory')->createNamed('coreshop', CartListType::class, ['list' => $this->getCart()], [
'context' => $shopperContext->getContext(),
'context' => $this->container->get(ShopperContextInterface::class)->getContext(),
]);

$params['form'] = $form->createView();
Expand Down Expand Up @@ -270,7 +268,7 @@ public function addItemAction(Request $request): Response
$addToCart->getCartItem()->getQuantity(),
);

$this->addFlash('coreshop_global_success', $this->container->get('translator')->trans('coreshop.ui.item_added'));
$this->addFlash('success', $this->container->get('translator')->trans('coreshop.ui.item_added'));

if ($request->isXmlHttpRequest()) {
return new JsonResponse([
Expand All @@ -282,7 +280,7 @@ public function addItemAction(Request $request): Response
}

foreach ($form->getErrors(true, true) as $error) {
$this->addFlash('coreshop_global_error', $error->getMessage());
$this->addFlash('error', $error->getMessage());
}

if ($request->isXmlHttpRequest()) {
Expand All @@ -308,7 +306,6 @@ public function addItemAction(Request $request): Response
[
'form' => $form->createView(),
'product' => $product,
'_redirect' => $redirect,
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@

use CoreShop\Bundle\FrontendBundle\Controller\FrontendController;
use CoreShop\Component\Core\Context\ShopperContextInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;

class CartWidgetController extends FrontendController
{
private ShopperContextInterface $shopperContext;

public function __construct(ShopperContextInterface $shopperContext, ContainerInterface $container)
{
public function __construct(
ShopperContextInterface $shopperContext,
ContainerInterface $container,
) {
parent::__construct($container);
$this->shopperContext = $shopperContext;
}


public function cartNumberAction(): JsonResponse
{
$items = $this->shopperContext->getCart()->getItems();

return new JsonResponse(count($items));
}

}
}
6 changes: 3 additions & 3 deletions src/CoreShop/Bundle/FrontendBundle/Resources/assets/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import './scripts/shop.js';
import './scripts/variant.js';
import './scripts/map.js';
import {Carousel} from './scripts/carousel';
import {CartInfo} from './scripts/cartInfo';
//import {CartInfo} from './scripts/cartInfo';

document.addEventListener('DOMContentLoaded', function () {
const CartWidget = new CartInfo('/coreshop_get_cart_items', '.js-cart-widget');
// const CartWidget = new CartInfo('/coreshop_get_cart_items', '.js-cart-widget');
const CarouselProducts = new Carousel();

console.log(CartWidget);
//console.log(CartWidget);
console.log(CarouselProducts);
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ coreshop_payment_after:
defaults:
_controller: CoreShop\Bundle\PayumBundle\Controller\PaymentController::afterCaptureAction

coreshop_get_cart_items:
path: /coreshop_get_cart_items
methods: [GET]
defaults:
_controller: CoreShop\Bundle\FrontendBundle\Controller\CartController::widgetAction

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ coreshop.ui.wishlist: 'Wishlist'
coreshop.ui.wishlist_empty: 'Your wishlist is empty'
coreshop.ui.error: 'There was an Error'
coreshop.ui.success: 'The operation was successful'
coreshop.ui.error.voucher.not_found: 'This Voucher is invalid'
coreshop.ui.error.voucher.invalid: 'This Voucher is invalid'
coreshop.ui.error.voucher.not_found: 'This voucher is invalid'
coreshop.ui.error.voucher.invalid: 'This voucher is invalid'
coreshop.ui.success.voucher.stored: 'Voucher has been successfully applied'
coreshop.ui.success.voucher.successfully_removed: 'Voucher has been successfully removed'
coreshop.ui.voucher.code: 'Voucher'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
<div class="text-right cart-item-total-price">
<div><small>Total:</small></div>
<div class="price-new" {{ coreshop_test_html_attribute('cart-item-unit-price', item.name) }}>
<div class="price-new" {{ coreshop_test_html_attribute('cart-item-total-price', item.name) }}>
{% if item.discount < 0 %}
<span>({{ currency.convertAndFormat(item.discount) }})</span>
{% endif %}
Expand Down Expand Up @@ -96,7 +96,7 @@
title="{{ 'coreshop.ui.remove'|trans }}"
class="btn btn-link"
data-id="{{ item.id }}"
{{ coreshop_test_html_attribute('wishlist-remove-button', item.name) }}
{{ coreshop_test_html_attribute('cart-remove-button', item.name) }}
>
<i class="bi bi-trash me-2"></i> {{ 'coreshop.ui.remove'|trans }}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span class="cart-number">{% if cart.hasItems %}{{ cart.items|length }}{% else %}0{% endif %}</span>
<i class="bi bi-cart"></i>
</button>

<span class="cart-total" {{ coreshop_test_html_attribute('cart-total') }}>{{ currency.convertAndFormat(cart.total) }}</span>
<div class="dropdown-menu pull-right" aria-labelledby="dropdownMenuButton">
<div class="pt-1 px-3">
{% if cart.hasItems %}
Expand All @@ -29,7 +29,7 @@
</ul>
</div>
<div class="my-1">{{ 'coreshop.ui.subtotal'|trans }}: <span>{{ currency.convertAndFormat(cart.subtotal) }}</span></div>
<div class="mb-3">{{ 'coreshop.ui.total'|trans }}: <span {{ coreshop_test_html_attribute('cart-total') }}>{{ currency.convertAndFormat(cart.total) }}</span></div>
<div class="mb-3">{{ 'coreshop.ui.total'|trans }}: <span>{{ currency.convertAndFormat(cart.total) }}</span></div>
{% endif %}
<div class="d-flex gap-2">
{% if is_granted('CORESHOP_CART_SUMMARY') %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<span>{{ form_widget(list_form, coreshop_test_form_attribute('cart', cart_name)|coreshop_merge_recursive({'label': false,'attr': {'class': 'form-check-input'}})) }}</span>
<span {{ coreshop_test_html_attribute('name') }}>{{ cart_name }}</span>
</div>
<div {{ coreshop_test_html_attribute('total') }}><strong>{{ 'coreshop.ui.total'|trans }}: </strong>{{ currency.convertAndFormat(list.total) }}</div>
<div><strong>{{ 'coreshop.ui.total'|trans }}: </strong><span {{ coreshop_test_html_attribute('total') }}>{{ currency.convertAndFormat(list.total) }}</span></div>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 39c10f7

Please sign in to comment.