Skip to content

Commit

Permalink
test: adapt functional tests to GLPI 10
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Dec 1, 2021
1 parent dc71c02 commit 86b56a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tests/4-functional/Central.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(),
Expand Down
26 changes: 5 additions & 21 deletions tests/src/CommonBrowsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 86b56a3

Please sign in to comment.