for (const entry of tuple) {
// Clears fields and adds edits
- await this.inputClear(element(by.id(entry[1])));
+ await this.clearInput(element(by.id(entry[1])));
await element(by.id(entry[1])).sendKeys(entry[0]);
}
// Clears the editable fields
for (const entry of tuple) {
- await this.inputClear(element(by.id(entry[1])));
+ await this.clearInput(element(by.id(entry[1])));
}
// Checks that clearing represents in details tab of module
for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
if (devHealthTuple[0] !== undefined) {
// Clears and inputs edits
- await this.inputClear(element(by.id(devHealthTuple[1])));
+ await this.clearInput(element(by.id(devHealthTuple[1])));
await element(by.id(devHealthTuple[1])).sendKeys(devHealthTuple[0]);
}
}
); // checks ansible
await this.getTableCell('devicehealth').click();
await element(by.cssContainingText('button', 'Edit')).click();
- await this.inputClear(element(by.id('mark_out_threshold')));
+ await this.clearInput(element(by.id('mark_out_threshold')));
await element(by.id('mark_out_threshold')).sendKeys('2419200');
- await this.inputClear(element(by.id('pool_name')));
+ await this.clearInput(element(by.id('pool_name')));
await element(by.id('pool_name')).sendKeys('device_health_metrics');
- await this.inputClear(element(by.id('retention_period')));
+ await this.clearInput(element(by.id('retention_period')));
await element(by.id('retention_period')).sendKeys('15552000');
- await this.inputClear(element(by.id('scrape_frequency')));
+ await this.clearInput(element(by.id('scrape_frequency')));
await element(by.id('scrape_frequency')).sendKeys('86400');
- await this.inputClear(element(by.id('sleep_interval')));
+ await this.clearInput(element(by.id('sleep_interval')));
await element(by.id('sleep_interval')).sendKeys('600');
- await this.inputClear(element(by.id('warn_threshold')));
+ await this.clearInput(element(by.id('warn_threshold')));
await element(by.id('warn_threshold')).sendKeys('7257600');
// Checks that clearing represents in details tab of ansible
).toMatch('Status');
// check for fields in table
- expect(await monitors.getStatusTable().getText()).toMatch('Cluster ID');
- expect(await monitors.getStatusTable().getText()).toMatch('monmap modified');
- expect(await monitors.getStatusTable().getText()).toMatch('monmap epoch');
- expect(await monitors.getStatusTable().getText()).toMatch('quorum con');
- expect(await monitors.getStatusTable().getText()).toMatch('quorum mon');
- expect(await monitors.getStatusTable().getText()).toMatch('required con');
- expect(await monitors.getStatusTable().getText()).toMatch('required mon');
+ expect(await monitors.getStatusTables().getText()).toMatch('Cluster ID');
+ expect(await monitors.getStatusTables().getText()).toMatch('monmap modified');
+ expect(await monitors.getStatusTables().getText()).toMatch('monmap epoch');
+ expect(await monitors.getStatusTables().getText()).toMatch('quorum con');
+ expect(await monitors.getStatusTables().getText()).toMatch('quorum mon');
+ expect(await monitors.getStatusTables().getText()).toMatch('required con');
+ expect(await monitors.getStatusTables().getText()).toMatch('required mon');
});
it('should check In Quorum and Not In Quorum tables are present', async () => {
pages: Pages;
/**
- * Decorator to be used on Helper methods to restrict access to one
- * particular URL. This shall help developers to prevent and highlight
- * mistakes. It also reduces boilerplate code and by thus, increases
- * readability.
+ * Decorator to be used on Helper methods to restrict access to one particular URL. This shall
+ * help developers to prevent and highlight mistakes. It also reduces boilerplate code and by
+ * thus, increases readability.
*/
static restrictTo(page): Function {
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
return $('.breadcrumb-item.active').getText();
}
- async getTabText(idx): Promise<string> {
+ async getTabText(index): Promise<string> {
return $$('.nav.nav-tabs li')
- .get(idx)
+ .get(index)
.getText();
}
);
}
- // getTitleText() {
- // let title;
- // return browser
- // .wait(() => {
- // title = $('.panel-title');
- // return title.isPresent();
- // })
- // .then(() => title.getText());
- // }
- //
getTableCell(content: string): ElementFinder {
return element(by.cssContainingText('.datatable-body-cell-label', content));
}
}
/**
- * Used for instances where a modal container would receive the click rather
- * than the desired element.
+ * Ceph Dashboards' <input type="checkbox"> tag is not visible. Instead of the real checkbox, a
+ * replacement is shown which is supposed to have an adapted style. The replacement checkbox shown
+ * is part of the label and is rendered in the "::before" pseudo element of the label, hence the
+ * label is always clicked when the user clicks the replacement checkbox.
*
- * Our <input type="checkbox"> tag is not visible. Instead of the real
- * checkbox, a replacement is shown which is supposed to have an adapted
- * style. The replacement checkbox shown is part of the label and is rendered
- * in the "::before" pseudo element of the label, hence the label is always
- * clicked when the user clicks the replacement checkbox.
- *
- * This method finds corresponding label to the given checkbox and clicks it
- * instead of the (fake) checkbox, like it is the case with real users.
+ * This method finds corresponding label to the given checkbox and clicks it instead of the (fake)
+ * checkbox, like it is the case with real users.
*
* Alternatively, the checkbox' label can be passed.
*
}
/**
- * Returns the cell with the content given in `content`. Will not return a
- * rejected Promise if the table cell hasn't been found. It behaves this way
- * to enable to wait for visiblity/invisiblity/presence of the returned
- * element.
+ * Returns the cell with the content given in `content`. Will not return a rejected Promise if the
+ * table cell hasn't been found. It behaves this way to enable to wait for
+ * visibility/invisibility/presence of the returned element.
*
- * It will return a rejected Promise if the result is ambigous, though. That
- * means if the search for content has been completed, but more than a single
- * row is shown in the data table.
+ * It will return a rejected Promise if the result is ambiguous, though. That means if the search
+ * for content has been completed, but more than a single row is shown in the data table.
*/
async getTableCellByContent(content: string): Promise<ElementFinder> {
const searchInput = $('#pool-list > div .search input');
const count = Number(await footer.getAttribute('ng-reflect-row-count'));
if (count !== 0 && count > 1) {
- return Promise.reject('getTableCellByContent: Result is ambigous');
+ return Promise.reject('getTableCellByContent: Result is ambiguous');
} else {
return Promise.resolve(
element(
}
}
- // used when .clear() does not work on a text box, sends a Ctrl + a, BACKSPACE
- async inputClear(elem) {
- await elem.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));
- await elem.sendKeys(protractor.Key.BACK_SPACE);
+ /**
+ * Used when .clear() does not work on a text box, sends a Ctrl + a, BACKSPACE
+ */
+ async clearInput(elem: ElementFinder) {
+ const types = ['text', 'number'];
+ if ((await elem.getTagName()) === 'input' && types.includes(await elem.getAttribute('type'))) {
+ await elem.sendKeys(
+ protractor.Key.chord(protractor.Key.CONTROL, 'a'),
+ protractor.Key.BACK_SPACE
+ );
+ } else {
+ return Promise.reject(`Element ${elem} does not match the expected criteria.`);
+ }
}
@PageHelper.waitForTableData()
return $$('cd-table');
}
+ /**
+ * Gets column headers of table
+ */
+ getDataTableHeaders(): ElementArrayFinder {
+ return $$('.datatable-header');
+ }
+
/**
* Grabs striped tables
*/
- getStatusTable(): ElementArrayFinder {
+ getStatusTables(): ElementArrayFinder {
return $$('.table.table-striped');
}
getLegends(): ElementArrayFinder {
return $$('legend');
}
-
- /**
- * Gets column headers of table
- */
- getDataTableHeaders(): ElementArrayFinder {
- return $$('.datatable-header');
- }
}