1 import { PageHelper } from '../page-helper.po';
4 index: { url: '#/osd', id: 'cd-osd-list' },
5 create: { url: '#/osd/create', id: 'cd-osd-form' }
8 export class OSDsPageHelper extends PageHelper {
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();
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);
26 this.filterTable('Hostname', hostname);
30 this.getTableCount('total').should('be.gte', 1);
32 cy.get('@addButton').click();
36 cy.get('@primaryGroups').within(() => {
37 this.getTableCount('total').as('newOSDCount');
40 cy.get(`${pages.create.id} .card-footer .tc_submitButton`).click();
41 cy.get(`cd-osd-creation-preview-modal .modal-footer .tc_submitButton`).click();
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);
57 @PageHelper.restrictTo(pages.index.url)
58 ensureNoOsd(id: number) {
59 this.searchTable(`id:${id}`);
60 this.expectTableCount('found', 0);
61 this.clearTableSearchInput();
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)
71 if (osdIds.includes(rowOSD)) {
75 this.clickActionButton('delete');
77 cy.get('cd-modal label[for="preserve"]').click();
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');