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

cy - refactored e2e tests (fixtures) #10242

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

artshllk
Copy link

@artshllk artshllk commented Oct 3, 2024

🦄 Problem

We needed to refactor the Cypress tests to improve readability and maintainability, particularly in how fixtures were loaded across the test suite. The previous approach involved loading each fixture manually within the beforeEach block, leading to code duplication and decreased clarity.

🤖 Solution

I refactored the Cypress test suite by introducing a more concise method to handle fixture loading. Instead of calling cy.task("db:fixture", ...) for each fixture separately, I grouped the fixtures into an array and used a loop to load them all at once. This reduces redundancy, improves readability, and makes future modifications easier (e.g., adding new fixtures).

The refactor only affects the way fixtures are loaded, without impacting the overall test functionality. This should help streamline future test maintenance and updates.

🌈 Notes

  • The fixtures array contains all the necessary fixtures and is processed in the beforeEach hook to ensure that they are loaded before each test.
  • No changes were made to the actual test logic, only the setup phase for better readability.

💯 How to test

  1. Run the Cypress tests as usual.
  2. Ensure that all tests relying on database fixtures run without issues and that the fixtures are loaded correctly for each test case.
  3. Review the fixture-loading behavior to verify that it's functioning as expected across all test environments.

Comment on lines 7 to 23
const authenticatedPages = [
"/mes-tutos/enregistres",
"/mes-tutos/recommandes",
"/mon-compte/informations-personnelles",
"/mon-compte/langue",
"/mon-compte/methodes-de-connexion",
"/plan-du-site",
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some pages are missing in this array

cy.injectAxe();

// then
viewports.forEach(({ width, height }) => {
cy.viewport(width, height);
cy.checkA11yAndShowViolations({ skipFailures, url });
cy.checkA11yAndShowViolations({ skipFailures: false, url });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipFailures was set to true for some urls, notably /assessments/fake-assessment

@artshllk
Copy link
Author

artshllk commented Oct 8, 2024

Sorry for the small mistakes earlier! I’ve addressed the feedback and made the necessary updates. Everything should look good now, but please let me know if there’s anything else I need to fix or adjust. I was just aiming to do a small refactor to clean things up a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants