]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | import { $$, by, element } from 'protractor'; |
2 | import { PageHelper } from '../page-helper.po'; | |
11fdf7f2 | 3 | |
9f95a23c TL |
4 | export class ManagerModulesPageHelper extends PageHelper { |
5 | pages = { | |
6 | index: '/#/mgr-modules' | |
7 | }; | |
8 | ||
9 | // NOTABLE ISSUES: .clear() does not work on most text boxes, therefore using sendKeys | |
10 | // a Ctrl + 'a' BACK_SPACE is used. | |
11 | // The need to click the module repeatedly in the table is to ensure | |
12 | // that the values in the details tab updated. This fixed a bug I experienced. | |
13 | ||
14 | async editMgrModule(name: string, tuple: string[][]) { | |
15 | // Selects the Manager Module and then fills in the desired fields. | |
16 | // Doesn't check/uncheck boxes because it is not reflected in the details table. | |
17 | // DOES NOT WORK FOR ALL MGR MODULES, for example, Device health | |
18 | await this.navigateTo(); | |
19 | await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); | |
20 | await element(by.cssContainingText('button', 'Edit')).click(); | |
21 | ||
22 | for (const entry of tuple) { | |
23 | // Clears fields and adds edits | |
24 | await this.clearInput(element(by.id(entry[1]))); | |
25 | await element(by.id(entry[1])).sendKeys(entry[0]); | |
26 | } | |
27 | ||
28 | await element(by.cssContainingText('button', 'Update')).click(); | |
29 | // Checks if edits appear | |
30 | await this.navigateTo(); | |
31 | await this.waitVisibility(this.getFirstTableCellWithText(name)); | |
32 | await this.getFirstTableCellWithText(name).click(); | |
33 | for (const entry of tuple) { | |
34 | await this.waitTextToBePresent($$('.datatable-body').last(), entry[0]); | |
35 | } | |
36 | ||
37 | // Clear mgr module of all edits made to it | |
38 | await this.navigateTo(); | |
39 | await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); | |
40 | await element(by.cssContainingText('button', 'Edit')).click(); | |
41 | ||
42 | // Clears the editable fields | |
43 | for (const entry of tuple) { | |
44 | await this.clearInput(element(by.id(entry[1]))); | |
45 | } | |
46 | ||
47 | // Checks that clearing represents in details tab of module | |
48 | await element(by.cssContainingText('button', 'Update')).click(); | |
49 | await this.navigateTo(); | |
50 | await this.waitVisibility(this.getFirstTableCellWithText(name)); | |
51 | await this.getFirstTableCellWithText(name).click(); | |
52 | for (const entry of tuple) { | |
53 | await this.waitTextNotPresent($$('.datatable-body').last(), entry[0]); | |
54 | } | |
55 | } | |
56 | ||
57 | async editDevicehealth( | |
58 | threshhold?: string, | |
59 | pooln?: string, | |
60 | retention?: string, | |
61 | scrape?: string, | |
62 | sleep?: string, | |
63 | warn?: string | |
64 | ) { | |
65 | // Isn't called by editMgrModule since clearing doesn't work. | |
66 | // Selects the Devicehealth manager module, then fills in the desired fields, including all fields except | |
67 | // checkboxes. Clicking checkboxes has been a notable issue in Protractor, therefore they were omitted in this | |
68 | // version of the tests. Could be added in a future PR. Then checks if these edits appear in the details table. | |
69 | await this.navigateTo(); | |
70 | let devHealthArray: [string, string][]; | |
71 | devHealthArray = [ | |
72 | [threshhold, 'mark_out_threshold'], | |
73 | [pooln, 'pool_name'], | |
74 | [retention, 'retention_period'], | |
75 | [scrape, 'scrape_frequency'], | |
76 | [sleep, 'sleep_interval'], | |
77 | [warn, 'warn_threshold'] | |
78 | ]; | |
79 | ||
80 | await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth')); | |
81 | await element(by.cssContainingText('button', 'Edit')).click(); | |
82 | for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) { | |
83 | if (devHealthTuple[0] !== undefined) { | |
84 | // Clears and inputs edits | |
85 | await this.clearInput(element(by.id(devHealthTuple[1]))); | |
86 | await element(by.id(devHealthTuple[1])).sendKeys(devHealthTuple[0]); | |
87 | } | |
88 | } | |
89 | ||
90 | await element(by.cssContainingText('button', 'Update')).click(); | |
91 | await this.navigateTo(); | |
92 | await this.waitVisibility(this.getFirstTableCellWithText('devicehealth')); | |
93 | // Checks for visibility of devicehealth in table | |
94 | await this.getFirstTableCellWithText('devicehealth').click(); | |
95 | for (let i = 0, devHealthTuple: [string, string]; (devHealthTuple = devHealthArray[i]); i++) { | |
96 | if (devHealthTuple[0] !== undefined) { | |
97 | await this.waitFn(async () => { | |
98 | // Repeatedly reclicks the module to check if edits has been done | |
99 | await element(by.cssContainingText('.datatable-body-cell-label', 'devicehealth')).click(); | |
100 | return this.waitTextToBePresent($$('.datatable-body').last(), devHealthTuple[0]); | |
101 | }); | |
102 | } | |
103 | } | |
104 | ||
105 | // Inputs old values into devicehealth fields. This manager module doesnt allow for updates | |
106 | // to be made when the values are cleared. Therefore, I restored them to their original values | |
107 | // (on my local run of ceph-dev, this is subject to change i would assume). I'd imagine there is a | |
108 | // better way of doing this. | |
109 | await this.navigateTo(); | |
110 | await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth')); | |
111 | await element(by.cssContainingText('button', 'Edit')).click(); | |
112 | await this.clearInput(element(by.id('mark_out_threshold'))); | |
113 | await element(by.id('mark_out_threshold')).sendKeys('2419200'); | |
114 | ||
115 | await this.clearInput(element(by.id('pool_name'))); | |
116 | await element(by.id('pool_name')).sendKeys('device_health_metrics'); | |
117 | ||
118 | await this.clearInput(element(by.id('retention_period'))); | |
119 | await element(by.id('retention_period')).sendKeys('15552000'); | |
120 | ||
121 | await this.clearInput(element(by.id('scrape_frequency'))); | |
122 | await element(by.id('scrape_frequency')).sendKeys('86400'); | |
123 | ||
124 | await this.clearInput(element(by.id('sleep_interval'))); | |
125 | await element(by.id('sleep_interval')).sendKeys('600'); | |
126 | ||
127 | await this.clearInput(element(by.id('warn_threshold'))); | |
128 | await element(by.id('warn_threshold')).sendKeys('7257600'); | |
129 | ||
130 | // Checks that clearing represents in details tab | |
131 | await this.waitClickableAndClick(element(by.cssContainingText('button', 'Update'))); | |
132 | await this.navigateTo(); | |
133 | await this.waitVisibility(this.getFirstTableCellWithText('devicehealth')); | |
134 | await this.getFirstTableCellWithText('devicehealth').click(); | |
135 | for (let i = 0, devHealthTuple: [string, string]; (devHealthTuple = devHealthArray[i]); i++) { | |
136 | if (devHealthTuple[0] !== undefined) { | |
137 | await this.waitFn(async () => { | |
138 | // Repeatedly reclicks the module to check if clearing has been done | |
139 | await element(by.cssContainingText('.datatable-body-cell-label', 'devicehealth')).click(); | |
140 | return this.waitTextNotPresent($$('.datatable-body').last(), devHealthTuple[0]); | |
141 | }); | |
142 | } | |
143 | } | |
11fdf7f2 TL |
144 | } |
145 | } |