Source
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @backup dashboard, dashboard_user, dashboard_usrgrp
*/
class testPageDashboardList extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
public function testPageDashboardList_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.
$this->assertTrue(($this->query('name:dashboardForm')->asForm()->one())->query('button:Delete')->exists());
// Check header buttons.
$this->assertTrue($this->query('button:Create dashboard')->exists());
$this->assertTrue($this->query('xpath://button[@title="Kiosk mode"]')->exists());
}
public static function getCheckFilterData() {
return [
[
[
'fields' => [
'Show' => 'All'
],
'result_count' => 16
]
],
[
[
'fields' => [
'Show' => 'Created by me'
],
'result_count' => 15
]
],