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

testGraphAxis.php « graphs « selenium « tests « ui - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e835f370cf251f509ee4ebad51e04ced05ed7abd (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 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';

/**
 * @backup profiles
 */
class testGraphAxis extends CWebTest {

	public function getDaylightSavingData() {
		return [
			[
				[
					'settings' => ['Time zone' => 'Europe/Riga'],
					'start_period' => '2020-10-25 00:00:00',
					'end_period' => '2020-10-25 08:00:00',
					'name' => 'Riga, Winter, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Europe/Riga'],
					'start_period' => '2020-03-29 00:00:00',
					'end_period' => '2020-03-29 08:00:00',
					'name' => 'Riga, Summer, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Europe/Riga'],
					'start_period' => '2020-10-25 03:00:00',
					'end_period' => '2020-10-25 05:00:00',
					'name' => 'Riga, Winter, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Europe/Riga'],
					'start_period' => '2020-03-29 02:00:00',
					'end_period' => '2020-03-29 04:00:00',
					'name' => 'Riga, Summer, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Lord_Howe'],
					'start_period' => '2020-10-04 00:00:00',
					'end_period' => '2020-10-04 08:00:00',
					'name' => 'Lord_Howe, Winter, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Lord_Howe'],
					'start_period' => '2020-04-05 00:00:00',
					'end_period' => '2020-04-05 08:00:00',
					'name' => 'Lord_Howe, Summer, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Lord_Howe'],
					'start_period' => '2020-10-04 01:00:00',
					'end_period' => '2020-10-04 03:00:00',
					'name' => 'Lord_Howe, Winter, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Lord_Howe'],
					'start_period' => '2020-04-05 01:00:00',
					'end_period' => '2020-04-05 03:00:00',
					'name' => 'Lord_Howe, Summer, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Eucla'],
					'start_period' => '2020-03-25 02:00:00',
					'end_period' => '2020-03-25 04:00:00',
					'name' => 'Eucla, Summer, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Australia/Eucla'],
					'start_period' => '2020-03-25 00:00:00',
					'end_period' => '2020-03-25 08:00:00',
					'name' => 'Eucla, Summer, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Pacific/Chatham'],
					'start_period' => '2020-04-05 02:00:00',
					'end_period' => '2020-04-05 04:00:00',
					'name' => 'Chatham, Summer, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Pacific/Chatham'],
					'start_period' => '2020-04-05 01:00:00',
					'end_period' => '2020-04-05 08:00:00',
					'name' => 'Chatham, Summer, big zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Pacific/Chatham'],
					'start_period' => '2020-09-27 02:00:00',
					'end_period' => '2020-09-27 04:00:00',
					'name' => 'Chatham, Winter, small zoom'
				]
			],
			[
				[
					'settings' => ['Time zone' => 'Pacific/Chatham'],
					'start_period' => '2020-09-27 00:00:00',
					'end_period' => '2020-09-27 08:00:00',
					'name' => 'Chatham, Winter, big zoom'
				]
			]
		];
	}

	/**
	 * Test for checking X axis on graphs depending on time zone and daylight saving changes.
	 *
	 * @dataProvider getDaylightSavingData
	 */
	public function testGraphAxis_DaylightSaving($data) {
		// Set timezone.
		$this->page->login()->open('zabbix.php?action=userprofile.edit')->waitUntilReady();
		$form = $this->query('name:user_form')->asForm()->waitUntilVisible()->one();

		/** For Pacific/Chatham timezone on clock change dates (in September and April) there might be one fail
		 *  for short period at night when info is not updated yet: 2:45 -> 3:45 or 3:45 -> 2:45.
		 *  Tests need to be run again and fix observed when timezone format is updated.
		 */
		if (CTestArrayHelper::get($data, 'settings.Time zone')) {
			$data['settings']['Time zone'] = CDateTimeHelper::getTimeZoneFormat($data['settings']['Time zone']);
		}

		$form->fill($data['settings']);
		$form->submit();

		// Go to Graphs and set time period.
		$this->page->open('zabbix.php?action=host.view')->waitUntilReady();
		$table = $this->query('xpath://form[@name="host_view"]/table[@class="list-table"]')
				->waitUntilReady()->asTable()->one();
		$table->findRow('Name', 'Dynamic widgets H2')->getColumn('Graphs')->query('tag:a')->one()->click();
		$this->page->waitUntilReady();
		$this->waitUntilGraphIsLoaded();
		$this->query('id:from')->one()->fill($data['start_period']);
		$this->query('id:to')->one()->fill($data['end_period']);
		$this->query('button:Apply')->one()->waitUntilClickable()->click();
		$this->page->waitUntilReady();
		// TODO: This sleep is added here because of DEV-1908.
		sleep(1);
		$this->assertScreenshot($this->waitUntilGraphIsLoaded(), $data['name']);
	}

	/**
	 * Function for waiting loader ring.
	 */
	private function waitUntilGraphIsLoaded() {
		try {
			$this->query('xpath://div[contains(@class,"is-loading")]/img')->waitUntilPresent();
		}
		catch (\Exception $ex) {
			// Code is not missing here.
		}

		return $this->query('xpath://div[not(contains(@class,"is-loading"))]/img')->waitUntilPresent()->one();
	}
}