Skip to content

Commit

Permalink
OXDEV-7319 Add attribute assignment test
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzdemmer committed Dec 3, 2024
1 parent bf9d700 commit 8bd3b50
Showing 1 changed file with 152 additions and 0 deletions.
152 changes: 152 additions & 0 deletions tests/Codeception/Acceptance/Admin/AttributeAssignmentCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\EshopCommunity\Tests\Codeception\Acceptance\Admin;

use Codeception\Attribute\Group;
use OxidEsales\EshopCommunity\Tests\Codeception\Support\AcceptanceTester;

#[Group('admin')]
final class AttributeAssignmentCest
{
public function testAssignProductsToAttribute(AcceptanceTester $I): void
{
$I->wantToTest('assigning products to an attribute');

$I->amGoingTo('create and assign products to a new attribute');
$adminPanel = $I->loginAdmin();
$attributesPage = $adminPanel->openAttributes();
$mainAttributePage = $attributesPage
->switchLanguage('Deutsch')
->createAttribute('Test Size [DE] šÄßüл');
$productAssignmentPopup = $mainAttributePage->openAssignProductsPopup();

$I->expect('all products to be initially in unassigned list');
$productAssignmentPopup
->seeItem('1000', $productAssignmentPopup->list1)
->seeItem('1001', $productAssignmentPopup->list1)
->seeItem('10014', $productAssignmentPopup->list1)
->seeItem('1002', $productAssignmentPopup->list1)
->dontSeeItem('1000', $productAssignmentPopup->list2)
->dontSeeItem('1001', $productAssignmentPopup->list2)
->dontSeeItem('10014', $productAssignmentPopup->list2)
->dontSeeItem('1002', $productAssignmentPopup->list2);

$I->amGoingTo('assign two products');
$productAssignmentPopup->assignItem('1000');
$productAssignmentPopup->assignItem('10014');

$I->expect('only selected products to be assigned');
$productAssignmentPopup
->seeItem('1000', $productAssignmentPopup->list2)
->seeItem('10014', $productAssignmentPopup->list2)
->seeItem('1001', $productAssignmentPopup->list1)
->seeItem('1002', $productAssignmentPopup->list1);

$I->amGoingTo('assign remaining products');
$productAssignmentPopup->assignAll();

$I->expect('all products to be in assigned list');
$productAssignmentPopup
->seeItem('1000', $productAssignmentPopup->list2)
->seeItem('1001', $productAssignmentPopup->list2)
->seeItem('10014', $productAssignmentPopup->list2)
->seeItem('1002', $productAssignmentPopup->list2);

$I->amGoingTo('unassign specific product');
$productAssignmentPopup->assignItem('1001', $productAssignmentPopup->list2, $productAssignmentPopup->list1);

$I->expect('specific product to be unassigned');
$productAssignmentPopup
->seeItem('1001', $productAssignmentPopup->list1)
->seeItem('1000', $productAssignmentPopup->list2)
->seeItem('10014', $productAssignmentPopup->list2)
->seeItem('1002', $productAssignmentPopup->list2);

$I->amGoingTo('unassign all products');
$productAssignmentPopup->unassignAll();

$I->expect('all products to be back in unassigned list');
$productAssignmentPopup
->seeItem('1000', $productAssignmentPopup->list1)
->seeItem('1001', $productAssignmentPopup->list1)
->seeItem('10014', $productAssignmentPopup->list1)
->seeItem('1002', $productAssignmentPopup->list1);
}

public function testAssignCategoriesToAttribute(AcceptanceTester $I): void
{
$I->wantToTest('assigning and sorting categories and attributes');

$I->amGoingTo('create new attribute and open category assignment');
$adminPanel = $I->loginAdmin();
$attributesPage = $adminPanel->openAttributes();
$mainAttributePage = $attributesPage
->switchLanguage('Deutsch')
->createAttribute('Test Color [DE] šÄßüл');
$categoryPage = $mainAttributePage->openCategoryTab();
$categoryAssignmentPopup = $categoryPage->openAssignCategoriesPopup();

$I->expect('categories to be initially in unassigned list');
$categoryAssignmentPopup
->seeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list1)
->seeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list1)
->dontSeeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list2)
->dontSeeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list2);

$I->amGoingTo('assign single category');
$categoryAssignmentPopup->assignItem('Test category 0 [DE] šÄßüл');

$I->expect('only selected category to be assigned');
$categoryAssignmentPopup
->seeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list2)
->seeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list1);

$I->amGoingTo('test attribute sorting within category');
$categoryAssignmentPopup->selectCategoryItem('Test category 0 [DE] šÄßüл');

$categoryAssignmentPopup
->seeItemInRow('Test attribute 1 [DE] šÄßüл', $categoryAssignmentPopup->list3, 1)
->seeItemInRow('Test attribute 2 [DE] šÄßüл', $categoryAssignmentPopup->list3, 2)
->seeItemInRow('Test attribute 3 [DE] šÄßüл', $categoryAssignmentPopup->list3, 3)
->seeItemInRow('Test Color [DE] šÄßüл', $categoryAssignmentPopup->list3, 4);

$I->amGoingTo('change attribute order');
$categoryAssignmentPopup->selectAttributeItem('Test Color [DE] šÄßüл');
$categoryAssignmentPopup->moveUp();
$categoryAssignmentPopup->selectAttributeItem('Test Color [DE] šÄßüл');
$categoryAssignmentPopup->moveUp();

$categoryAssignmentPopup
->seeItemInRow('Test attribute 1 [DE] šÄßüл', $categoryAssignmentPopup->list3, 1)
->seeItemInRow('Test Color [DE] šÄßüл', $categoryAssignmentPopup->list3, 2)
->seeItemInRow('Test attribute 2 [DE] šÄßüл', $categoryAssignmentPopup->list3, 3)
->seeItemInRow('Test attribute 3 [DE] šÄßüл', $categoryAssignmentPopup->list3, 4);

$I->amGoingTo('assign remaining category');
$categoryAssignmentPopup->assignAll();

$I->expect('all categories to be assigned');
$categoryAssignmentPopup
->seeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list2)
->seeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list2)
->dontSeeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list1)
->dontSeeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list1);

$I->amGoingTo('unassign all categories');
$categoryAssignmentPopup->unassignAll();

$I->expect('all categories to be back in unassigned list');
$categoryAssignmentPopup
->seeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list1)
->seeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list1)
->dontSeeItem('Test category 0 [DE] šÄßüл', $categoryAssignmentPopup->list2)
->dontSeeItem('Test category 1 [DE] šÄßüл', $categoryAssignmentPopup->list2);
}
}

0 comments on commit 8bd3b50

Please sign in to comment.