Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Implementing Tests #39

Merged
merged 16 commits into from
Jul 29, 2024
Merged

Conversation

syed-ods
Copy link
Contributor

@syed-ods syed-ods commented Jun 26, 2024

Please keep this PR open until all tests have been added and approved.

Unit tests:

  1. Check if the top level redirect page exists.
  2. The main English template was generated. 
  3. The main French template was generated.
  4. The sitemap template was generated.

Integration tests:

  1. Check if the core ontario-frontend NPM package exists.
  2. If the user opted for ES-Lint, the config package was installed.
  3. If the user opted for Prettier, the config package was installed.

E2E tests:

  1. Test if the user clicks the French and English buttons, the page is populated with appropriate language content/data.
  2. Test if the search input and button are working, and the search returns some results. (Integration + E2E)
  • Check if search exists
  • Make sure typing a search term and clicking the search button redirects you to the search URL.

Test Prototypes:
https://github.com/syed-ods/on-frontend-test-prototypes


Acceptance Criteria

Unit Tests "{new-project}/src/tests/_unit/app.spec.js"

  • The user can create a new project using ontario-create-app. They should then be able to run npm test or npm run test from their project.
  • The assertion test to check the main index page (dist folder) should fail with the appropriate user feedback. This test should pass after the user builds or serves the app.
  • The tests should capture the EN and FR page names via the CLI prompt. Running npm test should pass these two tests.
  • If the user changes these file names for EN or FR pages, the tests should fail prompting the user to edit that information in the appropriate test files.
  • The last unit test for checking sitemap should also pass as this file will be created with every new project.

Integration Tests "{new-project}/src/tests/integration/packages.spec.js"

  • Running npm test from a newly created project should run the integration tests.
  • The file src/tests/integration/packages.spec.js should capture the ESLint and Prettier user selection.
  • If the user selected prettier or eslint, uninstalling any of their associated or core packages should fail the tests for optional packages.
  • If the core package ontario-frontend is uninstalled, the test for required packages should fail.

E2E Tests "{new-project}/src/tests/e2e"

  • The new project should include a nightwatch.conf.js file.
  • It should also include a .env and a .gitignore file.
  • Running npm run test:e2e should install the required node packages if not installed previously.
  • It should run the tests on the saved link value E2E_URL in the .env file.
  • If the saved link is not up and running, the tests should provide appropriate failure feedback.
  • Running npm run test:e2e should run the localization e2e test with appropriate CLI feedback.
  • It should run the search e2e test with appropriate CLI feedback.
  • The command npm run test:e2e should also be able to run with the --url flag, where the users can pass a custom URL to test. Example usage = npm run test:e2e --url=https://www.ontario.ca/international-trade-events-calendar.

Next step

  • Should make the integration tests work with the updated add and remove package commands. If the user adds eslint or prettier after the project is created, the variables in src/tests/integration/packages.spec.js should update accordingly, or the user should be provide appropriate feedback to update those variables.

@syed-ods syed-ods marked this pull request as draft June 26, 2024 18:51
@syed-ods syed-ods requested review from kyle-binger-3 July 3, 2024 13:59
Copy link
Collaborator

@kyle-binger-3 kyle-binger-3 left a comment

Choose a reason for hiding this comment

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

Hey Syed!

This is fantastic work, great job capturing all the different kinds of tests (unit, E2E, Integration).

I've left some general feedback that may be helpful. Let me know if you have any questions / want to chat further.

Thanks!

@syed-ods syed-ods requested a review from matt-stjean July 11, 2024 12:56
Copy link
Member

@matt-stjean matt-stjean left a comment

Choose a reason for hiding this comment

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

Great work on implementing the tests and configurations! The structure is clear, and the use of helper functions enhances readability and maintainability. Here are some key points and suggestions:

  1. Environment Variables: Ensure all required environment variables are set and provide clear error messages if they are not.
  2. Helper Functions: Improve error handling and add detailed logs to assist with debugging.
  3. Test Cases: Add edge cases and more comprehensive checks to ensure robustness.
  4. Documentation: Update comments and instructions to guide future updates and changes.

Overall, your implementation is solid, with minor enhancements needed for error handling and edge cases. Keep up the good work!

@syed-ods syed-ods requested a review from matt-stjean July 24, 2024 13:48
@syed-ods
Copy link
Contributor Author

@matt-stjean I'm thinking of making Microsoft Edge as the default browsers for e2e tests. That's because I tried uninstalling Chrome and run the tests but Nightwatch was unable to run the tests. I also tried installing specific webdrivers for each browser. It seems like an MVP idea to keep one browser only and mention the details in our developer documentation.

@matt-stjean
Copy link
Member

matt-stjean commented Jul 25, 2024 via email

@matt-stjean matt-stjean marked this pull request as ready for review July 29, 2024 14:16
Copy link
Member

@matt-stjean matt-stjean left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your work Syed

@matt-stjean matt-stjean self-assigned this Jul 29, 2024
@matt-stjean matt-stjean merged commit 434bb12 into develop Jul 29, 2024
@matt-stjean matt-stjean deleted the ONFRONT-82-implement-test-prototypes branch July 29, 2024 14:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants