import { loginWithFixtures } from '../support/intercept'; describe('Compare', () => { beforeEach(() => { loginWithFixtures(); cy.visit('/files'); cy.wait('@getFiles'); cy.contains('li', 'COMPARE').click(); }); it('Compare dropdown sorting options', () => { const expectedOptions = [ 'By File Name (A to Z)', 'By File Name (Z to A)', 'By Dependency (A to Z)', 'By Dependency (Z to A)', 'By File Type (A to Z)', 'By File Type (Z to A)', 'By Last Update (A to Z)', 'By Last Update (Z to A)', ]; cy.get('.p-dropdown').click(); cy.get('.p-dropdown-items') .find('.p-dropdown-item') .then($options => { const actualOptions = $options .map((index, elem) => Cypress.$(elem).find('.p-dropdown-item-label').text()) .get(); expect(actualOptions).to.deep.equal(expectedOptions); }); }); it('Grid cards are rendered for compare file selection', () => { cy.get('#compareGridCards').find('li').should('have.length.greaterThan', 0); }); it('Compare button is disabled until two files are dragged', () => { cy.contains('button', 'Compare').should('be.disabled'); cy.get('#compareFile0').drag('#primaryDragCard'); cy.get('#compareFile1').drag('#secondaryDragCard'); cy.contains('button', 'Compare').should('be.enabled'); }); it('Enter Compare dashboard and see charts', () => { cy.get('#compareFile0').drag('#primaryDragCard'); cy.get('#compareFile1').drag('#secondaryDragCard'); cy.contains('button', 'Compare').click(); cy.wait('@getCompare'); cy.url().should('include', 'compare'); // Assert chart title spans are visible cy.contains('span', 'Average Cycle Time').should('exist'); cy.contains('span', 'Cycle Efficiency').should('exist'); cy.contains('span', 'Average Processing Time').should('exist'); cy.contains('span', 'Average Processing Time by Activity').should('exist'); cy.contains('span', 'Average Waiting Time').should('exist'); cy.contains('span', 'Average Waiting Time between Activity').should('exist'); }); it('Compare State button exists on dashboard', () => { cy.get('#compareFile0').drag('#primaryDragCard'); cy.get('#compareFile1').drag('#secondaryDragCard'); cy.contains('button', 'Compare').click(); cy.wait('@getCompare'); cy.get('#compareState').should('exist').and('be.visible'); }); it('Sidebar shows time usage and frequency sections', () => { cy.get('#compareFile0').drag('#primaryDragCard'); cy.get('#compareFile1').drag('#secondaryDragCard'); cy.contains('button', 'Compare').click(); cy.wait('@getCompare'); cy.get('aside').should('exist'); cy.get('aside li').should('have.length.greaterThan', 0); }); });