1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hipanel\tests\_support\Page\Widget; |
4
|
|
|
|
5
|
|
|
use hipanel\tests\_support\AcceptanceTester; |
6
|
|
|
use hipanel\tests\_support\Page\Authenticated; |
7
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Input; |
8
|
|
|
use hipanel\tests\_support\Page\Widget\Input\TestableInput; |
9
|
|
|
use WebDriverKeys; |
10
|
|
|
|
11
|
|
|
class Grid extends Authenticated |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var string $Xpath Chropath of current grid |
15
|
|
|
*/ |
16
|
|
|
private $Xpath; |
17
|
|
|
|
18
|
|
|
public function __construct(AcceptanceTester $I, string $Xpath = "//form[contains(@id, 'bulk')]") |
19
|
|
|
{ |
20
|
|
|
parent::__construct($I); |
21
|
|
|
$this->Xpath = $Xpath; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param string[] $columnNames array of column names |
26
|
|
|
* @param string|null $representation the representation name |
27
|
|
|
* @throws \Codeception\Exception\ModuleException |
28
|
|
|
*/ |
29
|
|
|
public function containsColumns(array $columnNames, $representation = null): void |
30
|
|
|
{ |
31
|
|
|
$I = $this->tester; |
32
|
|
|
$formId = $I->grabAttributeFrom($this->Xpath, 'id'); |
33
|
|
|
|
34
|
|
|
if ($representation !== null) { |
35
|
|
|
$I->click("//button[contains(text(), 'View:')]"); |
36
|
|
|
$I->click("//ul/li/a[contains(text(), '$representation')]"); |
37
|
|
|
$I->waitForPageUpdate(120); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
foreach ($columnNames as $column) { |
41
|
|
|
$I->see($column, "//form[@id='$formId']//table/thead/tr/th"); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Filters grids table. |
47
|
|
|
* |
48
|
|
|
* @param TestableInput $inputElement |
49
|
|
|
* @param string $value |
50
|
|
|
* @throws \Codeception\Exception\ModuleException |
51
|
|
|
*/ |
52
|
|
|
public function filterBy(TestableInput $inputElement, string $value): void |
53
|
|
|
{ |
54
|
|
|
$inputElement->setValue($value); |
55
|
|
|
if ($inputElement instanceof Input) { |
56
|
|
|
$this->tester->pressKey($inputElement->getSelector(), WebDriverKeys::ENTER); |
57
|
|
|
} |
58
|
|
|
$this->tester->waitForPageUpdate(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Sorts grid by specified column. |
63
|
|
|
* |
64
|
|
|
* @param string $columnName |
65
|
|
|
* @throws \Codeception\Exception\ModuleException |
66
|
|
|
*/ |
67
|
|
|
public function sortBy(string $columnName): void |
68
|
|
|
{ |
69
|
|
|
$this->tester->click("//th/a[contains(text(), '$columnName')]"); |
70
|
|
|
$this->tester->waitForPageUpdate(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|