]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/mgr-modules.po.ts
import ceph quincy 17.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / cluster / mgr-modules.po.ts
1 import { PageHelper } from '../page-helper.po';
2
3 export class Input {
4 id: string;
5 oldValue: string;
6 newValue: string;
7 }
8
9 export class ManagerModulesPageHelper extends PageHelper {
10 pages = { index: { url: '#/mgr-modules', id: 'cd-mgr-module-list' } };
11
12 /**
13 * Selects the Manager Module and then fills in the desired fields.
14 */
15 editMgrModule(name: string, inputs: Input[]) {
16 this.navigateEdit(name);
17
18 for (const input of inputs) {
19 // Clears fields and adds edits
20 cy.get(`#${input.id}`).clear().type(input.newValue);
21 }
22
23 cy.contains('button', 'Update').click();
24 // Checks if edits appear
25 this.getExpandCollapseElement(name).should('be.visible').click();
26
27 for (const input of inputs) {
28 cy.get('.datatable-body').last().contains(input.newValue);
29 }
30
31 // Clear mgr module of all edits made to it
32 this.navigateEdit(name);
33
34 // Clears the editable fields
35 for (const input of inputs) {
36 if (input.oldValue) {
37 const id = `#${input.id}`;
38 cy.get(id).clear();
39 if (input.oldValue) {
40 cy.get(id).type(input.oldValue);
41 }
42 }
43 }
44
45 // Checks that clearing represents in details tab of module
46 cy.contains('button', 'Update').click();
47 this.getExpandCollapseElement(name).should('be.visible').click();
48 for (const input of inputs) {
49 if (input.oldValue) {
50 cy.get('.datatable-body')
51 .eq(1)
52 .should('contain', input.id)
53 .and('not.contain', input.newValue);
54 }
55 }
56 }
57 }