Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @dataSource TopHostsWidget, ItemValueWidget, DynamicItemWidgets
*
* @backup dashboard, dashboard_user, dashboard_usrgrp
*/
class testDashboardsListPage extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
public function testDashboardsListPage_CheckLayout() {
$this->page->login()->open('zabbix.php?action=dashboard.list');
$this->page->assertTitle('Dashboards');
$table = $this->query('class:list-table')->asTable()->one();
$this->assertEquals(['', 'Name'], $table->getHeadersText());
// Check filter collapse/expand.
foreach (['true', 'false'] as $status) {
$filter_tab = $this->query('xpath://a[contains(@class, "filter-trigger")]')->one();
$filter_tab->parents('xpath:/li[@aria-expanded="'.$status.'"]')->one()->click();
}
// Check filter fields.
$filter_form = $this->query('name:zbx_filter')->asForm()->one();
$this->assertEquals(['Name', 'Show'], $filter_form->getLabels()->asText());
foreach (['All', 'Created by me'] as $show_tag) {
$this->assertTrue($filter_form->query('xpath://ul[@id="filter_show"]/li/label[text()="'.$show_tag.'"]')->exists());
};
// Check filter buttons.
foreach (['Apply', 'Reset'] as $button) {
$this->assertTrue($filter_form->query('button', $button)->exists());
}
// Check dashboard list button.