Skip to content

Commit 3d7c2d0

Browse files
Chore: e2e tests on page level progress extension (Issue/207) (#214)
* Added basic e2e test * Cleanup * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Update test/e2e/pageLevelProgress.cy.js Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com> * Lint fixes --------- Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com>
1 parent cd2068c commit 3d7c2d0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/e2e/pageLevelProgress.cy.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
describe('Page Level Progress', function () {
2+
beforeEach(function () {
3+
cy.getData();
4+
cy.visit('/');
5+
});
6+
7+
it('should display the page level progress bars correctly on the menu items', function () {
8+
const isPageLevelProgressEnabled = this.data.course._pageLevelProgress?._isEnabled;
9+
// Check if PLP is enabled. Check it's visible on menu tiles
10+
if (isPageLevelProgressEnabled) {
11+
const pagesCount = this.data.contentObjects.filter(page => page._pageLevelProgress._isEnabled).length;
12+
cy.get('.pagelevelprogress__indicator').should('have.length', pagesCount);
13+
} else {
14+
cy.get('.pagelevelprogress__indicator').should('not.exist');
15+
};
16+
});
17+
18+
it('should display the page level progress bars correctly on the pages', function () {
19+
const pageLevelProgress = this.data.course._pageLevelProgress;
20+
if (!pageLevelProgress?._isEnabled) return;
21+
const pages = this.data.contentObjects;
22+
pages.forEach(page => {
23+
cy.visit(`/#/${page._id}`);
24+
// Only check it appears correctly if it shows in the nav bar and its enabled on the page
25+
if (!page._pageLevelProgress?._isEnabled || pageLevelProgress._isShownInNavigationBar) {
26+
cy.get('.pagelevelprogress__indicator').should('not.exist');
27+
return;
28+
};
29+
30+
const articlesOnPage = this.data.articles.filter(article => article._parentId === page._id).map(article => article._id);
31+
const blocksOnPage = this.data.blocks.filter(block => articlesOnPage.includes(block._parentId)).map(blocks => blocks._id);
32+
const componentsOnPage = this.data.components.filter(component => blocksOnPage.includes(component._parentId));
33+
const plpComponents = componentsOnPage.filter(component => component._pageLevelProgress?._isEnabled);
34+
cy.get('.pagelevelprogress__indicator').should('exist');
35+
cy.get('button.nav__pagelevelprogress-btn').click();
36+
// TODO: If its a random assessment more checks are necessary
37+
if (page._classes !== 'assessment') {
38+
cy.get('.pagelevelprogress__item').should('have.length', plpComponents.length);
39+
};
40+
});
41+
});
42+
});

0 commit comments

Comments
 (0)