'Dashboard with favorite maps widget', 'private' => 1, 'pages' => [ [ 'widgets' => [ [ 'type' => 'favmaps', 'x' => 0, 'y' => 0, 'width' => 12, 'height' => 4 ] ] ] ] ] ]); self::$dashboardid = $response['dashboardids'][0]; } public function testDashboardFavoriteMapsWidget_AddFavoriteMap() { $this->page->login()->open('sysmaps.php')->waitUntilReady(); $this->page->assertHeader('Maps'); $this->query('link', $this->map_test)->waitUntilClickable()->one()->click(); $this->page->waitUntilReady(); $button = $this->query('xpath://button[@id="addrm_fav"]')->waitUntilVisible()->one(); $this->assertEquals('Add to favorites', $button->getAttribute('title')); $button->waitUntilClickable()->click(); $this->query('id:addrm_fav')->one()->waitUntilAttributesPresent(['title' => 'Remove from favorites']); $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); $widget = CDashboardElement::find()->one()->getWidget('Favorite maps')->waitUntilReady()->getContent(); $this->assertEquals('zabbix.php?action=map.view&sysmapid='.$this->mapid, $widget->query('link', $this->map_test)->one()->getAttribute('href') ); $this->assertEquals(1, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='. zbx_dbstr('web.favorite.sysmapids').' AND value_id='.zbx_dbstr($this->mapid)) ); } public function testDashboardFavoriteMapsWidget_RemoveFavoriteMaps() { $favorite_maps = CDBHelper::getAll('SELECT value_id FROM profiles WHERE idx='.zbx_dbstr('web.favorite.sysmapids')); $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); $widget = CDashboardElement::find()->one()->getWidget('Favorite maps')->getContent(); foreach ($favorite_maps as $map) { // Added variable due to External Hook. $xpath = './/button[@data-sysmapid='.CXPathHelper::escapeQuotes($map['value_id']); $remove_item = $widget->query('xpath', $xpath.' and contains(@onclick, "rm4favorites")]')->waituntilClickable()->one(); $remove_item->click(); $remove_item->waitUntilNotVisible(); } $this->assertTrue($widget->query('xpath:.//td[text()="No maps added."]')->waitUntilVisible()->one()->isPresent()); $this->assertEquals(0, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='. zbx_dbstr('web.favorite.sysmapids')) ); } }