Skip to content

Commit 8d9dee5

Browse files
committed
Refactor dropdown interaction logic and clean up test imports
- Improved the DropdownInteractionTrait to ensure both 'active' and 'visible' classes are checked for dropdown visibility. - Updated tests to remove unused LoginTrait imports in CreateCallQueueTest, CreateExtensionsTest, and CreateIVRMenuTest. - Added testCreateCallQueue and testCreateIVRMenu methods in respective test classes to ensure proper inheritance and execution of parent tests.
1 parent a111e2a commit 8d9dee5

8 files changed

Lines changed: 30 additions & 6 deletions

File tree

tests/AdminCabinet/Lib/Traits/DropdownInteractionTrait.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function waitForDropdownToOpen(WebDriverElement $dropdown, int $waitTi
8484
self::$driver->wait($waitTime, 100)->until(
8585
function () use ($dropdown) {
8686
try {
87-
return strpos($dropdown->getAttribute('class'), 'active visible') !== false;
87+
return (strpos($dropdown->getAttribute('class'), 'active') !== false && strpos($dropdown->getAttribute('class'), 'visible') !== false);
8888
} catch (StaleElementReferenceException $e) {
8989
// Элемент стал устаревшим - вероятно, DOM обновился
9090
return false;
@@ -99,8 +99,13 @@ function () use ($dropdown) {
9999
function () use ($dropdown) {
100100
try {
101101
$menuXpath = './/div[contains(@class, "menu")]';
102-
$menu = $dropdown->findElement(WebDriverBy::xpath($menuXpath));
103-
return $menu->isDisplayed();
102+
$menus = $dropdown->findElements(WebDriverBy::xpath($menuXpath));
103+
foreach ($menus as $menu) {
104+
if ($menu->isDisplayed()) {
105+
return true;
106+
}
107+
}
108+
return false;
104109
} catch (NoSuchElementException | StaleElementReferenceException $e) {
105110
// Тихо игнорируем ожидаемые исключения во время ожидания
106111
return false;

tests/AdminCabinet/Tests/CallQueues/AccountantDepartmentTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@
2525

2626
/**
2727
* Test class for creating Accountant department Call Queue
28+
* docker exec -it mikopbx_php83 /bin/sh -c "/offload/rootfs/usr/www/vendor/bin/phpunit --configuration /offload/rootfs/usr/www/tests/AdminCabinet/debug-unit.xml /offload/rootfs/usr/www/tests/AdminCabinet/Tests/CallQueues/AccountantDepartmentTest.php"
2829
*/
2930
class AccountantDepartmentTest extends CreateCallQueueTest
3031
{
3132
protected function getCallQueueData(): array
3233
{
3334
return CallQueueDataFactory::getCallQueueData('accountant.department');
3435
}
36+
37+
public function testCreateCallQueue(): void
38+
{
39+
parent::testCreateCallQueue();
40+
}
3541
}

tests/AdminCabinet/Tests/CallQueues/SalesDepartmentTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@
2525

2626
/**
2727
* Test class for creating Sales department Call Queue
28+
* docker exec -it mikopbx_php83 /bin/sh -c "/offload/rootfs/usr/www/vendor/bin/phpunit --configuration /offload/rootfs/usr/www/tests/AdminCabinet/debug-unit.xml /offload/rootfs/usr/www/tests/AdminCabinet/Tests/CallQueues/SalesDepartmentTest.php"
2829
*/
2930
class SalesDepartmentTest extends CreateCallQueueTest
3031
{
3132
protected function getCallQueueData(): array
3233
{
3334
return CallQueueDataFactory::getCallQueueData('sales.department');
3435
}
36+
37+
public function testCreateCallQueue(): void
38+
{
39+
parent::testCreateCallQueue();
40+
}
3541
}

tests/AdminCabinet/Tests/CreateCallQueueTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
use Facebook\WebDriver\WebDriverBy;
2424
use MikoPBX\Tests\AdminCabinet\Lib\MikoPBXTestsBase;
25-
use MikoPBX\Tests\AdminCabinet\Tests\Traits\LoginTrait;
2625

2726
/**
2827
* Base class for Call Queue creation tests

tests/AdminCabinet/Tests/CreateExtensionsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
use Facebook\WebDriver\WebDriverBy;
2424
use MikoPBX\Tests\AdminCabinet\Lib\MikoPBXTestsBase;
25-
use MikoPBX\Tests\AdminCabinet\Tests\Traits\LoginTrait;
2625

2726
abstract class CreateExtensionsTest extends MikoPBXTestsBase
2827
{

tests/AdminCabinet/Tests/CreateIVRMenuTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Facebook\WebDriver\WebDriverBy;
66
use MikoPBX\Tests\AdminCabinet\Lib\MikoPBXTestsBase;
7-
use MikoPBX\Tests\AdminCabinet\Tests\Traits\LoginTrait;
87

98
/**
109
* Base class for IVR menu creation tests

tests/AdminCabinet/Tests/IVRMenus/MainIvrMenuTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ protected function getIVRMenuData(): array
3333
{
3434
return IVRMenuDataFactory::getIVRMenuData('main.ivr.menu');
3535
}
36+
37+
public function testCreateIVRMenu(): void
38+
{
39+
parent::testCreateIVRMenu();
40+
}
3641
}

tests/AdminCabinet/Tests/IVRMenus/SecondIvrMenuTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ protected function getIVRMenuData(): array
3232
{
3333
return IVRMenuDataFactory::getIVRMenuData('second.ivr.menu');
3434
}
35+
36+
public function testCreateIVRMenu(): void
37+
{
38+
parent::testCreateIVRMenu();
39+
}
3540
}

0 commit comments

Comments
 (0)