File: D:/HostingSpaces/SBogers10/shop.komma.nl/tests/Cypress/integration/site/assortment.spec.js
/// <reference types="Cypress" />
import PagesInfo from "../../support/pagesInfo";
const pagesInfo = new PagesInfo();
describe('Assortment', function() {
describe('Left navigation menu', function() {
it('Shows all top level categories.', function() {
cy.visit(pagesInfo.getByName('assortment').locations.nl);
cy.request('GET', '/testapi/v1/product_categories/top_level').then(function(response) {
const allCategories = response.body.data;
allCategories.forEach(topLevelCategory => {
cy.get('[data-test="categories-list"]').should('contain', topLevelCategory.display_name)
})
})
});
it('It is possible to follow top level category links. And should be active', function() {
cy.visit(pagesInfo.getByName('assortment').locations.nl);
cy.request('GET', '/testapi/v1/product_categories/top_level').then(function(response) {
const topLevelCategories = response.body.data;
topLevelCategories.forEach(topLevelCategory => {
cy.get('[data-test="categories-list"]').contains(topLevelCategory.display_name).click();
cy.get('[data-test="assortment-menu"] [data-test="current-assortment-menu-item"]').contains(topLevelCategory.display_name).should('exist')
cy.go('back')
})
})
});
it('Categories that have productables should show them with a max of 10', function() {
cy.visit(pagesInfo.getByName('assortment').locations.nl);
cy.request('GET', '/testapi/v1/product_categories/index').then(function(response) {
cy.get('[data-test="categories-list-item"]').first().click();
const categories = response.body.data;
categories.forEach(category => {
if(!category.display_name) return;
cy.get('[data-test="assortment-menu"]').contains(category.display_name).click();
cy.get('[data-test="assortment-grid"]').children().should('have.length.lte', 10);
})
})
});
});
});