]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/osds.po.ts
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / cluster / osds.po.ts
1 import { PageHelper } from '../page-helper.po';
2
3 const pages = {
4 index: { url: '#/osd', id: 'cd-osd-list' },
5 create: { url: '#/osd/create', id: 'cd-osd-form' }
6 };
7
8 export class OSDsPageHelper extends PageHelper {
9 pages = pages;
10
11 columnIndex = {
12 id: 3,
13 status: 5
14 };
15
16 create(deviceType: 'hdd' | 'ssd', hostname?: string, expandCluster = false) {
17 // Click Primary devices Add button
18 cy.get('cd-osd-devices-selection-groups[name="Primary"]').as('primaryGroups');
19 cy.get('@primaryGroups').find('button').click();
20
21 // Select all devices with `deviceType`
22 cy.get('cd-osd-devices-selection-modal').within(() => {
23 cy.get('.modal-footer .tc_submitButton').as('addButton').should('be.disabled');
24 this.filterTable('Type', deviceType);
25 if (hostname) {
26 this.filterTable('Hostname', hostname);
27 }
28
29 if (expandCluster) {
30 this.getTableCount('total').should('be.gte', 1);
31 }
32 cy.get('@addButton').click();
33 });
34
35 if (!expandCluster) {
36 cy.get('@primaryGroups').within(() => {
37 this.getTableCount('total').as('newOSDCount');
38 });
39
40 cy.get(`${pages.create.id} .card-footer .tc_submitButton`).click();
41 cy.get(`cd-osd-creation-preview-modal .modal-footer .tc_submitButton`).click();
42 }
43 }
44
45 @PageHelper.restrictTo(pages.index.url)
46 checkStatus(id: number, status: string[]) {
47 this.searchTable(`id:${id}`);
48 this.expectTableCount('found', 1);
49 cy.get(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`).should(($ele) => {
50 const allStatus = $ele.toArray().map((v) => v.innerText);
51 for (const s of status) {
52 expect(allStatus).to.include(s);
53 }
54 });
55 }
56
57 @PageHelper.restrictTo(pages.index.url)
58 ensureNoOsd(id: number) {
59 this.searchTable(`id:${id}`);
60 this.expectTableCount('found', 0);
61 this.clearTableSearchInput();
62 }
63
64 @PageHelper.restrictTo(pages.index.url)
65 deleteByIDs(osdIds: number[], replace?: boolean) {
66 this.getTableRows().each(($el) => {
67 const rowOSD = Number(
68 $el.find('datatable-body-cell .datatable-body-cell-label').get(this.columnIndex.id - 1)
69 .textContent
70 );
71 if (osdIds.includes(rowOSD)) {
72 cy.wrap($el).click();
73 }
74 });
75 this.clickActionButton('delete');
76 if (replace) {
77 cy.get('cd-modal label[for="preserve"]').click();
78 }
79 cy.get('cd-modal label[for="confirmation"]').click();
80 cy.contains('cd-modal button', 'Delete').click();
81 cy.get('cd-modal').should('not.exist');
82 }
83 }