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

Codi 🐢 default base test #1195

Merged
merged 6 commits into from
Mar 26, 2024
Merged

Conversation

RobAndrewHurst
Copy link
Contributor

🐢 Added Codi Test Module for Building Default Mapview πŸ§ͺ

Description πŸ“

This pull request introduces a comprehensive test module that ensures the correct functionality and behavior of a mapview in our application. The test module covers various aspects of the mapview, including dictionary merging, user authentication, language selection, scroll restoration, tab functionality, locale retrieval, mapview creation, layer management, gazetteer integration, and more.

Key Features and Improvements ✨

1. Dictionary Merging πŸ“˜

  • Tests the merging of dictionaries from different languages.
  • Verifies that the English dictionary is updated with new entries.
  • Asserts that the merged dictionaries have the expected properties and values.

2. User Authentication πŸ”’

  • Tests the refreshing of the user's cookie and retrieval of updated credentials.
  • Asserts that the user object is updated after refreshing the cookie.
  • Verifies that the user object has the expected properties.

3. Language Selection 🌐

  • Tests the setting of the language based on the specified priority.
  • Asserts that the language is set correctly based on the available overrides.

4. Scroll Restoration πŸ“œ

  • Tests the scroll restoration functionality if supported by the browser.
  • Asserts that scroll restoration is set to 'auto' when supported.

5. Tab Functionality πŸ—‚οΈ

  • Tests the setting of help text from the dictionary for each tab.
  • Verifies the handling of tab click events.
  • Asserts that the active class is added to the clicked tab and corresponding panel.
  • Asserts that the active class is removed from other tabs and panels.

6. Locale Retrieval 🌎

  • Tests the retrieval of accessible locales from the Workspace API.
  • Asserts that the retrieved locales is an array and not empty.
  • Tests the retrieval of the locale with the list of layers from the Workspace API.
  • Asserts that the retrieved locale is not an instance of Error and has the expected properties.

7. Mapview Creation πŸ—ΊοΈ

  • Tests the creation of the mapview with the provided options.
  • Asserts that the mapview is created successfully and has the expected properties.

8. Layer Management

  • Tests the addition of layers to the mapview.
  • Asserts that the layers are added successfully to the mapview.

9. Gazetteer Integration πŸ“

  • Tests the creation of a gazetteer if available in the locale.
  • Asserts that the gazetteer is created when available.
  • Asserts that the locations tab is hidden when the gazetteer is not available.

10. Listview Creation πŸ“‹

  • Tests the creation of the layers listview.
  • Asserts that the layers listview is created successfully.
  • Tests the creation of the locations listview.
  • Asserts that the locations listview is created successfully.

11. Highlight Interaction πŸ”¦

  • Tests the beginning of the highlight interaction.
  • Asserts that the highlight interaction is added to the mapview.

12. Tabview Functionality πŸ—‚οΈ

  • Tests the showing and hiding of the tabview.
  • Asserts that the tabview is shown when the showTab function is called.
  • Asserts that the tabview is hidden when the removeLastTab function is called.

fin πŸŽ‰

This test module serves as a comprehensive suite to validate the functionality and behavior of a view that simulates our default mapview. It ensures that all the critical components, such as dictionary merging, user authentication, language selection, tab functionality, locale retrieval, mapview creation, layer management, gazetteer integration, and listview creation, are working as expected.

By including this test module, we can have confidence in the stability and reliability of our application's default mapview. It will help catch any potential issues or regressions during development and provide a solid foundation for future enhancements and modifications.

Please can you review the test module and provide any feedback or suggestions for improvement. Once approved, we can merge this pull request and include the test module in our codebase.

@RobAndrewHurst
Copy link
Contributor Author

RobAndrewHurst commented Mar 25, 2024

To test this you can navigate to http://localhost:3000/{dir}?template=test_view.

You should see something like the following in your console.

image

Copy link
Contributor

@simon-leech simon-leech left a comment

Choose a reason for hiding this comment

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

Loving it - so easy to use and covers so many good tests! πŸ‘ŒπŸ‘

Only one thing - can we update the readme / config docs somewhere to highlight this option and how to use?

@RobAndrewHurst
Copy link
Contributor Author

Loving it - so easy to use and covers so many good tests! πŸ‘ŒπŸ‘

Only one thing - can we update the readme / config docs somewhere to highlight this option and how to use?

@simon-leech I have included a how to test on the mapview module docs.

Will need to think how we can better document the tests too.

Lets create a TODO for that πŸ‘

@RobAndrewHurst RobAndrewHurst added the Testing Changes relating to existing or new unit tests. label Mar 26, 2024
@simon-leech
Copy link
Contributor

Thanks Rob! Just that little bit of docs looks good to me for now. We can revisit more detailed in the future πŸ‘

Copy link

sonarcloud bot commented Mar 26, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@RobAndrewHurst
Copy link
Contributor Author

I have also made each test in the _default.test.mjs await so that we ensure nothing runs before it needs to.

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

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

image

Looking good

@RobAndrewHurst RobAndrewHurst merged commit 49a64b8 into GEOLYTIX:main Mar 26, 2024
5 checks passed
@RobAndrewHurst RobAndrewHurst deleted the codi branch March 26, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing Changes relating to existing or new unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants