Skip to content

Commit d4e9083

Browse files
authored
fix: (CXSPA-9643) - Product search page automated a11y tests (#20149)
1 parent 524242e commit d4e9083

File tree

6 files changed

+61
-11
lines changed

6 files changed

+61
-11
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <spartacus-team@sap.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import { viewportContext } from '../../helpers/viewport-context';
8+
9+
describe('Product Search Page', { testIsolation: false }, () => {
10+
beforeEach(() => {
11+
cy.a11yContinuumSetup();
12+
});
13+
14+
it('Searchbar', () => {
15+
cy.visit('/search/camera');
16+
cy.get('cx-product-list-item');
17+
cy.get('cx-searchbox input').type('cam').get('.products a');
18+
cy.get('cx-searchbox').a11yRunContinuumTest();
19+
cy.get('body').click(0, 0);
20+
});
21+
22+
it('Page content with list view', () => {
23+
cy.get('cx-product-list').a11yRunContinuumTest();
24+
});
25+
26+
it('Grid view', () => {
27+
cy.get('button.cx-product-grid').first().click();
28+
cy.get('#product-results-list').a11yRunContinuumTest();
29+
});
30+
31+
it('Sorting dropdown', () => {
32+
cy.get('cx-sorting').first().click();
33+
cy.get('ng-dropdown-panel').a11yRunContinuumTest();
34+
});
35+
36+
it('Facets', () => {
37+
cy.visit('/search/camera?query=camera:relevance:availableInStores:Chiba');
38+
cy.get('cx-active-facets a');
39+
cy.get('cx-product-facet-navigation').a11yRunContinuumTest();
40+
});
41+
42+
viewportContext(['mobile'], () => {
43+
it('Facets Modal', () => {
44+
cy.get('cx-product-facet-navigation .dialog-trigger').click();
45+
cy.get('cx-facet-list .value');
46+
cy.get('.dialog.active').a11yRunContinuumTest();
47+
});
48+
});
49+
});

projects/storefrontlib/cms-components/content/tab/tab.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ng-container *ngIf="mode$ | async as mode">
22
<!-- Tab List is the list of buttons to open tabs -->
33
<div
4-
[attr.role]="mode === TAB_MODE.ACCORDIAN ? 'presentation' : 'tablist'"
4+
[attr.role]="mode === TAB_MODE.ACCORDIAN ? 'null' : 'tablist'"
55
[attr.aria-label]="config.label | cxTranslate"
66
[class]="mode.toLowerCase()"
77
>

projects/storefrontlib/cms-components/content/tab/tab.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ describe('TabComponent', () => {
352352

353353
it('should display menu buttons for tabs', () => {
354354
const accordianEl = document.querySelector('div[class="accordian"]');
355-
expect(accordianEl?.role).toEqual('presentation');
355+
expect(accordianEl?.role).toEqual('null');
356356
const buttonEls = document.querySelectorAll('button[role="button"]');
357357
expect(buttonEls.length).toEqual(4);
358358

projects/storefrontlib/cms-components/navigation/search-box/search-box.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
class="results"
135135
id="results"
136136
(click)="close($any($event), true)"
137-
role="listbox"
138137
[class.no-headers]="
139138
!isEnabledFeature(searchBoxFeatures.TRENDING_SEARCHES_FEATURE) &&
140139
!isEnabledFeature(searchBoxFeatures.SEARCH_BOX_V2)
@@ -173,7 +172,7 @@ <h3>
173172
!isEnabledFeature(searchBoxFeatures.SEARCH_BOX_V2)
174173
"
175174
>
176-
<li *ngFor="let suggestion of result.suggestions">
175+
<li *ngFor="let suggestion of result.suggestions" role="option">
177176
<a
178177
role="option"
179178
[innerHTML]="
@@ -252,7 +251,7 @@ <h3 *ngIf="result.products?.length">
252251
role="listbox"
253252
[class.hidden]="hasSearchBoxV2"
254253
>
255-
<li *ngFor="let product of result.products">
254+
<li *ngFor="let product of result.products" role="option">
256255
<a
257256
role="option"
258257
[routerLink]="

projects/storefrontlib/cms-components/product/product-list/product-facet-navigation/facet-list/facet-list.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import {
8+
AfterViewInit,
89
ChangeDetectionStrategy,
910
Component,
1011
ElementRef,
@@ -15,22 +16,21 @@ import {
1516
OnInit,
1617
Optional,
1718
Output,
19+
QueryList,
1820
Renderer2,
21+
TemplateRef,
1922
ViewChild,
20-
inject,
21-
AfterViewInit,
2223
ViewChildren,
23-
QueryList,
24-
TemplateRef,
24+
inject,
2525
} from '@angular/core';
2626
import { Facet, FeatureConfigService, useFeatureStyles } from '@spartacus/core';
27-
import { Tab, TabConfig, TAB_MODE } from '../../../../content/tab/tab.model';
2827
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
2928
import { filter, map, take } from 'rxjs/operators';
3029
import {
3130
FocusConfig,
3231
KeyboardFocusService,
3332
} from '../../../../../layout/a11y/keyboard-focus/index';
33+
import { TAB_MODE, Tab, TabConfig } from '../../../../content/tab/tab.model';
3434
import { ICON_TYPE } from '../../../../misc/icon/icon.model';
3535
import { FacetGroupCollapsedState, FacetList } from '../facet.model';
3636
import { FacetComponent } from '../facet/facet.component';
@@ -137,6 +137,7 @@ export class FacetListComponent implements OnInit, OnDestroy, AfterViewInit {
137137
header: facet.name,
138138
content: this.facetsRef?.get(i),
139139
disableBorderFocus: true,
140+
id: i,
140141
}));
141142

142143
this.tabs$.next(tabs);

projects/storefrontlib/cms-components/product/product-list/product-grid-item/product-grid-item.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
class="cx-product-image"
88
[container]="product.images?.PRIMARY"
99
format="product"
10-
[alt]="product.summary"
10+
[alt]="product.name || product.summary"
1111
></cx-media>
1212
</a>
1313
<a
1414
[routerLink]="{ cxRoute: 'product', params: product } | cxUrl"
1515
class="cx-product-name"
1616
[innerHTML]="product.nameHtml"
17+
[id]="product.code + '_header'"
1718
></a>
1819

1920
<ng-template [cxOutlet]="ProductListOutlets.ITEM_DETAILS">

0 commit comments

Comments
 (0)