|
| 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