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';
/**
* @browsers chrome
*/
class testMultiselect extends CWebTest {
public function testMultiselect_SuggestExisting() {
$this->checkSuggest('zabbix.php?action=problem.view&filter_reset=1', 'zbx_filter',
'Host groups', 'z', 'multiselect-suggest'
);
}
public function testMultiselect_SuggestNoMatches() {
$this->checkSuggest('zabbix.php?action=problem.view&filter_reset=1','zbx_filter',
'Host groups', 'QQQ', 'multiselect-matches'
);
}
public function testMultiselect_SuggestCreateNew() {
$this->checkSuggest('zabbix.php?action=host.edit','host-form', 'Host groups', 'QQQwww',
'multiselect-suggest'
);
}
public function checkSuggest($link, $query, $name, $string, $class) {
$this->page->login()->open($link)->waitUntilReady();
$this->page->updateViewport();
$field = $this->query('name:'.$query)->asForm()->one()->getField($name);
$element = $field->query('tag:input')->one();
$element->type($string);
$this->query('class', $class)->waitUntilVisible();
// Cover proxy selection field, because it gets changed depending on proxy names' lengths in the dropdown.
$covered_region = ($query === 'host-form')
? [$element, ['x' => 193, 'y' => 317, 'width' => 452, 'height' => 22]]
: [$element];
$this->assertScreenshotExcept($element->parents('class', (($query === 'host-form') ? 'form-grid' : 'table-forms'))
->one(), $covered_region, $string
);
}