This method should be use to navigate to the edit page.
Signed-off-by: Tiago Melo <tmelo@suse.com>
}
editImage(name: string, pool: string, newName: string, newSize: string) {
- const base_url = '#/block/rbd/edit/';
- const editURL = base_url
- .concat(encodeURIComponent(pool))
- .concat('%2F')
- .concat(encodeURIComponent(name));
- cy.visit(editURL);
+ this.navigateEdit(name);
// Wait until data is loaded
cy.get('#pool').should('contain.value', pool);
* Does not work for configs with checkbox only, possible future PR
*/
configClear(name: string) {
- this.navigateTo();
const valList = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']; // Editable values
- // Enter config setting name into filter box
- this.seachTable(name);
-
- // Selects config that we want to clear
- this.getFirstTableCell(name).click(); // waits for config to be clickable and click
- cy.contains('button', 'Edit').click(); // clicks button to edit
-
- // Wait for the data to load
+ this.navigateEdit(name);
+ // Waits for the data to load
cy.contains('.card-header', `Edit ${name}`);
for (const i of valList) {
* Ex: [global, '2'] is the global value with an input of 2
*/
edit(name: string, ...values: [string, string][]) {
+ this.navigateEdit(name);
- // Enter config setting name into filter box
- this.seachTable(name);
-
- // Selects config that we want to edit
- this.getFirstTableCell(name).click(); // waits for config to be clickable and click
- cy.contains('button', 'Edit').click(); // clicks button to edit
-
+ // Waits for data to load
cy.contains('.card-header', `Edit ${name}`);
values.forEach((valtuple) => {
* DOES NOT WORK FOR ALL MGR MODULES, for example, Device health
*/
editMgrModule(name: string, tuple: string[][]) {
- this.getFirstTableCell(name).click();
- cy.contains('button', 'Edit').click();
+ this.navigateEdit(name);
for (const entry of tuple) {
// Clears fields and adds edits
}
// Clear mgr module of all edits made to it
- this.getFirstTableCell(name).click();
- cy.contains('button', 'Edit').click();
+ this.navigateEdit(name);
// Clears the editable fields
for (const entry of tuple) {
[warn, 'warn_threshold']
];
- this.getFirstTableCell('devicehealth').click();
- cy.contains('button', 'Edit').click();
+ this.navigateEdit('devicehealth');
for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
if (devHealthTuple[0] !== undefined) {
// Clears and inputs edits
// to be made when the values are cleared. Therefore, I restored them to their original values
// (on my local run of ceph-dev, this is subject to change i would assume).
// I'd imagine there is a better way of doing this.
- this.getFirstTableCell('devicehealth').click();
- cy.contains('button', 'Edit').click();
+ this.navigateEdit('devicehealth');
+
cy.get('#mark_out_threshold').clear().type('2419200');
cy.get('#pool_name').clear().type('device_health_metrics');
});
}
+ /**
+ * Navigates to the edit page
+ */
+ navigateEdit(name: string, select = true) {
+ if (select) {
+ this.navigateTo();
+ this.getFirstTableCell(name).click();
+ }
+ cy.contains('button', 'Edit').click();
+ this.expectBreadcrumbText('Edit');
+ }
+
/**
* Checks the active breadcrumb value.
*/
edit_pool_pg(name: string, new_pg: number, wait = true) {
this.isPowerOf2(new_pg);
- this.getFirstTableCell(name).click(); // select pool from the table
- cy.contains('button', 'Edit').click(); // click edit button
- this.expectBreadcrumbText('Edit'); // verify we are now on edit page
+ this.navigateEdit(name);
+
cy.get('input[name=pgNum]').clear().type(`${new_pg}`);
cy.get('cd-submit-button').click();
const str = `${new_pg} active+clean`;
@PageHelper.restrictTo(pages.index.url)
edit(name: string, new_owner: string) {
- this.getFirstTableCell(name).click(); // wait for table to load and click
- cy.contains('button', 'Edit').click(); // click button to move to edit page
- this.expectBreadcrumbText('Edit');
+ this.navigateEdit(name);
+
cy.get('input[name=placement-target]').should('have.value', 'default-placement');
this.selectOwner(new_owner);
cy.get('@versioningValueCell').should('have.text', this.versioningStateEnabled);
// Disable versioning:
- cy.contains('button', 'Edit').click(); // click button to move to edit page
- this.expectBreadcrumbText('Edit');
+ this.navigateEdit(name, false);
+
cy.get('label[for=versioning]').click();
cy.get('input[id=versioning]').should('not.be.checked');
cy.contains('button', 'Edit Bucket').click();
}
testInvalidEdit(name: string) {
- this.navigateTo();
-
- this.getFirstTableCell(name).click(); // wait for table to load and click
- cy.contains('button', 'Edit').click(); // click button to move to edit page
-
- this.expectBreadcrumbText('Edit');
+ this.navigateEdit(name);
cy.get('input[id=versioning]').should('exist').and('not.be.checked');
@PageHelper.restrictTo(pages.index.url)
edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
- this.getFirstTableCell(name).click(); // wait for table to load and click
- cy.contains('button', 'Edit').click(); // click button to move to edit page
-
- this.expectBreadcrumbText('Edit');
+ this.navigateEdit(name);
// Change the full name field
cy.get('#display_name').click().clear().type(new_fullname);
this.navigateTo('create');
this.create(uname, 'xxx', 'xxx@xxx', '1');
- this.navigateTo();
-
- // wait for table to load and click on the bucket you want to edit in the table
- this.getFirstTableCell(uname).click();
- cy.contains('button', 'Edit').click(); // click button to move to edit page
-
- this.expectBreadcrumbText('Edit');
+ this.navigateEdit(name);
// put invalid email to make field invalid
cy.get('#email')
create(name: string, description: string) {
this.navigateTo('create');
+ // Waits for data to load
+ cy.contains('grafana');
// fill in fields
cy.get('#name').type(name);
// Click the create button and wait for role to be made
cy.contains('button', 'Create Role').click();
+ cy.get('.breadcrumb-item.active').should('not.have.text', name);
this.getFirstTableCell(name).should('exist');
}
edit(name: string, description: string) {
- this.getFirstTableCell(name).click(); // select role from table
- cy.contains('button', 'Edit').click(); // click button to move to edit page
+ this.navigateEdit(name);
+ // Waits for data to load
+ cy.contains('grafana');
// fill in fields with new values
cy.get('#description').clear().type(description);
// Click the edit button and check new values are present in table
cy.contains('button', 'Edit Role').click();
+ cy.get('.breadcrumb-item.active').should('not.have.text', name);
this.getFirstTableCell(name).should('exist');
this.getFirstTableCell(description).should('exist');
}
edit(username: string, password: string, name: string, email: string) {
- this.getFirstTableCell(username).click(); // select user from table
- cy.contains('button', 'Edit').click(); // click button to move to edit page
+ this.navigateEdit(username);
// fill in fields with new values
cy.get('#password').clear().type(password);
resolve(route: ActivatedRouteSnapshot) {
const path = route.params.name;
const text = _.startCase(path);
- return [{ text: text, path: path }];
+ return [{ text: `${text}/Edit`, path: path }];
}
}