Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix product search e2e tests #19468

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ describe('Kayboard navigation', () => {

context('Facet component', () => {
beforeEach(() => {
// TODO: No longer needed to toggle a11yTabComponent feature when set to true
// by default.
cy.cxConfig({
features: {
a11yTabComponent: true,
},
});
cy.visit('/Brands/all/c/brands');
cy.get('cx-facet-list button.tab-btn').first().as('facetHeader');
cy.get('cx-facet a').first().as('firstFacetOption');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ context('Product search product type flow', () => {
viewportContext(['mobile', 'desktop'], () => {
before(() => {
cy.window().then((win) => win.sessionStorage.clear());

// TODO: No longer needed to toggle a11yTabComponent feature when set to true
// by default.
cy.cxConfig({
features: {
a11yTabComponent: true,
},
});

cy.visit('/');
});

Expand Down Expand Up @@ -63,7 +72,7 @@ context('Product search product type flow', () => {
assertNumberOfProducts(`@${QUERY_ALIAS.SONY}`, `"${category}"`);

// Filter by brand
clickFacet('Brand');
clickFacet('Brand', true);

cy.wait(`@${QUERY_ALIAS.BRAND_PAGE}`)
.its('response.statusCode')
Expand All @@ -80,7 +89,7 @@ context('Product search product type flow', () => {
assertNumberOfProducts(`@${QUERY_ALIAS.SONY}`, `"${category}"`);

// Filter by price
clickFacet('Price');
clickFacet('Price', true);

cy.wait(`@${QUERY_ALIAS.PRICE_DSC_FILTER}`)
.its('response.statusCode')
Expand All @@ -103,7 +112,7 @@ context('Product search product type flow', () => {
);

// Filter by category
clickFacet('Category');
clickFacet('Category', true);

cy.wait(`@${QUERY_ALIAS.CATEGORY_FILTER}`)
.its('response.statusCode')
Expand All @@ -125,7 +134,7 @@ context('Product search product type flow', () => {
`"${category}"`
);

clickFacet('Color');
clickFacet('Color', true);

cy.wait(`@${QUERY_ALIAS.COLOR_FILTER}`)
.its('response.statusCode')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ context('Product search store flow', () => {
viewportContext(['desktop', 'mobile'], () => {
before(() => {
cy.window().then((win) => win.sessionStorage.clear());

// TODO: No longer needed to toggle a11yTabComponent feature when set to true
// by default.
cy.cxConfig({
features: {
a11yTabComponent: true,
},
});

cy.visit('/');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ export function checkFirstItem(productName: string): void {
});
}

export function clickFacet(header: string) {
export function clickFacet(header: string, force = false) {
cy.onMobile(() => {
cy.get('cx-product-facet-navigation button').click();
});
cy.get('cx-facet-list cx-tab button.tab-btn')
.contains(header)
.then((el) => {
if (el.find('.fa-plus').is(':visible')) {
if (el.find('.tab-icon[outerText^="+"]').length || force) {
// TODO Remove force once you can scroll facets on mobile
cy.wrap(el).click({ force: true });
}
Expand Down
Loading