HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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)
        });
    });
});