mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Fixed duplicate search-navbar-container id & renabled accessibility tests for header
This commit is contained in:
@@ -8,11 +8,6 @@ describe('Header', () => {
|
||||
cy.get('ds-header').should('be.visible');
|
||||
|
||||
// Analyze <ds-header> for accessibility
|
||||
testA11y({
|
||||
include: ['ds-header'],
|
||||
exclude: [
|
||||
['#search-navbar-container'] // search in navbar has duplicative ID. Will be fixed in #1174
|
||||
],
|
||||
});
|
||||
testA11y('ds-header');
|
||||
});
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<div id="search-navbar-container" [title]="'nav.search' | translate" (dsClickOutside)="collapse()">
|
||||
<div [title]="'nav.search' | translate" (dsClickOutside)="collapse()">
|
||||
<div class="d-inline-block position-relative">
|
||||
<form [formGroup]="searchForm" (ngSubmit)="onSubmit(searchForm.value)" autocomplete="on" class="d-flex">
|
||||
<input #searchInput [@toggleAnimation]="isExpanded" [attr.aria-label]="('nav.search' | translate)" name="query"
|
||||
|
@@ -8,7 +8,6 @@ import { SearchService } from '../core/shared/search/search.service';
|
||||
import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
|
||||
|
||||
import { SearchNavbarComponent } from './search-navbar.component';
|
||||
import { PaginationServiceStub } from '../shared/testing/pagination-service.stub';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { BrowserOnlyMockPipe } from '../shared/testing/browser-only-mock.pipe';
|
||||
|
||||
@@ -17,8 +16,6 @@ describe('SearchNavbarComponent', () => {
|
||||
let fixture: ComponentFixture<SearchNavbarComponent>;
|
||||
let mockSearchService: any;
|
||||
let router: Router;
|
||||
let routerStub;
|
||||
let paginationService;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
mockSearchService = {
|
||||
@@ -27,12 +24,6 @@ describe('SearchNavbarComponent', () => {
|
||||
}
|
||||
};
|
||||
|
||||
routerStub = {
|
||||
navigate: (commands) => commands
|
||||
};
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
@@ -72,7 +63,7 @@ describe('SearchNavbarComponent', () => {
|
||||
spyOn(component, 'expand').and.callThrough();
|
||||
spyOn(component, 'onSubmit').and.callThrough();
|
||||
spyOn(router, 'navigate');
|
||||
const searchIcon = fixture.debugElement.query(By.css('#search-navbar-container form .submit-icon'));
|
||||
const searchIcon = fixture.debugElement.query(By.css('form .submit-icon'));
|
||||
searchIcon.triggerEventHandler('click', {
|
||||
preventDefault: () => {/**/
|
||||
}
|
||||
@@ -88,7 +79,7 @@ describe('SearchNavbarComponent', () => {
|
||||
describe('empty query', () => {
|
||||
describe('press submit button', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
const searchIcon = fixture.debugElement.query(By.css('#search-navbar-container form .submit-icon'));
|
||||
const searchIcon = fixture.debugElement.query(By.css('form .submit-icon'));
|
||||
searchIcon.triggerEventHandler('click', {
|
||||
preventDefault: () => {/**/
|
||||
}
|
||||
@@ -97,7 +88,7 @@ describe('SearchNavbarComponent', () => {
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
it('to search page with empty query', () => {
|
||||
const extras: NavigationExtras = {queryParams: { query: '' }, queryParamsHandling: 'merge'};
|
||||
const extras: NavigationExtras = { queryParams: { query: '' }, queryParamsHandling: 'merge' };
|
||||
expect(component.onSubmit).toHaveBeenCalledWith({ query: '' });
|
||||
expect(router.navigate).toHaveBeenCalledWith(['search'], extras);
|
||||
});
|
||||
@@ -109,20 +100,20 @@ describe('SearchNavbarComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
searchInput = fixture.debugElement.query(By.css('#search-navbar-container form input'));
|
||||
searchInput = fixture.debugElement.query(By.css('form input'));
|
||||
searchInput.nativeElement.value = 'test';
|
||||
searchInput.nativeElement.dispatchEvent(new Event('input'));
|
||||
fixture.detectChanges();
|
||||
});
|
||||
describe('press submit button', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
const searchIcon = fixture.debugElement.query(By.css('#search-navbar-container form .submit-icon'));
|
||||
const searchIcon = fixture.debugElement.query(By.css('form .submit-icon'));
|
||||
searchIcon.triggerEventHandler('click', null);
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
it('to search page with query', async () => {
|
||||
const extras: NavigationExtras = { queryParams: { query: 'test' }, queryParamsHandling: 'merge'};
|
||||
const extras: NavigationExtras = { queryParams: { query: 'test' }, queryParamsHandling: 'merge' };
|
||||
expect(component.onSubmit).toHaveBeenCalledWith({ query: 'test' });
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['search'], extras);
|
||||
|
Reference in New Issue
Block a user