Skip to content

Commit db1dd2e

Browse files
committed
Multiple changes
- flaky main fixes - expand fake-cluster intercepts and make use of them - improve accessing of cluster `Edit Config` action - other - move action menu stuff from sortable table to action menu po - refactor edit fake cluster test to use common code
1 parent ccb4f5a commit db1dd2e

6 files changed

Lines changed: 70 additions & 45 deletions

File tree

cypress/e2e/blueprints/nav/fake-cluster.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,7 @@ export function generateFakeClusterDataAndIntercepts({
25282528
cy.intercept({
25292529
method: 'GET',
25302530
pathname: '/v1/provisioning.cattle.io.clusters',
2531-
query: { pagesize: '*' }
2531+
query: { pagesize: '100000' }
25322532
}, (req) => {
25332533
req.continue((res) => {
25342534
const localIndex = res.body.data.findIndex((item: any) => item.id.includes('/local'));
@@ -2552,25 +2552,40 @@ export function generateFakeClusterDataAndIntercepts({
25522552
});
25532553
}).as('provCluster');
25542554

2555+
const update = (clusters: any[]) => {
2556+
const localIndex = clusters.findIndex((item: any) => item.id.includes('local'));
2557+
2558+
if (localIndex >= 0) {
2559+
const localCluster = clusters[localIndex];
2560+
2561+
localCluster.spec.description = longClusterDescription;
2562+
}
2563+
2564+
clusters.push(fakeNavClusterData.mgmtClusterObj);
2565+
};
2566+
25552567
// add extra cluster to the nav list to test https://github.com/rancher/dashboard/issues/10452
25562568
cy.intercept({
25572569
method: 'GET',
25582570
pathname: '/v1/management.cattle.io.clusters',
2559-
query: { pagesize: '*' }
2571+
query: { pagesize: '10' }
25602572
}, (req) => {
25612573
req.continue((res) => {
2562-
const localIndex = res.body.data.findIndex((item: any) => item.id.includes('local'));
2563-
2564-
if (localIndex >= 0) {
2565-
const localCluster = res.body.data[localIndex];
2566-
2567-
localCluster.spec.description = longClusterDescription;
2568-
}
2574+
update(res.body.data);
2575+
res.send(res.body);
2576+
});
2577+
}).as('mgmtClustersSideNav');
25692578

2570-
res.body.data.push(fakeNavClusterData.mgmtClusterObj);
2579+
cy.intercept({
2580+
method: 'GET',
2581+
pathname: '/v1/management.cattle.io.clusters',
2582+
query: { pagesize: '100' }
2583+
}, (req) => {
2584+
req.continue((res) => {
2585+
update(res.body.data);
25712586
res.send(res.body);
25722587
});
2573-
}).as('mgmtClusters');
2588+
}).as('mgmtClustersLists');
25742589

25752590
cy.intercept('GET', `/v1/management.cattle.io.clusters/${ fakeNavClusterData.mgmtClusterObj.id }?*`, (req) => {
25762591
req.reply({

cypress/e2e/po/components/action-menu-shell.po.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,24 @@ export default class ActionMenuPo extends ComponentPo {
99
return this.self().find('[dropdown-menu-item]').eq(index).click();
1010
}
1111

12+
checkNoActionsAvailable(present = true) {
13+
if (present) {
14+
return this.self().should('contain', 'No actions available');
15+
} else {
16+
return this.self().should('not.contain', 'No actions available');
17+
}
18+
}
19+
20+
atLeastOneActiveMenuItem() {
21+
return this.self().find('[dropdown-menu-item]:not([disabled])').should('exist');
22+
}
23+
1224
getMenuItem(name: string) {
13-
return this.self().get('[dropdown-menu-item]').contains(name);
25+
return this.self().contains('[dropdown-menu-item]', name);
26+
}
27+
28+
waitForMenuItem(name: string) {
29+
return this.getMenuItem(name).should('be.visible');
1430
}
1531

1632
menuItemNames() {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import ComponentPo from '@/cypress/e2e/po/components/component.po';
22

33
export default class LoadingPo extends ComponentPo {
4-
4+
constructor(selector = '.loading-indicator') {
5+
super(selector);
6+
}
57
}

cypress/e2e/po/components/sortable-table.po.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export default class SortableTablePo extends ComponentPo {
191191

192192
rowActionMenu() {
193193
// Get the visible dropdown menu - this ensures we only interact with a menu that's actually open
194-
return new ActionMenuPo(cy.get('[dropdown-menu-collection]:visible'));
194+
return new ActionMenuPo('[dropdown-menu-collection]:visible');
195195
}
196196

197197
noRowsShouldNotExist() {
@@ -244,9 +244,9 @@ export default class SortableTablePo extends ComponentPo {
244244

245245
// Wait for the dropdown to finish loading (not show "No actions available")
246246
if (!skipNoActionAvailableCheck) {
247-
actionMenu.self().should('not.contain', 'No actions available');
247+
actionMenu.checkNoActionsAvailable(false);
248248
// Ensure at least one non-disabled menu item is present
249-
actionMenu.self().find('[dropdown-menu-item]:not([disabled])').should('exist');
249+
actionMenu.atLeastOneActiveMenuItem();
250250
}
251251

252252
return actionMenu;

cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ export default class ClusterManagerListPagePo extends BaseListPagePo {
112112
}
113113

114114
editCluster(name: string) {
115-
this.sortableTable().rowActionMenuOpen(name).getMenuItem('Edit Config').click();
115+
const rowMenu = this.sortableTable().rowActionMenuOpen(name);
116+
117+
return rowMenu.waitForMenuItem('Edit Config').click();
116118
}
117119

118120
/**

cypress/e2e/tests/pages/manager/edit-fake-cluster.spec.ts

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
22
import ClusterManagerEditGenericPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/edit/cluster-edit-generic.po';
3-
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
43
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
54
import { RANCHER_PAGE_EXCEPTIONS, catchTargetPageException } from '@/cypress/support/utils/exception-utils';
65
import { CURRENT_RANCHER_VERSION } from '@shell/config/version.js';
7-
import PagePo from '@/cypress/e2e/po/pages/page.po';
8-
96
import { generateFakeClusterDataAndIntercepts } from '@/cypress/e2e/blueprints/nav/fake-cluster';
7+
import LoadingPo from '@/cypress/e2e/po/components/loading.po';
8+
109
const fakeProvClusterId = 'some-fake-cluster-id';
1110
const fakeMgmtClusterId = 'some-fake-mgmt-id';
1211

12+
const clusterList = new ClusterManagerListPagePo('_');
13+
const loadingPo = new LoadingPo();
14+
const editCluster = new ClusterManagerEditGenericPagePo('_', fakeProvClusterId);
15+
1316
describe('Cluster Edit', { tags: ['@manager', '@adminUser'] }, () => {
1417
describe('Cluster Edit (Fake DO cluster)', () => {
1518
beforeEach(() => {
@@ -18,31 +21,25 @@ describe('Cluster Edit', { tags: ['@manager', '@adminUser'] }, () => {
1821
});
1922

2023
cy.login();
21-
});
2224

23-
it('Clearing a registry auth item on the UI (Cluster Edit Config) should retain its authentication ID', () => {
2425
HomePagePo.goTo();
25-
const burgerMenu = new BurgerMenuPo();
26-
27-
BurgerMenuPo.toggle();
28-
const clusterManagementNavItem = burgerMenu.links().contains(`Cluster Management`);
2926

30-
clusterManagementNavItem.should('exist');
31-
clusterManagementNavItem.click();
32-
const clusterList = new ClusterManagerListPagePo('_');
27+
cy.wait('@mgmtClustersSideNav');
28+
cy.wait('@mgmtClustersLists');
29+
cy.wait('@provClusters');
3330

31+
clusterList.navToMenuEntry('Cluster Management');
3432
clusterList.waitForPage();
35-
cy.intercept({
36-
method: 'GET',
37-
pathname: '/v1/provisioning.cattle.io.clusters',
38-
query: { pagesize: '100000' }
39-
}).as('waitForDropDownInfo'); // Wait for request which will populate the drop down
4033

41-
cy.wait('@waitForDropDownInfo');
34+
cy.wait('@mgmtClustersLists');
35+
cy.wait('@provClusters');
36+
4237
clusterList.editCluster(fakeProvClusterId);
4338

44-
const editCluster = new ClusterManagerEditGenericPagePo('_', fakeProvClusterId);
39+
editCluster.waitForPage();
40+
});
4541

42+
it('Clearing a registry auth item on the UI (Cluster Edit Config) should retain its authentication ID', () => {
4643
editCluster.clickTab('#registry');
4744
editCluster.registryAuthenticationItems().closeArrayListItem(0);
4845

@@ -53,17 +50,10 @@ describe('Cluster Edit', { tags: ['@manager', '@adminUser'] }, () => {
5350

5451
// testing https://github.com/rancher/dashboard/issues/10192
5552
it('"documentation" link in editing a cluster should open in a new tab', () => {
56-
HomePagePo.goTo();
57-
5853
catchTargetPageException(RANCHER_PAGE_EXCEPTIONS);
5954

60-
const page = new PagePo('');
61-
const clusterList = new ClusterManagerListPagePo('_');
62-
63-
page.navToMenuEntry('Cluster Management');
64-
clusterList.waitForPage();
65-
66-
clusterList.list().actionMenu(fakeProvClusterId).getMenuItem('Edit Config').click();
55+
// Don't click until the loading indicator isn't there....
56+
loadingPo.checkNotExists();
6757

6858
// since in Cypress we cannot assert directly a link on a new tab
6959
// next best thing is to assert that the link has _blank

0 commit comments

Comments
 (0)