]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/block/images.po.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / block / images.po.ts
1 import { PageHelper } from '../page-helper.po';
2
3 export class ImagesPageHelper extends PageHelper {
4 pages = {
5 index: { url: '#/block/rbd', id: 'cd-rbd-list' },
6 create: { url: '#/block/rbd/create', id: 'cd-rbd-form' }
7 };
8
9 // Creates a block image and fills in the name, pool, and size fields.
10 // Then checks if the image is present in the Images table.
11 createImage(name: string, pool: string, size: string) {
12 this.navigateTo('create');
13
14 cy.get('#name').type(name); // Enter in image name
15
16 // Select image pool
17 cy.contains('Loading...').should('not.exist');
18 this.selectOption('pool', pool);
19 cy.get('#pool').should('have.class', 'ng-valid'); // check if selected
20
21 // Enter in the size of the image
22 cy.get('#size').type(size);
23
24 // Click the create button and wait for image to be made
25 cy.contains('button', 'Create RBD').click();
26 this.getFirstTableCell(name).should('exist');
27 }
28
29 editImage(name: string, pool: string, newName: string, newSize: string) {
30 this.navigateEdit(name);
31
32 // Wait until data is loaded
33 cy.get('#pool').should('contain.value', pool);
34
35 cy.get('#name').clear().type(newName);
36 cy.get('#size').clear().type(newSize); // click the size box and send new size
37
38 cy.contains('button', 'Edit RBD').click();
39
40 this.getExpandCollapseElement(newName).click();
41 cy.get('.table.table-striped.table-bordered').contains('td', newSize);
42 }
43
44 // Selects RBD image and moves it to the trash,
45 // checks that it is present in the trash table
46 moveToTrash(name: string) {
47 // wait for image to be created
48 cy.get('.datatable-body').first().should('not.contain.text', '(Creating...)');
49
50 this.getFirstTableCell(name).click();
51
52 // click on the drop down and selects the move to trash option
53 cy.get('.table-actions button.dropdown-toggle').first().click();
54 cy.get('li.move-to-trash').click();
55
56 cy.contains('button', 'Move Image').should('be.visible').click();
57
58 // Clicks trash tab
59 cy.contains('.nav-link', 'Trash').click();
60 this.getFirstTableCell(name).should('exist');
61 }
62
63 // Checks trash tab table for image and then restores it to the RBD Images table
64 // (could change name if new name is given)
65 restoreImage(name: string, newName?: string) {
66 // clicks on trash tab
67 cy.contains('.nav-link', 'Trash').click();
68
69 // wait for table to load
70 this.getFirstTableCell(name).click();
71 cy.contains('button', 'Restore').click();
72
73 // wait for pop-up to be visible (checks for title of pop-up)
74 cy.get('#name').should('be.visible');
75
76 // If a new name for the image is passed, it changes the name of the image
77 if (newName !== undefined) {
78 // click name box and send new name
79 cy.get('#name').clear().type(newName);
80 }
81
82 cy.contains('button', 'Restore Image').click();
83
84 // clicks images tab
85 cy.contains('.nav-link', 'Images').click();
86
87 this.getFirstTableCell(newName).should('exist');
88 }
89
90 // Enters trash tab and purges trash, thus emptying the trash table.
91 // Checks if Image is still in the table.
92 purgeTrash(name: string, pool?: string) {
93 // clicks trash tab
94 cy.contains('.nav-link', 'Trash').click();
95 cy.contains('button', 'Purge Trash').click();
96
97 // Check for visibility of modal container
98 cy.get('.modal-header').should('be.visible');
99
100 // If purgeing a specific pool, selects that pool if given
101 if (pool !== undefined) {
102 this.selectOption('poolName', pool);
103 cy.get('#poolName').should('have.class', 'ng-valid'); // check if pool is selected
104 }
105 cy.get('#purgeFormButton').click();
106 // Wait for image to delete and check it is not present
107
108 this.getFirstTableCell(name).should('not.exist');
109 }
110 }