Skip to content

Commit 3279afa

Browse files
committed
mgr/dashboard: fix the hosts e2e failure
Fixes: https://tracker.ceph.com/issues/61354 Signed-off-by: Nizamudeen A <[email protected]>
1 parent c56e10a commit 3279afa

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/hosts.po.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ export class HostsPageHelper extends PageHelper {
4747
}
4848

4949
checkExist(hostname: string, exist: boolean) {
50-
this.getTableCell(this.columnIndex.hostname, hostname).should(($elements) => {
51-
const hosts = $elements.map((_, el) => el.textContent).get();
52-
if (exist) {
53-
expect(hosts).to.include(hostname);
54-
} else {
55-
expect(hosts).to.not.include(hostname);
56-
}
57-
});
50+
this.getTableCell(this.columnIndex.hostname, hostname, true)
51+
.parent()
52+
.find(`datatable-body-cell:nth-child(${this.columnIndex.hostname}) span`)
53+
.should(($elements) => {
54+
const hosts = $elements.toArray().map((v) => v.innerText);
55+
if (exist) {
56+
expect(hosts).to.include(hostname);
57+
} else {
58+
expect(hosts).to.not.include(hostname);
59+
}
60+
});
5861
}
5962

6063
remove(hostname: string) {
@@ -63,7 +66,7 @@ export class HostsPageHelper extends PageHelper {
6366

6467
// Add or remove labels on a host, then verify labels in the table
6568
editLabels(hostname: string, labels: string[], add: boolean) {
66-
this.getTableCell(this.columnIndex.hostname, hostname).click();
69+
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
6770
this.clickActionButton('edit');
6871

6972
// add or remove label badges
@@ -87,7 +90,7 @@ export class HostsPageHelper extends PageHelper {
8790
checkLabelExists(hostname: string, labels: string[], add: boolean) {
8891
// Verify labels are added or removed from Labels column
8992
// First find row with hostname, then find labels in the row
90-
this.getTableCell(this.columnIndex.hostname, hostname)
93+
this.getTableCell(this.columnIndex.hostname, hostname, true)
9194
.click()
9295
.parent()
9396
.find(`datatable-body-cell:nth-child(${this.columnIndex.labels}) .badge`)
@@ -107,14 +110,14 @@ export class HostsPageHelper extends PageHelper {
107110
maintenance(hostname: string, exit = false, force = false) {
108111
this.clearTableSearchInput();
109112
if (force) {
110-
this.getTableCell(this.columnIndex.hostname, hostname).click();
113+
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
111114
this.clickActionButton('enter-maintenance');
112115

113116
cy.get('cd-modal').within(() => {
114117
cy.contains('button', 'Continue').click();
115118
});
116119

117-
this.getTableCell(this.columnIndex.hostname, hostname)
120+
this.getTableCell(this.columnIndex.hostname, hostname, true)
118121
.parent()
119122
.find(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`)
120123
.should(($ele) => {
@@ -123,7 +126,7 @@ export class HostsPageHelper extends PageHelper {
123126
});
124127
}
125128
if (exit) {
126-
this.getTableCell(this.columnIndex.hostname, hostname)
129+
this.getTableCell(this.columnIndex.hostname, hostname, true)
127130
.click()
128131
.parent()
129132
.find(`datatable-body-cell:nth-child(${this.columnIndex.status})`)
@@ -134,18 +137,18 @@ export class HostsPageHelper extends PageHelper {
134137
}
135138
});
136139

137-
this.getTableCell(this.columnIndex.hostname, hostname)
140+
this.getTableCell(this.columnIndex.hostname, hostname, true)
138141
.parent()
139142
.find(`datatable-body-cell:nth-child(${this.columnIndex.status})`)
140143
.should(($ele) => {
141144
const status = $ele.toArray().map((v) => v.innerText);
142145
expect(status).to.not.include('maintenance');
143146
});
144147
} else {
145-
this.getTableCell(this.columnIndex.hostname, hostname).click();
148+
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
146149
this.clickActionButton('enter-maintenance');
147150

148-
this.getTableCell(this.columnIndex.hostname, hostname)
151+
this.getTableCell(this.columnIndex.hostname, hostname, true)
149152
.parent()
150153
.find(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`)
151154
.should(($ele) => {
@@ -157,7 +160,7 @@ export class HostsPageHelper extends PageHelper {
157160

158161
@PageHelper.restrictTo(pages.index.url)
159162
drain(hostname: string) {
160-
this.getTableCell(this.columnIndex.hostname, hostname).click();
163+
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
161164
this.clickActionButton('start-drain');
162165
this.checkLabelExists(hostname, ['_no_schedule'], true);
163166

@@ -169,7 +172,7 @@ export class HostsPageHelper extends PageHelper {
169172
}
170173

171174
checkServiceInstancesExist(hostname: string, instances: string[]) {
172-
this.getTableCell(this.columnIndex.hostname, hostname)
175+
this.getTableCell(this.columnIndex.hostname, hostname, true)
173176
.parent()
174177
.find(`datatable-body-cell:nth-child(${this.columnIndex.services}) .badge`)
175178
.should(($ele) => {

src/pybind/mgr/dashboard/frontend/cypress/e2e/page-helper.po.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export abstract class PageHelper {
286286
delete(name: string, columnIndex?: number, section?: string) {
287287
// Selects row
288288
const getRow = columnIndex
289-
? this.getTableCell.bind(this, columnIndex)
289+
? this.getTableCell.bind(this, columnIndex, name, true)
290290
: this.getFirstTableCell.bind(this);
291291
getRow(name).click();
292292
let action: string;

0 commit comments

Comments
 (0)