Skip to content

Commit

Permalink
[CST-15593] improve tests reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Barbasso committed Oct 31, 2024
1 parent e516ae8 commit 6257718
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 20 deletions.
12 changes: 6 additions & 6 deletions cypress/e2e/admin-add-new-modals.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/admin-edit-modals.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/admin-export-modals.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/admin-sidebar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
</div>
<div class="sidebar-collapsible-element-outer-wrapper">
<div class="sidebar-collapsible-element-inner-wrapper sidebar-item">
<span [id]="adminMenuSectionTitleId(section.id)">{{itemModel.text | translate}}</span>
<span [id]="adminMenuSectionTitleId(section.id)" [attr.data-test]="adminMenuSectionTitleId(section.id) | dsBrowserOnly">
{{itemModel.text | translate}}
</span>
</div>
</div>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/app/admin/admin-sidebar/admin-sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h4 class="my-1">{{ 'menu.header.admin' | translate }}</h4>
<div class="sidebar-full-width-container" id="sidebar-collapse-toggle-container">
<a class="sidebar-section-wrapper sidebar-full-width-container"
id="sidebar-collapse-toggle"
[attr.data-test]="'sidebar-collapse-toggle' | dsBrowserOnly"
href="javascript:void(0);"
(click)="toggle($event)"
(keyup.space)="toggle($event)"
Expand Down
3 changes: 2 additions & 1 deletion src/app/admin/admin-sidebar/admin-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { MenuService } from '../../shared/menu/menu.service';
import { MenuID } from '../../shared/menu/menu-id.model';
import { CSSVariableService } from '../../shared/sass-helper/css-variable.service';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { BrowserOnlyPipe } from '../../shared/utils/browser-only.pipe';

/**
* Component representing the admin sidebar
Expand All @@ -46,7 +47,7 @@ import { ThemeService } from '../../shared/theme-support/theme.service';
styleUrls: ['./admin-sidebar.component.scss'],
animations: [slideSidebar],
standalone: true,
imports: [NgIf, NgbDropdownModule, NgClass, NgFor, NgComponentOutlet, AsyncPipe, TranslateModule],
imports: [NgIf, NgbDropdownModule, NgClass, NgFor, NgComponentOutlet, AsyncPipe, TranslateModule, BrowserOnlyPipe],
})
export class AdminSidebarComponent extends MenuComponent implements OnInit {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<div class="sidebar-collapsible-element-outer-wrapper">
<div class="sidebar-collapsible-element-inner-wrapper sidebar-item toggler-wrapper">
<span [id]="adminMenuSectionTitleId(section.id)">
<span [id]="adminMenuSectionTitleId(section.id)" [attr.data-test]="adminMenuSectionTitleId(section.id) | dsBrowserOnly">
<ng-container
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { slide } from '../../../shared/animations/slide';
import { MenuService } from '../../../shared/menu/menu.service';
import { MenuID } from '../../../shared/menu/menu-id.model';
import { CSSVariableService } from '../../../shared/sass-helper/css-variable.service';
import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe';
import { AdminSidebarSectionComponent } from '../admin-sidebar-section/admin-sidebar-section.component';

/**
Expand All @@ -36,7 +37,7 @@ import { AdminSidebarSectionComponent } from '../admin-sidebar-section/admin-sid
styleUrls: ['./expandable-admin-sidebar-section.component.scss'],
animations: [rotate, slide, bgColor],
standalone: true,
imports: [NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe, TranslateModule],
imports: [NgClass, NgComponentOutlet, NgIf, NgFor, AsyncPipe, TranslateModule, BrowserOnlyPipe],
})

export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>{{'collection.edit.item-mapper.head' | translate}}</h2>
</div>
</ng-template>
</li>
<li [ngbNavItem]="'mapTab'" role="presentation" data-test="mapTab">
<li [ngbNavItem]="'mapTab' | dsBrowserOnly" role="presentation" data-test="mapTab">
<a ngbNavLink>{{'collection.edit.item-mapper.tabs.map' | translate}}</a>
<ng-template ngbNavContent>
<div class="row mt-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
import { ItemSelectComponent } from '../../shared/object-select/item-select/item-select.component';
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
import { ThemedSearchFormComponent } from '../../shared/search-form/themed-search-form.component';
import { BrowserOnlyPipe } from '../../shared/utils/browser-only.pipe';
import { followLink } from '../../shared/utils/follow-link-config.model';

@Component({
Expand All @@ -86,6 +87,7 @@ import { followLink } from '../../shared/utils/follow-link-config.model';
AsyncPipe,
ItemSelectComponent,
NgIf,
BrowserOnlyPipe,
],
standalone: true,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>{{'item.edit.item-mapper.head' | translate}}</h2>
</div>
</ng-template>
</li>
<li [ngbNavItem]="'mapTab'" role="presentation" data-test="mapTab">
<li [ngbNavItem]="'mapTab' | dsBrowserOnly" role="presentation" data-test="mapTab">
<a ngbNavLink>{{'item.edit.item-mapper.tabs.map' | translate}}</a>
<ng-template ngbNavContent>
<div class="row mt-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { NotificationsService } from '../../../shared/notifications/notification
import { CollectionSelectComponent } from '../../../shared/object-select/collection-select/collection-select.component';
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
import { ThemedSearchFormComponent } from '../../../shared/search-form/themed-search-form.component';
import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe';
import { getItemPageRoute } from '../../item-page-routing-paths';

@Component({
Expand All @@ -79,6 +80,7 @@ import { getItemPageRoute } from '../../item-page-routing-paths';
AsyncPipe,
TranslateModule,
NgIf,
BrowserOnlyPipe,
],
standalone: true,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';

import { AdminSidebarComponent as BaseComponent } from '../../../../../app/admin/admin-sidebar/admin-sidebar.component';
import { BrowserOnlyPipe } from '../../../../../app/shared/utils/browser-only.pipe';

/**
* Component representing the admin sidebar
Expand All @@ -21,7 +22,7 @@ import { AdminSidebarComponent as BaseComponent } from '../../../../../app/admin
// styleUrls: ['./admin-sidebar.component.scss']
styleUrls: ['../../../../../app/admin/admin-sidebar/admin-sidebar.component.scss'],
standalone: true,
imports: [NgIf, NgbDropdownModule, NgClass, NgFor, NgComponentOutlet, AsyncPipe, TranslateModule],
imports: [NgIf, NgbDropdownModule, NgClass, NgFor, NgComponentOutlet, AsyncPipe, TranslateModule, BrowserOnlyPipe],
})
export class AdminSidebarComponent extends BaseComponent {
}

0 comments on commit 6257718

Please sign in to comment.