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

test(selenium): word learning events #1856

Merged
merged 1 commit into from
Aug 25, 2024
Merged

Conversation

jo-elimu
Copy link
Member

Add UI tests.

#411

Technical Details

Testing Instructions

Screenshots


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this Aug 25, 2024
@jo-elimu jo-elimu requested a review from a team as a code owner August 25, 2024 07:21
@jo-elimu jo-elimu linked an issue Aug 25, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Aug 25, 2024

Walkthrough

The code changes involve minor modifications in comments, updates to HTML structure, enhancements to data visualization capabilities, and restructuring of import statements across several Java files. Key updates include the addition of logic for aggregating word learning events data, improvements to the usability of various web pages, and a reorganization of utility classes into a dedicated sub-package.

Changes

Files Change Summary
src/main/java/.../StoryBookLearningEventListController.java Updated comment for clarity.
src/main/java/.../WordLearningEventListController.java Added logic to aggregate word learning events by month for a chart.
src/main/webapp/WEB-INF/jsp/.../main.jsp Added id attribute to an anchor element for better accessibility.
src/main/webapp/WEB-INF/jsp/.../storybook-learning-event/list.jsp Modified table headers to include <code> tags for semantic clarity.
src/main/webapp/WEB-INF/jsp/.../word-learning-event/list.jsp Updated charting library source and improved chart and table structure and data handling.
src/test/java/.../EmojisRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../ImagesRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../LetterSoundsRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../LettersRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../SoundsRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../StoryBooksRestControllerTest.java Changed import path for DomainHelper.
src/test/java/.../WordsRestControllerTest.java Changed import path for DomainHelper.
src/test/java/selenium/.../WelcomePage.java Changed package and import paths for better organization.
src/test/java/selenium/.../WelcomePageTest.java Changed package and import paths; updated comment on test command properties.
src/test/java/selenium/analytics/.../MainAnalyticsPage.java New class for interacting with the main analytics page using Selenium.
src/test/java/selenium/analytics/.../MainAnalyticsPageTest.java New test class for MainAnalyticsPage, structured with JUnit 5.
src/test/java/selenium/analytics/.../WordLearningEventsPage.java New class for interacting with the Word Learning Events page.
src/test/java/selenium/analytics/.../WordLearningEventsPageTest.java New test class for WordLearningEventsPage, structured with JUnit 5.
src/test/java/selenium/util/.../DomainHelper.java Changed package to selenium.util for better organization.
src/test/java/selenium/util/.../ErrorHelper.java Changed package to selenium.util.
src/test/java/selenium/util/.../ErrorPage.java Changed package to selenium.util.
src/test/java/selenium/util/.../JavaScriptHelper.java Changed package to selenium.util.
src/test/java/selenium/util/.../MarkupValidationHelper.java Changed package to selenium.util.
src/test/java/selenium/util/.../SignOnHelper.java Changed package to selenium.util.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant ChartService
    participant Database

    User->>WebApp: Requests Word Learning Events
    WebApp->>Database: Fetch Word Learning Events
    Database-->>WebApp: Return Events Data
    WebApp->>ChartService: Prepare Data for Chart
    ChartService-->>WebApp: Return Chart Data
    WebApp-->>User: Display Chart with Events Data
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1e5443e and 28ba380.

Files selected for processing (24)
  • src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/WordLearningEventListController.java (2 hunks)
  • src/main/webapp/WEB-INF/jsp/analytics/main.jsp (1 hunks)
  • src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp (1 hunks)
  • src/main/webapp/WEB-INF/jsp/analytics/word-learning-event/list.jsp (2 hunks)
  • src/test/java/ai/elimu/rest/v2/content/EmojisRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/ImagesRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/LetterSoundsRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/LettersRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/SoundsRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/StoryBooksRestControllerTest.java (1 hunks)
  • src/test/java/ai/elimu/rest/v2/content/WordsRestControllerTest.java (1 hunks)
  • src/test/java/selenium/WelcomePage.java (1 hunks)
  • src/test/java/selenium/WelcomePageTest.java (3 hunks)
  • src/test/java/selenium/analytics/MainAnalyticsPage.java (1 hunks)
  • src/test/java/selenium/analytics/MainAnalyticsPageTest.java (1 hunks)
  • src/test/java/selenium/analytics/WordLearningEventsPage.java (1 hunks)
  • src/test/java/selenium/analytics/WordLearningEventsPageTest.java (1 hunks)
  • src/test/java/selenium/util/DomainHelper.java (1 hunks)
  • src/test/java/selenium/util/ErrorHelper.java (1 hunks)
  • src/test/java/selenium/util/ErrorPage.java (1 hunks)
  • src/test/java/selenium/util/JavaScriptHelper.java (1 hunks)
  • src/test/java/selenium/util/MarkupValidationHelper.java (2 hunks)
  • src/test/java/selenium/util/SignOnHelper.java (1 hunks)
Files skipped from review due to trivial changes (17)
  • src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java
  • src/main/webapp/WEB-INF/jsp/analytics/main.jsp
  • src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp
  • src/test/java/ai/elimu/rest/v2/content/EmojisRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/ImagesRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/LetterSoundsRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/LettersRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/SoundsRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/StoryBooksRestControllerTest.java
  • src/test/java/ai/elimu/rest/v2/content/WordsRestControllerTest.java
  • src/test/java/selenium/WelcomePage.java
  • src/test/java/selenium/util/DomainHelper.java
  • src/test/java/selenium/util/ErrorHelper.java
  • src/test/java/selenium/util/ErrorPage.java
  • src/test/java/selenium/util/JavaScriptHelper.java
  • src/test/java/selenium/util/MarkupValidationHelper.java
  • src/test/java/selenium/util/SignOnHelper.java
Additional comments not posted (9)
src/test/java/selenium/analytics/WordLearningEventsPage.java (1)

8-18: Well-structured Selenium page object model.

The class WordLearningEventsPage follows good practices for Selenium testing, including the use of utility classes to handle errors. The constructor's direct interaction with the WebDriver is appropriate for setting up page-specific configurations.

Consider adding more detailed documentation to describe the interactions and the purpose of this page object within the test suite.

src/test/java/selenium/analytics/MainAnalyticsPage.java (1)

9-24: Well-implemented Selenium page interactions.

The MainAnalyticsPage class correctly encapsulates interactions with web elements, following Selenium best practices. The method pressWordLearningEventsLink is well-implemented for interacting with specific elements on the page.

Consider adding error handling or retry mechanisms in the pressWordLearningEventsLink method to handle scenarios where the element is not immediately clickable.

src/test/java/selenium/WelcomePageTest.java (1)

Line range hint 1-12: Good restructuring and test setup implementation.

The changes to the package declaration and import statements enhance clarity and maintainability. The setup method's handling of headless mode and other Chrome options is well-implemented and follows best practices for Selenium testing.

Ensure that the new package structure and the reorganized utility classes are consistently used across all test files to maintain uniformity in the codebase.

Also applies to: 27-27

src/test/java/selenium/analytics/MainAnalyticsPageTest.java (1)

14-52: Review of MainAnalyticsPageTest class setup and methods

  • Class Setup: The logger and WebDriver are initialized correctly. The class structure follows good practices for Selenium tests.
  • setUp Method: Properly configures the WebDriver with options, including a headless mode based on system properties. It also navigates to the correct URL.
  • tearDown Method: Appropriately quits the WebDriver, ensuring no resources are left hanging post-tests.
  • testMainAnalyticsPage Method: Currently, this method only logs an action and initializes a page object but does not perform any assertions or interactions. It's important to implement actual test steps here to validate the functionality of the MainAnalyticsPage.
src/test/java/selenium/analytics/WordLearningEventsPageTest.java (1)

15-56: Review of WordLearningEventsPageTest class setup and methods

  • Class Setup: Consistent setup with logger and WebDriver, following good testing practices.
  • setUp Method: Correctly sets up the WebDriver with options and navigates to the analytics URL.
  • tearDown Method: Properly handles the quitting of the WebDriver.
  • testWordLearningEventsPage Method: Initializes necessary page objects but lacks actual interactions and assertions. It's crucial to add steps that interact with the UI and verify the expected outcomes to ensure the word learning events page is functioning as intended.
src/main/webapp/WEB-INF/jsp/analytics/word-learning-event/list.jsp (4)

8-8: Approved script source update. Consider adding a local fallback.

Updating to a CDN-hosted version of Chart.js is beneficial for performance and access to new features. However, consider adding a local fallback script in case the CDN is unavailable.


9-9: Canvas ID update is consistent with JavaScript changes.

The ID update from myChart to chart is correctly reflected in the JavaScript code initializing the chart.


52-57: Table header updates enhance clarity and consistency.

The update to more descriptive, code-like identifiers for table headers is a good practice, improving clarity and potentially easing integration with front-end frameworks.


12-22: Dynamic data handling in JavaScript. Verify data sanitization.

The use of JSP tags to dynamically populate JavaScript arrays is effective. Ensure that data passed to JavaScript is properly sanitized to prevent XSS attacks.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.

Project coverage is 15.06%. Comparing base (1e5443e) to head (28ba380).
Report is 2 commits behind head on main.

Files Patch % Lines
...web/analytics/WordLearningEventListController.java 0.00% 21 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1856      +/-   ##
============================================
- Coverage     15.10%   15.06%   -0.05%     
  Complexity      456      456              
============================================
  Files           250      250              
  Lines          7700     7721      +21     
  Branches        804      807       +3     
============================================
  Hits           1163     1163              
- Misses         6487     6508      +21     
  Partials         50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
src/main/webapp/WEB-INF/jsp/analytics/word-learning-event/list.jsp (1)

30-31: CSV export functionality. Consider enhancing user feedback.

The CSV export functionality is implemented well. Consider providing more detailed feedback or a progress indicator to the user during the CSV generation process.

@jo-elimu jo-elimu merged commit 691d177 into main Aug 25, 2024
12 of 14 checks passed
@jo-elimu jo-elimu deleted the 411-word-learning-events branch August 25, 2024 07:27
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.

Implement analytics dashboard
2 participants