From 16602b90994a08c3c39c317e52f80cdb55fe5079 Mon Sep 17 00:00:00 2001 From: joe-allen-89 <85872286+joe-allen-89@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:38:26 +0100 Subject: [PATCH] Fix: e2e tests to check _canCycleThroughPagination (fixes #312) (#313) * Fix: e2e tests to check _canCycleThroughPagination * Update test/e2e/hotGraphic.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/hotGraphic.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> --------- Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> --- test/e2e/hotGraphic.cy.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/test/e2e/hotGraphic.cy.js b/test/e2e/hotGraphic.cy.js index 30fcb6b..a54b97d 100644 --- a/test/e2e/hotGraphic.cy.js +++ b/test/e2e/hotGraphic.cy.js @@ -1,9 +1,10 @@ describe('Hot Graphic', function () { function loopThroughHotGraphic(hotGraphicComponent) { const items = hotGraphicComponent._items; + const canCycle = hotGraphicComponent._canCycleThroughPagination; cy.get('.hotgraphic__pin-item').should('have.length', items.length); // Check each pin works correctly - items.forEach((item, index) => { + items.forEach((item, index) => { cy.get(`.hotgraphic__pin-item .item-${index}.is-visited`).should('not.exist'); cy.get('.notify__popup.hotgraphic').should('not.exist'); cy.get(`.hotgraphic__pin-item .item-${index}`).click(); @@ -16,18 +17,33 @@ describe('Hot Graphic', function () { // Check pin popup navigation works as expected cy.get('.hotgraphic__pin-item .item-0').click(); - items.forEach(item => { + items.forEach(item => { cy.testContainsOrNotExists('.hotgraphic-popup__item-title-inner', item.title); cy.testContainsOrNotExists('.hotgraphic-popup__item-body-inner', item.body); cy.get('.hotgraphic-popup__controls.next').click(); - }) - cy.get('.hotgraphic-popup__controls.next.is-disabled').should('exist'); - items.forEach(item => { + }); + + if (!canCycle) { + cy.get('.hotgraphic-popup__controls.next.is-disabled').should('exist'); + } else { + cy.get('.hotgraphic-popup__controls.next') + .should('exist') + .and('not.have.class', 'is-disabled') + } + + items.forEach(item => { cy.testContainsOrNotExists('.hotgraphic-popup__item-title-inner', item.title); cy.testContainsOrNotExists('.hotgraphic-popup__item-body-inner', item.body); cy.get('.hotgraphic-popup__controls.back').click(); - }) - cy.get('.hotgraphic-popup__controls.back.is-disabled').should('exist'); + }); + + if (!canCycle) { + cy.get('.hotgraphic-popup__controls.back.is-disabled').should('exist'); + } else { + cy.get('.hotgraphic-popup__controls.back') + .should('exist') + .and('not.have.class', 'is-disabled') + } }; beforeEach(function () {