Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Check landing page is a boxmenu type menu #179

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 48 additions & 21 deletions test/e2e/adapt-contrib-boxMenu.cy.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
describe('Menu Page', function () {
beforeEach(function () {
cy.getData();
cy.getData().then((data) => {
this.boxMenus = this.data.filter(item => item._component === 'boxMenu' || item._view === 'boxMenu');
if (this.boxMenus.length) return;
this.boxMenus = this.data.filter(item => ['course', 'menu'].includes(item._type));
});

cy.visit('/');
});

it(`should have the correct title and description`, function () {
const { body, displayTitle } = this.data.course;
it(`should be an instance of a box menu content object on each menu page`, function () {
this.boxMenus.forEach((menu, index) => {
cy.visit(`#/id/${menu._id}`);
cy.get('.boxmenu').should('exist');
});
});

it(`should have the correct title and description for each menu page`, function () {
this.boxMenus.forEach((menu, index) => {
cy.visit(`#/id/${menu._id}`);

const { body, displayTitle } = menu;

cy.get('.menu__title-inner').should('contain', displayTitle);
cy.get('.menu__body-inner').should('contain', body);
cy.get('.menu__title-inner').should('contain', displayTitle);
cy.get('.menu__body-inner').should('contain', body);
});
});

it(`should display the correct number of menu tiles`, function () {
cy.get('.menu-item').should('have.length', this.data.contentObjects.length);
it(`should display the correct number of menu tiles for each menu page`, function () {
this.boxMenus.forEach((menu, index) => {
cy.visit(`#/id/${menu._id}`);

const subPages = this.data.contentObjects.filter((page) => page._parentId === menu._id);
cy.get('.menu-item').should('have.length', subPages.length);
});
});

it('should display the correct information in each tile', function () {
cy.get('.menu-item').each(($item, index) => {
cy.get($item).within(function () {
const { _graphic, body, displayTitle, duration, linkText } = this.data.contentObjects[index];
it('should display the correct information in each tile for each menu page', function () {
this.boxMenus.forEach((menu, index) => {
cy.visit(`#/id/${menu._id}`);

const subPages = this.data.contentObjects.filter((page) => page._parentId === menu._id);

cy.get('.menu-item').each(($item, index) => {
cy.get($item).within(function () {
const { _graphic, body, displayTitle, duration, linkText } = subPages[index];

cy.testContainsOrNotExists('.menu-item__title', displayTitle);
cy.testContainsOrNotExists('.menu-item__body', body);
cy.testContainsOrNotExists('.menu-item__duration', duration);
cy.testContainsOrNotExists('.menu-item__title', displayTitle);
cy.testContainsOrNotExists('.menu-item__body', body);
cy.testContainsOrNotExists('.menu-item__duration', duration);

if (_graphic?.src) {
cy.get('img.menu-item__image').should('exist').should('have.attr', 'src', _graphic.src);
} else {
cy.get('img.menu-item__image').should('not.exist');
}
if (_graphic?.src) {
cy.get('img.menu-item__image').should('exist').should('have.attr', 'src', _graphic.src);
} else {
cy.get('img.menu-item__image').should('not.exist');
}

cy.get('.menu-item__details-inner').should('contain', _graphic.alt);
cy.get('button.boxmenu-item__button').should('contain', linkText);
cy.get('.menu-item__details-inner').should('contain', _graphic.alt);
cy.get('button.boxmenu-item__button').should('contain', linkText);
});
});
});
});
Expand Down