Skip to content

Commit

Permalink
Chore: e2e tests on page level progress extension (Issue/207) (#214)
Browse files Browse the repository at this point in the history
* Added basic e2e test

* Cleanup

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Update test/e2e/pageLevelProgress.cy.js

Co-authored-by: Cahir O'Doherty <[email protected]>

* Lint fixes

---------

Co-authored-by: Cahir O'Doherty <[email protected]>
  • Loading branch information
lemmyadams and cahirodoherty-learningpool authored Apr 22, 2024
1 parent cd2068c commit 3d7c2d0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/e2e/pageLevelProgress.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe('Page Level Progress', function () {
beforeEach(function () {
cy.getData();
cy.visit('/');
});

it('should display the page level progress bars correctly on the menu items', function () {
const isPageLevelProgressEnabled = this.data.course._pageLevelProgress?._isEnabled;
// Check if PLP is enabled. Check it's visible on menu tiles
if (isPageLevelProgressEnabled) {
const pagesCount = this.data.contentObjects.filter(page => page._pageLevelProgress._isEnabled).length;
cy.get('.pagelevelprogress__indicator').should('have.length', pagesCount);
} else {
cy.get('.pagelevelprogress__indicator').should('not.exist');
};
});

it('should display the page level progress bars correctly on the pages', function () {
const pageLevelProgress = this.data.course._pageLevelProgress;
if (!pageLevelProgress?._isEnabled) return;
const pages = this.data.contentObjects;
pages.forEach(page => {
cy.visit(`/#/${page._id}`);
// Only check it appears correctly if it shows in the nav bar and its enabled on the page
if (!page._pageLevelProgress?._isEnabled || pageLevelProgress._isShownInNavigationBar) {
cy.get('.pagelevelprogress__indicator').should('not.exist');
return;
};

const articlesOnPage = this.data.articles.filter(article => article._parentId === page._id).map(article => article._id);
const blocksOnPage = this.data.blocks.filter(block => articlesOnPage.includes(block._parentId)).map(blocks => blocks._id);
const componentsOnPage = this.data.components.filter(component => blocksOnPage.includes(component._parentId));
const plpComponents = componentsOnPage.filter(component => component._pageLevelProgress?._isEnabled);
cy.get('.pagelevelprogress__indicator').should('exist');
cy.get('button.nav__pagelevelprogress-btn').click();
// TODO: If its a random assessment more checks are necessary
if (page._classes !== 'assessment') {
cy.get('.pagelevelprogress__item').should('have.length', plpComponents.length);
};
});
});
});

0 comments on commit 3d7c2d0

Please sign in to comment.