From 625771837770a9fa1d5b6441474660ce256e18f2 Mon Sep 17 00:00:00 2001 From: Andrea Barbasso <´andrea.barbasso@4science.com´> Date: Thu, 31 Oct 2024 13:00:21 +0100 Subject: [PATCH] [CST-15593] improve tests reliability --- cypress/e2e/admin-add-new-modals.cy.ts | 12 ++++++------ cypress/e2e/admin-edit-modals.cy.ts | 6 +++--- cypress/e2e/admin-export-modals.cy.ts | 4 ++-- cypress/e2e/admin-sidebar.cy.ts | 2 +- .../admin-sidebar-section.component.html | 4 +++- .../admin-sidebar-section.component.ts | 3 ++- .../admin/admin-sidebar/admin-sidebar.component.html | 1 + .../admin/admin-sidebar/admin-sidebar.component.ts | 3 ++- .../expandable-admin-sidebar-section.component.html | 2 +- .../expandable-admin-sidebar-section.component.ts | 3 ++- .../collection-item-mapper.component.html | 2 +- .../collection-item-mapper.component.ts | 2 ++ .../item-collection-mapper.component.html | 2 +- .../item-collection-mapper.component.ts | 2 ++ .../admin/admin-sidebar/admin-sidebar.component.ts | 3 ++- 15 files changed, 31 insertions(+), 20 deletions(-) diff --git a/cypress/e2e/admin-add-new-modals.cy.ts b/cypress/e2e/admin-add-new-modals.cy.ts index 565ae154f1e..c783972b757 100644 --- a/cypress/e2e/admin-add-new-modals.cy.ts +++ b/cypress/e2e/admin-add-new-modals.cy.ts @@ -9,10 +9,10 @@ describe('Admin Add New Modals', () => { it('Add new Community modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu - cy.get('#admin-menu-section-new-title').click(); + cy.get('[data-test="admin-menu-section-new-title"]').click(); cy.get('a[data-test="menu.section.new_community"]').click(); @@ -22,10 +22,10 @@ describe('Admin Add New Modals', () => { it('Add new Collection modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu - cy.get('#admin-menu-section-new-title').click(); + cy.get('[data-test="admin-menu-section-new-title"]').click(); cy.get('a[data-test="menu.section.new_collection"]').click(); @@ -35,10 +35,10 @@ describe('Admin Add New Modals', () => { it('Add new Item modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu - cy.get('#admin-menu-section-new-title').click(); + cy.get('[data-test="admin-menu-section-new-title"]').click(); cy.get('a[data-test="menu.section.new_item"]').click(); diff --git a/cypress/e2e/admin-edit-modals.cy.ts b/cypress/e2e/admin-edit-modals.cy.ts index e96d6ce898c..f2f18de8773 100644 --- a/cypress/e2e/admin-edit-modals.cy.ts +++ b/cypress/e2e/admin-edit-modals.cy.ts @@ -9,7 +9,7 @@ describe('Admin Edit Modals', () => { it('Edit Community modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu cy.get('#admin-menu-section-edit-title').click(); @@ -22,7 +22,7 @@ describe('Admin Edit Modals', () => { it('Edit Collection modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu cy.get('#admin-menu-section-edit-title').click(); @@ -35,7 +35,7 @@ describe('Admin Edit Modals', () => { it('Edit Item modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu cy.get('#admin-menu-section-edit-title').click(); diff --git a/cypress/e2e/admin-export-modals.cy.ts b/cypress/e2e/admin-export-modals.cy.ts index 9f69764d197..0efe040fc84 100644 --- a/cypress/e2e/admin-export-modals.cy.ts +++ b/cypress/e2e/admin-export-modals.cy.ts @@ -9,7 +9,7 @@ describe('Admin Export Modals', () => { it('Export metadata modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu cy.get('#admin-menu-section-export-title').click(); @@ -22,7 +22,7 @@ describe('Admin Export Modals', () => { it('Export batch modal should pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on entry of menu cy.get('#admin-menu-section-export-title').click(); diff --git a/cypress/e2e/admin-sidebar.cy.ts b/cypress/e2e/admin-sidebar.cy.ts index be1c9d4ef27..318bf2b27e2 100644 --- a/cypress/e2e/admin-sidebar.cy.ts +++ b/cypress/e2e/admin-sidebar.cy.ts @@ -10,7 +10,7 @@ describe('Admin Sidebar', () => { it('should be pinnable and pass accessibility tests', () => { // Pin the sidebar open - cy.get('#sidebar-collapse-toggle').click(); + cy.get('[data-test="sidebar-collapse-toggle"]').click(); // Click on every expandable section to open all menus cy.get('ds-expandable-admin-sidebar-section').click({ multiple: true }); diff --git a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html index 24ba17fff47..30a7a3353b9 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html +++ b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html @@ -14,7 +14,9 @@
diff --git a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts index ff9897ce9e8..2910f948a24 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts +++ b/src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts @@ -17,6 +17,7 @@ import { MenuID } from '../../../shared/menu/menu-id.model'; import { LinkMenuItemModel } from '../../../shared/menu/menu-item/models/link.model'; import { MenuSection } from '../../../shared/menu/menu-section.model'; import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-section.component'; +import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe'; /** * Represents a non-expandable section in the admin sidebar @@ -26,7 +27,7 @@ import { MenuSectionComponent } from '../../../shared/menu/menu-section/menu-sec templateUrl: './admin-sidebar-section.component.html', styleUrls: ['./admin-sidebar-section.component.scss'], standalone: true, - imports: [NgClass, RouterLink, TranslateModule], + imports: [NgClass, RouterLink, TranslateModule, BrowserOnlyPipe], }) export class AdminSidebarSectionComponent extends MenuSectionComponent implements OnInit { diff --git a/src/app/admin/admin-sidebar/admin-sidebar.component.html b/src/app/admin/admin-sidebar/admin-sidebar.component.html index f3d5409a642..41376f777e1 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar.component.html +++ b/src/app/admin/admin-sidebar/admin-sidebar.component.html @@ -42,6 +42,7 @@