Welcome to mirror list, hosted at ThFree Co, Russian Federation.

testPageScreens.php « selenium « tests « php « frontends - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1a0f3447fa4345828d95edb5decc0b8ef0b6787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/*
** Zabbix
** Copyright (C) 2001-2019 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/CLegacyWebTest.php';

class testPageScreens extends CLegacyWebTest {

	public static function allScreens() {
		return CDBHelper::getDataProvider('SELECT screenid,name FROM screens WHERE templateid IS NULL ORDER BY screenid');
	}

	public function testPageScreens_CheckLayout() {
		$screens = CDBHelper::getAll('SELECT name FROM screens WHERE templateid IS NULL');

		$this->zbxTestLogin('screenconf.php');
		$this->zbxTestCheckTitle('Configuration of screens');

		$this->zbxTestCheckHeader('Screens');
		$this->zbxTestTextPresent('Filter');
		$this->zbxTestTextPresent(sprintf('Displaying %1$s of %1$s found', count($screens)));
		$this->zbxTestDropdownAssertSelected('config', 'Screens');

		$this->zbxTestTextPresent(['Name', 'Dimension (cols x rows)', 'Actions']);

		foreach ($screens as $screen) {
			$this->zbxTestTextPresent($screen['name']);
		}
		$this->zbxTestTextPresent(['Export', 'Delete']);
	}

	/**
	* @dataProvider allScreens
	*/
	public function testPageScreens_SimpleEdit($screen) {
		$this->zbxTestLogin('screenconf.php');
		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestClickLinkText($screen['name']);
		$this->zbxTestCheckTitle('Custom screens [refreshed every 30 sec.]');
		$this->zbxTestTextPresent($screen['name']);
		$this->zbxTestTextPresent('Edit screen');
		$this->zbxTestCheckHeader('Screens');
	}

	/**
	* @dataProvider allScreens
	*/
	public function testPageScreens_SimpleUpdate($screen) {
		$sqlScreen = 'SELECT * FROM screens WHERE screenid='.$screen['screenid'];
		$oldHashScreen = CDBHelper::getHash($sqlScreen);
		$sqlScreenItems = 'SELECT * FROM screens_items WHERE screenid='.$screen['screenid'].' ORDER BY screenitemid';
		$oldHashScreenItems = CDBHelper::getHash($sqlScreenItems);

		$this->zbxTestLogin('screenconf.php');
		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestHrefClickWait('?form=update&screenid='.$screen['screenid']);

		$this->zbxTestCheckHeader('Screens');
		$this->zbxTestTextPresent(['Screen','Sharing']);
		$this->zbxTestTextPresent(['Owner', 'Name', 'Columns', 'Rows']);

		$this->zbxTestClickWait('update');

		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestTextPresent('Screen updated');

		$this->assertEquals($oldHashScreen, CDBHelper::getHash($sqlScreen));
		$this->assertEquals($oldHashScreenItems, CDBHelper::getHash($sqlScreenItems));
	}

	public function testPageScreens_Create() {
		$this->zbxTestLogin('screenconf.php');
		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestClickButtonText('Create screen');

		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestTextPresent(['Owner', 'Name', 'Columns', 'Rows']);

		$this->zbxTestClickWait('cancel');

		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestTextNotPresent(['Owner', 'Columns', 'Rows']);
	}

	/**
	 * @dataProvider allScreens
	 * @backup-once screens
	 */
	public function testPageScreens_MassDelete($screen) {
		$this->zbxTestLogin('screenconf.php');
		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestCheckboxSelect('screens_'.$screen['screenid']);
		$this->zbxTestClickButton('screen.massdelete');
		$this->zbxTestAcceptAlert();

		$this->zbxTestCheckTitle('Configuration of screens');
		$this->zbxTestTextPresent('Screen deleted');
		$this->zbxTestCheckHeader('Screens');

		$sql = 'SELECT NULL FROM screens WHERE screenid='.$screen['screenid'];
		$this->assertEquals(0, CDBHelper::getCount($sql));
		$sql = 'SELECT NULL FROM screens_items WHERE screenid='.$screen['screenid'];
		$this->assertEquals(0, CDBHelper::getCount($sql));
		$sql = 'SELECT NULL FROM slides WHERE screenid='.$screen['screenid'];
		$this->assertEquals(0, CDBHelper::getCount($sql));
	}
}