Skip to content

Commit eac98c1

Browse files
authored
Merge pull request ceph#58485 from ivoalmeida/carbon-datatable
mgr/dashboard: replace ngx-datatable by carbon datatable Reviewed-by: Ernesto Puerta <[email protected]> Reviewed-by: Nizamudeen A <[email protected]>
2 parents 2b06a57 + cd03946 commit eac98c1

File tree

136 files changed

+2462
-1565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2462
-1565
lines changed

src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.po.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export class ImagesPageHelper extends PageHelper {
4545
// checks that it is present in the trash table
4646
moveToTrash(name: string) {
4747
// wait for image to be created
48-
cy.get('.datatable-body').first().should('not.contain.text', '(Creating...)');
48+
cy.get('cds-table table tbody').first().should('not.contain.text', '(Creating...)');
4949

5050
this.getFirstTableCell(name).click();
5151

5252
// click on the drop down and selects the move to trash option
53-
cy.get('.table-actions button.dropdown-toggle').first().click();
54-
cy.get('button.move-to-trash').click();
53+
cy.get('[data-testid="table-action-btn"]').click({ multiple: true });
54+
cy.get('button.move-to-trash').click({ force: true });
5555

56-
cy.get('[data-cy=submitBtn]').should('be.visible').click();
56+
cy.get('[data-cy=submitBtn] button').should('be.visible').click({ force: true });
5757

5858
// Clicks trash tab
5959
cy.contains('.nav-link', 'Trash').click();
@@ -68,7 +68,8 @@ export class ImagesPageHelper extends PageHelper {
6868

6969
// wait for table to load
7070
this.getFirstTableCell(name).click();
71-
cy.contains('button', 'Restore').click();
71+
cy.get('[data-testid="table-action-btn"]').click({ multiple: true });
72+
cy.get('button.restore').click({ force: true });
7273

7374
// wait for pop-up to be visible (checks for title of pop-up)
7475
cy.get('cds-modal #name').should('be.visible');

src/pybind/mgr/dashboard/frontend/cypress/e2e/block/mirroring.e2e-spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ describe('Mirroring page', () => {
7171
cy.get('cd-pool-list').should('exist');
7272

7373
cy.visit('#/block/mirroring').wait(1000);
74-
cy.get('.table-actions button.dropdown-toggle').first().click();
7574
cy.get('[aria-label="Import Bootstrap Token"]').click();
7675
cy.get('cd-bootstrap-import-modal').within(() => {
7776
cy.get(`input[name=${name}]`).click({ force: true });
@@ -101,13 +100,14 @@ describe('Mirroring page', () => {
101100

102101
it('tests editing mode for pools', () => {
103102
mirroring.navigateTo();
104-
105-
mirroring.editMirror(poolName, 'Pool');
106-
mirroring.getFirstTableCell('pool').should('be.visible');
107-
mirroring.editMirror(poolName, 'Image');
108-
mirroring.getFirstTableCell('image').should('be.visible');
109-
mirroring.editMirror(poolName, 'Disabled');
110-
mirroring.getFirstTableCell('disabled').should('be.visible');
103+
cy.get('cd-mirroring-pools').within(() => {
104+
mirroring.editMirror(poolName, 'Pool');
105+
mirroring.getFirstTableCell('pool').should('be.visible');
106+
mirroring.editMirror(poolName, 'Image');
107+
mirroring.getFirstTableCell('image').should('be.visible');
108+
mirroring.editMirror(poolName, 'Disabled');
109+
mirroring.getFirstTableCell('disabled').should('be.visible');
110+
});
111111
});
112112

113113
afterEach(() => {

src/pybind/mgr/dashboard/frontend/cypress/e2e/block/mirroring.po.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export class MirroringPageHelper extends PageHelper {
1919
@PageHelper.restrictTo(pages.index.url)
2020
editMirror(name: string, option: string) {
2121
// Clicks the pool in the table
22-
this.getFirstTableCell(name).click();
23-
24-
// Clicks the Edit Mode button
25-
cy.contains('button', 'Edit Mode').click();
22+
this.clickRowActionButton(name, 'edit-mode');
2623

2724
// Clicks the drop down in the edit pop-up, then clicks the Update button
2825
cy.get('cds-modal').should('be.visible');
@@ -37,7 +34,7 @@ export class MirroringPageHelper extends PageHelper {
3734

3835
@PageHelper.restrictTo(pages.index.url)
3936
generateToken(poolName: string) {
40-
cy.get('[aria-label="Create Bootstrap Token"]').first().click();
37+
cy.get('[aria-label="Create Bootstrap Token"]').click();
4138
cy.get('cd-bootstrap-create-modal').within(() => {
4239
cy.get(`input[name=${poolName}]`).click({ force: true });
4340
cy.get('button[type=submit]').click();
@@ -51,7 +48,7 @@ export class MirroringPageHelper extends PageHelper {
5148
cy.get('cd-mirroring-pools').within(() => {
5249
this.getTableCell(this.poolsColumnIndex.name, poolName)
5350
.parent()
54-
.find(`datatable-body-cell:nth-child(${this.poolsColumnIndex.health}) .badge`)
51+
.find(`[cdstabledata]:nth-child(${this.poolsColumnIndex.health}) .badge`)
5552
.should(($ele) => {
5653
const newLabels = $ele.toArray().map((v) => v.innerText);
5754
expect(newLabels).to.include(status);

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ export class ConfigurationPageHelper extends PageHelper {
1010
* Does not work for configs with checkbox only, possible future PR
1111
*/
1212
configClear(name: string) {
13+
this.navigateTo();
1314
const valList = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']; // Editable values
1415

15-
this.navigateEdit(name);
16+
this.getFirstTableCell(name).click();
17+
cy.contains('button', 'Edit').click();
1618
// Waits for the data to load
1719
cy.contains('.card-header', `Edit ${name}`);
1820

@@ -22,8 +24,10 @@ export class ConfigurationPageHelper extends PageHelper {
2224
// Clicks save button and checks that values are not present for the selected config
2325
cy.get('[data-cy=submitBtn]').click();
2426

27+
cy.wait(3 * 1000);
28+
2529
// Enter config setting name into filter box
26-
this.searchTable(name);
30+
this.searchTable(name, 100);
2731

2832
// Expand row
2933
this.getExpandCollapseElement(name).click();
@@ -45,7 +49,8 @@ export class ConfigurationPageHelper extends PageHelper {
4549
* Ex: [global, '2'] is the global value with an input of 2
4650
*/
4751
edit(name: string, ...values: [string, string][]) {
48-
this.navigateEdit(name);
52+
this.getFirstTableCell(name).click();
53+
cy.contains('button', 'Edit').click();
4954

5055
// Waits for data to load
5156
cy.contains('.card-header', `Edit ${name}`);
@@ -58,9 +63,10 @@ export class ConfigurationPageHelper extends PageHelper {
5863
// Clicks save button then waits until the desired config is visible, clicks it,
5964
// then checks that each desired value appears with the desired number
6065
cy.get('[data-cy=submitBtn]').click();
66+
cy.wait(3 * 1000);
6167

6268
// Enter config setting name into filter box
63-
this.searchTable(name);
69+
this.searchTable(name, 100);
6470

6571
// Checks for visibility of config in table
6672
this.getExpandCollapseElement(name).should('be.visible').click();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export class CreateClusterServicePageHelper extends ServicesPageHelper {
4949
columnIndex = {
5050
service_name: 1,
5151
placement: 2,
52-
running: 0,
53-
size: 0,
54-
last_refresh: 0
52+
running: 3,
53+
size: 4,
54+
last_refresh: 5
5555
};
5656
}

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ export class HostsPageHelper extends PageHelper {
4646
}
4747
}
4848

49-
checkExist(hostname: string, exist: boolean) {
49+
checkExist(hostname: string, exist: boolean, shouldReload = false) {
50+
if (shouldReload) {
51+
cy.reload(true, { log: true, timeout: 5 * 1000 });
52+
}
5053
this.getTableCell(this.columnIndex.hostname, hostname, true)
5154
.parent()
52-
.find(`datatable-body-cell:nth-child(${this.columnIndex.hostname}) span`)
55+
.find(`[cdstabledata]:nth-child(${this.columnIndex.hostname}) span`)
5356
.should(($elements) => {
5457
const hosts = $elements.toArray().map((v) => v.innerText);
5558
if (exist) {
@@ -61,13 +64,12 @@ export class HostsPageHelper extends PageHelper {
6164
}
6265

6366
remove(hostname: string) {
64-
super.delete(hostname, this.columnIndex.hostname, 'hosts', true);
67+
super.delete(hostname, this.columnIndex.hostname, 'hosts', true, false, true);
6568
}
6669

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

7274
// add or remove label badges
7375
if (add) {
@@ -90,10 +92,10 @@ export class HostsPageHelper extends PageHelper {
9092
checkLabelExists(hostname: string, labels: string[], add: boolean) {
9193
// Verify labels are added or removed from Labels column
9294
// First find row with hostname, then find labels in the row
93-
this.getTableCell(this.columnIndex.hostname, hostname, true)
94-
.click()
95+
this.getTableCell(this.columnIndex.hostname, hostname, true).as('row').click();
96+
cy.get('@row')
9597
.parent()
96-
.find(`datatable-body-cell:nth-child(${this.columnIndex.labels}) .badge`)
98+
.find(`[cdstabledata]:nth-child(${this.columnIndex.labels}) .badge`)
9799
.should(($ele) => {
98100
const newLabels = $ele.toArray().map((v) => v.innerText);
99101
for (const label of labels) {
@@ -110,16 +112,15 @@ export class HostsPageHelper extends PageHelper {
110112
maintenance(hostname: string, exit = false, force = false) {
111113
this.clearTableSearchInput();
112114
if (force) {
113-
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
114-
this.clickActionButton('enter-maintenance');
115+
this.clickRowActionButton(hostname, 'enter-maintenance');
115116

116117
cy.get('cds-modal').within(() => {
117118
cy.contains('button', 'Continue').click();
118119
});
119120

120121
this.getTableCell(this.columnIndex.hostname, hostname, true)
121122
.parent()
122-
.find(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`)
123+
.find(`[cdstabledata]:nth-child(${this.columnIndex.status}) .badge`)
123124
.should(($ele) => {
124125
const status = $ele.toArray().map((v) => v.innerText);
125126
expect(status).to.include('maintenance');
@@ -129,28 +130,27 @@ export class HostsPageHelper extends PageHelper {
129130
this.getTableCell(this.columnIndex.hostname, hostname, true)
130131
.click()
131132
.parent()
132-
.find(`datatable-body-cell:nth-child(${this.columnIndex.status})`)
133+
.find(`[cdstabledata]:nth-child(${this.columnIndex.status})`)
133134
.then(($ele) => {
134135
const status = $ele.toArray().map((v) => v.innerText);
135136
if (status[0].includes('maintenance')) {
136-
this.clickActionButton('exit-maintenance');
137+
this.clickRowActionButton(hostname, 'exit-maintenance');
137138
}
138139
});
139140

140141
this.getTableCell(this.columnIndex.hostname, hostname, true)
141142
.parent()
142-
.find(`datatable-body-cell:nth-child(${this.columnIndex.status})`)
143+
.find(`[cdstabledata]:nth-child(${this.columnIndex.status})`)
143144
.should(($ele) => {
144145
const status = $ele.toArray().map((v) => v.innerText);
145146
expect(status).to.not.include('maintenance');
146147
});
147148
} else {
148-
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
149-
this.clickActionButton('enter-maintenance');
149+
this.clickRowActionButton(hostname, 'enter-maintenance');
150150

151151
this.getTableCell(this.columnIndex.hostname, hostname, true)
152152
.parent()
153-
.find(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`)
153+
.find(`[cdstabledata]:nth-child(${this.columnIndex.status}) .badge`)
154154
.should(($ele) => {
155155
const status = $ele.toArray().map((v) => v.innerText);
156156
expect(status).to.include('maintenance');
@@ -160,8 +160,7 @@ export class HostsPageHelper extends PageHelper {
160160

161161
@PageHelper.restrictTo(pages.index.url)
162162
drain(hostname: string) {
163-
this.getTableCell(this.columnIndex.hostname, hostname, true).click();
164-
this.clickActionButton('start-drain');
163+
this.clickRowActionButton(hostname, 'start-drain');
165164
cy.wait(1000);
166165
this.checkLabelExists(hostname, ['_no_schedule'], true);
167166

@@ -175,7 +174,7 @@ export class HostsPageHelper extends PageHelper {
175174
checkServiceInstancesExist(hostname: string, instances: string[]) {
176175
this.getTableCell(this.columnIndex.hostname, hostname, true)
177176
.parent()
178-
.find(`datatable-body-cell:nth-child(${this.columnIndex.services}) .badge`)
177+
.find(`[cdstabledata]:nth-child(${this.columnIndex.services}) .badge`)
179178
.should(($ele) => {
180179
const serviceInstances = $ele.toArray().map((v) => v.innerText);
181180
for (const instance of instances) {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ export class ManagerModulesPageHelper extends PageHelper {
2323
cy.contains('button', 'Update').click();
2424
// Checks if edits appear
2525
this.getExpandCollapseElement(name).should('be.visible').click();
26-
2726
for (const input of inputs) {
28-
cy.get('.datatable-body').last().contains(input.newValue);
27+
cy.get('[data-testid="datatable-row-detail"] [cdstablerow] [cdstabledata] span').contains(
28+
input.newValue
29+
);
2930
}
3031

3132
// Clear mgr module of all edits made to it
@@ -47,10 +48,10 @@ export class ManagerModulesPageHelper extends PageHelper {
4748
this.getExpandCollapseElement(name).should('be.visible').click();
4849
for (const input of inputs) {
4950
if (input.oldValue) {
50-
cy.get('.datatable-body')
51-
.eq(1)
52-
.should('contain', input.id)
53-
.and('not.contain', input.newValue);
51+
cy.contains('[data-testid="datatable-row-detail"] [cdstablerow] [cdstabledata]', input.id)
52+
.parent('[cdstablerow]')
53+
.find('[cdstabledata]')
54+
.should('not.contain', input.newValue);
5455
}
5556
}
5657
}

src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/monitors.e2e-spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ describe('Monitors page', () => {
4242
monitors.getLegends().its(2).should('have.text', 'Not In Quorum');
4343

4444
// verify correct columns on In Quorum table
45-
monitors.getDataTableHeaders(0).contains('Name');
45+
monitors.getDataTableHeaders().contains('Name');
4646

47-
monitors.getDataTableHeaders(0).contains('Rank');
47+
monitors.getDataTableHeaders().contains('Rank');
4848

49-
monitors.getDataTableHeaders(0).contains('Public Address');
50-
51-
monitors.getDataTableHeaders(0).contains('Open Sessions');
49+
monitors.getDataTableHeaders().contains('Public Address');
5250

51+
monitors.getDataTableHeaders().contains('Open Sessions');
5352
// verify correct columns on Not In Quorum table
54-
monitors.getDataTableHeaders(1).contains('Name');
53+
monitors.getDataTableHeaders().contains('Name');
5554

56-
monitors.getDataTableHeaders(1).contains('Rank');
55+
monitors.getDataTableHeaders().contains('Rank');
5756

58-
monitors.getDataTableHeaders(1).contains('Public Address');
57+
monitors.getDataTableHeaders().contains('Public Address');
5958
});
6059
});
6160
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class OSDsPageHelper extends PageHelper {
3535
if (expandCluster) {
3636
this.getTableCount('total').should('be.gte', 1);
3737
}
38-
cy.get('@addButton').click();
38+
cy.get('@addButton').click({ force: true });
3939
});
4040

4141
if (!expandCluster) {
@@ -51,8 +51,9 @@ export class OSDsPageHelper extends PageHelper {
5151
@PageHelper.restrictTo(pages.index.url)
5252
checkStatus(id: number, status: string[]) {
5353
this.searchTable(`id:${id}`);
54+
cy.wait(5 * 1000);
5455
this.expectTableCount('found', 1);
55-
cy.get(`datatable-body-cell:nth-child(${this.columnIndex.status}) .badge`).should(($ele) => {
56+
cy.get(`[cdstabledata]:nth-child(${this.columnIndex.status}) .badge`).should(($ele) => {
5657
const allStatus = $ele.toArray().map((v) => v.innerText);
5758
for (const s of status) {
5859
expect(allStatus).to.include(s);
@@ -71,8 +72,7 @@ export class OSDsPageHelper extends PageHelper {
7172
deleteByIDs(osdIds: number[], replace?: boolean) {
7273
this.getTableRows().each(($el) => {
7374
const rowOSD = Number(
74-
$el.find('datatable-body-cell .datatable-body-cell-label').get(this.columnIndex.id - 1)
75-
.textContent
75+
$el.find('[cdstabledata][cdstablerow]').get(this.columnIndex.id - 1).textContent
7676
);
7777
if (osdIds.includes(rowOSD)) {
7878
cy.wrap($el).click();

0 commit comments

Comments
 (0)