]>
Commit | Line | Data |
---|---|---|
e306af50 TL |
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 | |
f67539c2 | 25 | cy.get('[data-cy=submitBtn]').click(); |
e306af50 TL |
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 | ||
f67539c2 | 38 | cy.get('[data-cy=submitBtn]').click(); |
e306af50 TL |
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(); | |
f67539c2 | 54 | cy.get('button.move-to-trash').click(); |
e306af50 | 55 | |
f67539c2 | 56 | cy.get('[data-cy=submitBtn]').should('be.visible').click(); |
e306af50 TL |
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) | |
f67539c2 | 74 | cy.get('cd-modal #name').should('be.visible'); |
e306af50 TL |
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 | |
f67539c2 | 79 | cy.get('cd-modal #name').clear().type(newName); |
e306af50 TL |
80 | } |
81 | ||
f67539c2 | 82 | cy.get('[data-cy=submitBtn]').click(); |
e306af50 TL |
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 | } | |
f67539c2 | 105 | cy.get('[data-cy=submitBtn]').click(); |
e306af50 TL |
106 | // Wait for image to delete and check it is not present |
107 | ||
108 | this.getFirstTableCell(name).should('not.exist'); | |
109 | } | |
110 | } |