]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | import { $, $$, by, element, protractor } from 'protractor'; |
2 | import { PageHelper } from '../page-helper.po'; | |
11fdf7f2 | 3 | |
9f95a23c TL |
4 | export class LogsPageHelper extends PageHelper { |
5 | pages = { index: '/#/logs' }; | |
11fdf7f2 | 6 | |
9f95a23c TL |
7 | async checkAuditForPoolFunction( |
8 | poolname: string, | |
9 | poolfunction: string, | |
10 | hour: number, | |
11 | minute: number | |
12 | ) { | |
13 | await this.navigateTo(); | |
14 | ||
15 | // sometimes the modal from deleting pool is still present at this point. | |
16 | // This wait makes sure it isn't | |
17 | await this.waitStaleness(element(by.cssContainingText('.modal-dialog', 'Delete Pool'))); | |
18 | ||
19 | // go to audit logs tab | |
20 | await element(by.cssContainingText('.nav-link', 'Audit Logs')).click(); | |
21 | ||
22 | // Enter an earliest time so that no old messages with the same pool name show up | |
23 | await $$('.bs-timepicker-field') | |
24 | .get(0) | |
25 | .sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a')); | |
26 | await $$('.bs-timepicker-field') | |
27 | .get(0) | |
28 | .sendKeys(protractor.Key.BACK_SPACE); | |
29 | if (hour < 10) { | |
30 | await $$('.bs-timepicker-field') | |
31 | .get(0) | |
32 | .sendKeys('0'); | |
33 | } | |
34 | await $$('.bs-timepicker-field') | |
35 | .get(0) | |
36 | .sendKeys(hour); | |
37 | ||
38 | await $$('.bs-timepicker-field') | |
39 | .get(1) | |
40 | .sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a')); | |
41 | await $$('.bs-timepicker-field') | |
42 | .get(1) | |
43 | .sendKeys(protractor.Key.BACK_SPACE); | |
44 | if (minute < 10) { | |
45 | await $$('.bs-timepicker-field') | |
46 | .get(1) | |
47 | .sendKeys('0'); | |
48 | } | |
49 | await $$('.bs-timepicker-field') | |
50 | .get(1) | |
51 | .sendKeys(minute); | |
52 | ||
53 | // Enter the pool name into the filter box | |
54 | await $$('input.form-control.ng-valid') | |
55 | .first() | |
56 | .click(); | |
57 | await $$('input.form-control.ng-valid') | |
58 | .first() | |
59 | .clear(); | |
60 | await $$('input.form-control.ng-valid') | |
61 | .first() | |
62 | .sendKeys(poolname); | |
63 | ||
64 | const audit_logs_tab = $('.tab-pane.active'); | |
65 | const audit_logs_body = audit_logs_tab.element(by.css('.card-body')); | |
66 | const logs = audit_logs_body.all(by.cssContainingText('.message', poolname)); | |
67 | ||
68 | await expect(logs.getText()).toMatch(poolname); | |
69 | await expect(logs.getText()).toMatch(`pool ${poolfunction}`); | |
70 | } | |
71 | ||
72 | async checkAuditForConfigChange( | |
73 | configname: string, | |
74 | setting: string, | |
75 | hour: number, | |
76 | minute: number | |
77 | ) { | |
78 | await this.navigateTo(); | |
79 | ||
80 | // go to audit logs tab | |
81 | await element(by.cssContainingText('.nav-link', 'Audit Logs')).click(); | |
82 | ||
83 | // Enter an earliest time so that no old messages with the same config name show up | |
84 | await $$('.bs-timepicker-field') | |
85 | .get(0) | |
86 | .sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a')); | |
87 | await $$('.bs-timepicker-field') | |
88 | .get(0) | |
89 | .sendKeys(protractor.Key.BACK_SPACE); | |
90 | if (hour < 10) { | |
91 | await $$('.bs-timepicker-field') | |
92 | .get(0) | |
93 | .sendKeys('0'); | |
94 | } | |
95 | await $$('.bs-timepicker-field') | |
96 | .get(0) | |
97 | .sendKeys(hour); | |
98 | ||
99 | await $$('.bs-timepicker-field') | |
100 | .get(1) | |
101 | .sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a')); | |
102 | await $$('.bs-timepicker-field') | |
103 | .get(1) | |
104 | .sendKeys(protractor.Key.BACK_SPACE); | |
105 | if (minute < 10) { | |
106 | await $$('.bs-timepicker-field') | |
107 | .get(1) | |
108 | .sendKeys('0'); | |
109 | } | |
110 | await $$('.bs-timepicker-field') | |
111 | .get(1) | |
112 | .sendKeys(minute); | |
113 | ||
114 | // Enter the config name into the filter box | |
115 | await $$('input.form-control.ng-valid') | |
116 | .first() | |
117 | .click(); | |
118 | await $$('input.form-control.ng-valid') | |
119 | .first() | |
120 | .clear(); | |
121 | await $$('input.form-control.ng-valid') | |
122 | .first() | |
123 | .sendKeys(configname); | |
124 | ||
125 | const audit_logs_tab = $('.tab-pane.active'); | |
126 | const audit_logs_body = audit_logs_tab.element(by.css('.card-body')); | |
127 | const logs = audit_logs_body.all(by.cssContainingText('.message', configname)); | |
128 | ||
129 | await this.waitPresence(logs.first()); | |
130 | ||
131 | await expect(logs.getText()).toMatch(configname); | |
132 | await expect(logs.getText()).toMatch(setting); | |
11fdf7f2 TL |
133 | } |
134 | } |