]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / e2e / cluster / configuration.po.ts
1 import { $, by, element, protractor } from 'protractor';
2 import { PageHelper } from '../page-helper.po';
3
4 export class ConfigurationPageHelper extends PageHelper {
5 pages = {
6 index: '/#/configuration'
7 };
8
9 async configClear(name: string) {
10 // Clears out all the values in a config to reset before and after testing
11 // Does not work for configs with checkbox only, possible future PR
12
13 await this.navigateTo();
14 const valList = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']; // Editable values
15
16 // Enter config setting name into filter box
17 await $('input.form-control.ng-valid').clear();
18 await $('input.form-control.ng-valid').sendKeys(name);
19
20 // Selects config that we want to clear
21 await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
22 await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
23
24 for (const i of valList) {
25 // Sends two backspaces to all values, clear() did not work in this instance, could be optimized more
26 await element(by.id(i)).sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
27 await element(by.id(i)).sendKeys(protractor.Key.BACK_SPACE);
28 }
29 // Clicks save button and checks that values are not present for the selected config
30 await element(by.cssContainingText('button', 'Save')).click();
31
32 // Enter config setting name into filter box
33 await $('input.form-control.ng-valid').clear();
34 await $('input.form-control.ng-valid').sendKeys(name);
35
36 await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
37 // Clicks desired config
38 await this.waitVisibility(
39 $('.table.table-striped.table-bordered'), // Checks for visibility of details tab
40 'config details did not appear'
41 );
42 for (const i of valList) {
43 // Waits until values are not present in the details table
44 await this.waitTextNotPresent($('.table.table-striped.table-bordered'), i + ':');
45 }
46 }
47
48 async edit(name: string, ...values: [string, string][]) {
49 // Clicks the designated config, then inputs the values passed into the edit function.
50 // Then checks if the edit is reflected in the config table. Takes in name of config and
51 // a list of tuples of values the user wants edited, each tuple having the desired value along
52 // with the number tehey want for that value. Ex: [global, '2'] is the global value with an input of 2
53 await this.navigateTo();
54
55 // Enter config setting name into filter box
56 await $('input.form-control.ng-valid').clear();
57 await $('input.form-control.ng-valid').sendKeys(name);
58
59 // Selects config that we want to edit
60 await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
61 await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
62
63 await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
64
65 for (let i = 0, valtuple; (valtuple = values[i]); i++) {
66 // Finds desired value based off given list
67 await element(by.id(valtuple[0])).sendKeys(valtuple[1]); // of values and inserts the given number for the value
68 }
69
70 // Clicks save button then waits until the desired config is visible, clicks it, then checks
71 // that each desired value appears with the desired number
72 await element(by.cssContainingText('button', 'Save')).click();
73 await this.navigateTo();
74
75 // Enter config setting name into filter box
76 await $('input.form-control.ng-valid').clear();
77 await $('input.form-control.ng-valid').sendKeys(name);
78
79 await this.waitVisibility(this.getFirstTableCellWithText(name));
80 // Checks for visibility of config in table
81 await this.getFirstTableCellWithText(name).click();
82 // Clicks config
83 for (let i = 0, valtuple; (valtuple = values[i]); i++) {
84 // iterates through list of values and
85 await this.waitTextToBePresent(
86 // checks if the value appears in details with the correct number attatched
87 $('.table.table-striped.table-bordered'),
88 valtuple[0] + ': ' + valtuple[1]
89 );
90 }
91 }
92 }