-
Notifications
You must be signed in to change notification settings - Fork 29
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
Chore: Added menu page e2e tests (Issue/167) #168
Conversation
Currently blocked by issue 3 of adaptlearning/adapt_framework#3472 |
Please sort out the data loading. |
Hi Oliver, I believe I have addressed this in a new PR into this branch: #173 Can you have a look an confirm if those are the changes you think are needed please |
Can this pr be closed if you have another? |
The other PR is into this one as I wasn't 100% clear on if the changes I was making were what you had intended |
…build (#173) * Wrap menu item tests in a per-language loop and reference the course build * Removing language looping from tests * Destructuring some variables * Making use of 'data' attribute that is already wrapped * Fixing paste fail * Removing duplication * Performing empty value check and testing for non-writing of element in such cases
@oliverfoster Here is the true PR now to get those tests into the plugin. Apologies again about the roundabout way with my PR into this branch, I just wanted to make sure the relevant changes needed were discussed in isolation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
const { _graphic, body, displayTitle, duration, linkText } = this.data.contentObjects[index]; | ||
|
||
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 (displayTitle) { | ||
cy.get('.menu-item__title').should('contain', displayTitle); | ||
} else { | ||
cy.get('.menu-item__title').should('not.exist'); | ||
} | ||
|
||
cy.get('menu-item__details-inner').should('contain', _graphic.alt); | ||
|
||
if (body) { | ||
cy.get('.menu-item__body').should('contain', body); | ||
} else { | ||
cy.get('.menu-item__body').should('not.exist'); | ||
} | ||
|
||
if (duration) { | ||
cy.get('.menu-item__duration').should('contain', duration); | ||
} else { | ||
cy.get('.menu-item__duration').should('not.exist'); | ||
} | ||
|
||
cy.get('button.boxmenu-item__button').should('contain', linkText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, rather than putting if else conditions to test for different scenarios we should do some negative and positive testing and each scenario should go into its own test definition. For example you might have a test for it('should display information in each tile when all details exist', () => {
as the positive test and another test for it('should not display information in each tile when menu item details do not exist', () => {
as the negative test. You could also provide some invalid data as a negative test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also provide some invalid data as a negative test.
If I've understood this correctly - we'd need to provide some invalid data to the course to rerender, which we currently can't do.
There is as yet no way of providing the rendered course with alternative test data. The tests are performed against the provided course data only. The results of this test will consequently vary depending on the course data provided. A single run of this test does not explicitly test all potential scenarios, as would normally be expected from test cases.
The reason for this is that providing a test course for all possible scenarios for each plugin could get quite unmanageable. At the moment this is a halfway house, we have meaningful tests that are course agnostic, at a later date we can run them with various course configurations when we have a need / a strategy for doing so. We will need to work out how to provide alternative JSON and how to rerender the course in that eventuality.
I think the title as it is: should display the correct information in each tile
is reasonably self descriptive - where correct information
is the six properties as configured.
🎉 This PR is included in version 6.5.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
addresses #167