From c5dff2b32f1c3af6f7aaa23ba49dc86b4b2b1145 Mon Sep 17 00:00:00 2001 From: Phillip Rak Date: Thu, 23 Jan 2025 12:44:00 -0700 Subject: [PATCH] Update e2e tests Signed-off-by: Phillip Rak --- cypress/e2e/po/side-bars/page-actions.po.ts | 4 +- cypress/e2e/po/side-bars/user-menu.po.ts | 26 +--- .../src/components/RcDropdown/RcDropdown.vue | 1 + shell/components/nav/Header.vue | 122 +++++++++--------- shell/components/nav/HeaderPageActionMenu.vue | 10 +- 5 files changed, 75 insertions(+), 88 deletions(-) diff --git a/cypress/e2e/po/side-bars/page-actions.po.ts b/cypress/e2e/po/side-bars/page-actions.po.ts index a724d958724..00d571f89e7 100644 --- a/cypress/e2e/po/side-bars/page-actions.po.ts +++ b/cypress/e2e/po/side-bars/page-actions.po.ts @@ -32,7 +32,7 @@ export default class PageActionsPo extends ComponentPo { * @returns {Cypress.Chainable} */ private static pageActionsMenu(): Cypress.Chainable { - return cy.get('body').getId('page-actions-dropdown'); + return cy.get('body').find('[dropdown-menu-collection]'); } /** @@ -41,7 +41,7 @@ export default class PageActionsPo extends ComponentPo { */ links(): Cypress.Chainable { return PageActionsPo.open().then(() => { - PageActionsPo.pageActionsMenu().find('.user-menu-item'); + PageActionsPo.pageActionsMenu().find('[dropdown-menu-item]'); }); } diff --git a/cypress/e2e/po/side-bars/user-menu.po.ts b/cypress/e2e/po/side-bars/user-menu.po.ts index 5f0df55b77d..30f4deb28e1 100644 --- a/cypress/e2e/po/side-bars/user-menu.po.ts +++ b/cypress/e2e/po/side-bars/user-menu.po.ts @@ -17,27 +17,14 @@ export default class UserMenuPo extends ComponentPo { * */ private userMenuContainer() { - return this.self().get('.user-menu'); - } - - /** - * Our section within the transient userMenuContainer - */ - userMenu(): Cypress.Chainable { - return this.self().getId(`user-menu-dropdown`); + return cy.get('body').find('[dropdown-menu-collection]'); } /** * Open the user menu - * - * Multiple clicks because sometimes just one ... isn't enough - * */ open(): Cypress.Chainable { - this.self().click(); - this.self().click(); - this.self().click(); - this.self().click(); + return cy.getId('nav_header_showUserMenu').should('be.visible').click(); } /** @@ -46,18 +33,13 @@ export default class UserMenuPo extends ComponentPo { isOpen() { // These should fail if `visibility: hidden` - https://docs.cypress.io/guides/core-concepts/interacting-with-elements#Visibility this.userMenuContainer().should('be.visible'); - this.userMenu().should('be.visible'); } ensureOpen() { // Check the user avatar icon is there this.checkVisible(); - // Yep, these are _horrible_, but flakey user avatar tests have plagued us for months and no-one has yet fixed them - // This is a temporary step until that brave, tenacious champion of e2e resolves the underlying issue. - cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting this.open(); - cy.wait(1000); // eslint-disable-line cypress/no-unnecessary-waiting // Check the v-popper drop down is open, if not open it // This isn't a pattern we want to use often, but this area has caused us lots of issues @@ -84,7 +66,7 @@ export default class UserMenuPo extends ComponentPo { * Check if menu is closed */ isClosed() { - this.userMenu().should('not.exist'); + this.userMenuContainer().should('not.exist'); } /** @@ -92,7 +74,7 @@ export default class UserMenuPo extends ComponentPo { * @returns */ getMenuItems(): Cypress.Chainable { - return this.userMenu().find('li').should('be.visible').and('have.length', 4); + return this.userMenuContainer().find('[dropdown-menu-item]').should('be.visible').and('have.length', 3); } /** diff --git a/pkg/rancher-components/src/components/RcDropdown/RcDropdown.vue b/pkg/rancher-components/src/components/RcDropdown/RcDropdown.vue index 7ca0bc49638..3aceb4b0740 100644 --- a/pkg/rancher-components/src/components/RcDropdown/RcDropdown.vue +++ b/pkg/rancher-components/src/components/RcDropdown/RcDropdown.vue @@ -115,6 +115,7 @@ const applyShow = () => { ref="dropdownTarget" role="menu" aria-orientation="vertical" + dropdown-menu-collection :aria-label="ariaLabel || 'Dropdown Menu'" > diff --git a/shell/components/nav/Header.vue b/shell/components/nav/Header.vue index 2bd73dc1863..97ec17b6ef8 100644 --- a/shell/components/nav/Header.vue +++ b/shell/components/nav/Header.vue @@ -651,65 +651,66 @@ export default { - - - - - + + + - - - + + @@ -843,7 +844,6 @@ export default { .rd-header-right { display: flex; - align-items: center; flex-direction: row; padding: 0; @@ -912,7 +912,7 @@ export default { width: 40px; } - :deep() > div > .btn.role-tertiary { + :deep() div .btn.role-tertiary { border: 1px solid var(--header-btn-bg); border: none; background: var(--header-btn-bg); @@ -1105,4 +1105,8 @@ export default { } } } + + .center-self { + align-self: center; + } diff --git a/shell/components/nav/HeaderPageActionMenu.vue b/shell/components/nav/HeaderPageActionMenu.vue index e8e19095062..3ae5fc63f82 100644 --- a/shell/components/nav/HeaderPageActionMenu.vue +++ b/shell/components/nav/HeaderPageActionMenu.vue @@ -24,11 +24,11 @@ const pageAction = (action: string) => {