From 86b56a3abce0cdb8d8821cf571099b4d9a173e49 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 30 Nov 2021 08:39:06 +0100 Subject: [PATCH] test: adapt functional tests to GLPI 10 Signed-off-by: Thierry Bugier --- tests/4-functional/Central.php | 4 ++-- tests/src/CommonBrowsing.php | 26 +++++--------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/tests/4-functional/Central.php b/tests/4-functional/Central.php index 493526026..3abde4cb4 100644 --- a/tests/4-functional/Central.php +++ b/tests/4-functional/Central.php @@ -5,7 +5,7 @@ class Central extends CommonFunctionalTestCase { private $selectors = [ - 'formsTab' => '#page > div > div > ul > li > a[title="Forms"]', + 'formsTab' => '#page ul > li > a[title="Forms"]', ]; public function testCentralHasTab() { @@ -18,8 +18,8 @@ public function testCentralHasTab() { } public function testFormsAreVisible() { - // Use a clean entity for the tests $this->login('glpi', 'glpi'); + // Use a clean entity for the tests $entity = new \Entity(); $entityId = $entity->import([ 'name' => $this->getUniqueString(), diff --git a/tests/src/CommonBrowsing.php b/tests/src/CommonBrowsing.php index 81d3715c1..50bf0f0e1 100644 --- a/tests/src/CommonBrowsing.php +++ b/tests/src/CommonBrowsing.php @@ -16,9 +16,11 @@ class CommonBrowsing { private $selectors = [ // Selectors available in the header of GLPI (most pages) '_header' => [ - 'user menu' => 'aside.navbar .user-menu a', - 'entity select dialog' => 'aside.navbar .dropdown-menu.dropdown-menu-end .dropstart + .dropstart a', + 'user icon' => 'body > div.page > header > div > div.ms-md-4.d-none.d-lg-block', + 'user menu' => 'div.navbar-nav.flex-row.order-md-last.user-menu > div > a', + 'entity select dialog' => '.dropdown-menu.dropdown-menu-end .dropstart + .dropstart a', 'entity search input' => 'input[name="entsearchtext"]', + 'entity search button' => 'body > div.page > header > div > div.ms-md-4.d-none.d-lg-block > div > div.navbar-nav.flex-row.order-md-last.user-menu > div > div > div:nth-child(3) > div div > button', 'globalEntitySelect' => '#global_entity_select', 'entityTreeView' => 'ul.jstree-container-ul', @@ -61,25 +63,7 @@ public function logout() { * @param bool $subtree if true, select the subtree of the entity */ public function changeActiveEntity(Entity $entity, bool $subtree) { - // Open the user menu - $this->test->client->executeScript(" - document.querySelector('" . $this->selectors['_header']['user-menu'] . "').click(); - "); - $this->test->client->waitForVisibility($this->selectors['_header']['entity select dialog']); - - // Open the entity selection dialog - $this->test->client->executeScript(" - document.querySelector('" . $this->selectors['_header']['entity select dialog'] . "').click(); - "); - $this->test->client->waitForVisibility($this->selectors['_header']['entity search input']); - - // - $this->test->client->executeScript(" - document.querySelector('" . $this->selectors['_header']['entity search input'] . "').value('" . addcslashes($entity->fields['name'], "'") . "'); - "); - $this->test->client->waitForVisibility('tr[id="ui-id-' . $entity->getID() . '"] .fancytree-title'); - - // TODO : Find a way to select the entity to use. Thre is nothing in the DOM to select it + $this->test->crawler = $this->test->client->request('GET', '/front/central.php?active_entity=' . $entity->getID()); } public function openTab($title) {