File: D:/HostingSpaces/SBogers10/shop.komma.nl/tests/Cypress/integration/site/home.spec.js
/// <reference types="Cypress" />
import faker from 'faker'
import PagesInfo from "../../support/pagesInfo";
const pagesInfo = new PagesInfo();
describe('Home', function() {
describe('Categories', function() {
it('Shows top level categories (max 5).', function() {
cy.visit(pagesInfo.getByName('home').locations.nl);
cy.request('GET', '/testapi/v1/product_categories/top_level').then(function(response) {
const topLevelCategories = response.body.data.slice(0, 5); //Retrieves items 0, 1, 2, 3, 4
topLevelCategories.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('home').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('Shows the assortment page when following the view all link', function() {
cy.visit(pagesInfo.getByName('home').locations.nl);
cy.get('[data-test="show-all"]').click();
cy.url().should('contain', pagesInfo.getByName('assortment').locations.nl)
});
});
});