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