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

chore(cypess): extend questions workflow with extended coverage of question creation and editing #4418

Merged
merged 2 commits into from
Dec 28, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Dec 28, 2024

Summary by CodeRabbit

  • Tests
    • Enhanced test suite for question types with comprehensive constants.
    • Added detailed test cases for creating, editing, and verifying different question types.
    • Improved test stability by increasing wait times.
    • Implemented robust cleanup process for the test environment.
  • Chores
    • Modified GitHub Actions workflow to trigger Cypress tests on changes in the cypress/** directory.

Copy link

aviator-app bot commented Dec 28, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link

coderabbitai bot commented Dec 28, 2024

📝 Walkthrough

Walkthrough

The pull request enhances the Cypress end-to-end test suite for question workflows by introducing a comprehensive set of constants for various question types and their attributes, including titles, content, choices, and editing states. The existing test cases have been refactored to utilize these constants, improving readability and maintainability. Adjustments include increased wait times for actions and the addition of new tests to verify the functionality of creating, editing, and storing questions. Furthermore, the GitHub Actions workflow has been modified to trigger tests when changes occur in the cypress/** directory.

Changes

File Change Summary
cypress/cypress/e2e/D-questions-workflow.cy.ts - Added multiple constants for different question types (content, flashcard, single choice, multiple choice, KPRIM, numerical range, free text)
- Introduced original and edited versions of constants
- Enhanced test cases with predefined constants
- Increased wait times from 500ms to 1000ms
- Added new tests for question editing and verification
.github/workflows/cypress-testing.yml - Added a path filter for the pull_request event to trigger tests on changes in the cypress/** directory

Possibly related PRs


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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: 0

🧹 Nitpick comments (9)
cypress/cypress/e2e/D-questions-workflow.cy.ts (9)

4-7: Group constants in a single structure for scalability
These constants for the content element look fine. For future expansion, consider grouping them inside a descriptive container object to keep related constants together and reduce repetition.


Line range hint 67-99: Use Cypress commands instead of fixed waits
The test accurately creates a content element but relies on cy.wait(1000) at line 91. Consider using Cypress built-in .should('be.visible'), .should('not.be.disabled'), or other event-driven checks to avoid flakiness and reduce overall test time.


113-134: Solid edit workflow for content element
The test ensures that new title, text, and status changes persist. Adding a negative test (e.g., clearing required fields) could strengthen coverage.


Line range hint 151-180: Flashcard creation with forced waits
The test coverage is thorough for creating flashcard elements, but keep in mind that cy.wait(1000) at line 173 could be replaced by more deterministic approaches (e.g., .should('be.visible')).


243-284: Single choice question creation flow
The logic preventing saving until a proper choice is entered is a strong approach. Consider removing manual waits (like cy.wait(500)) in favor of event-based checks to reduce test runtime.


Line range hint 370-430: Multiple choice setup
Again consider replacing cy.wait(500) with .should(...) or other cypress wait strategies. This will stabilize tests and reduce reliance on arbitrary intervals.


Line range hint 549-632: KPRIM question creation
The complex rearranging of answer fields is a good stress test of UI reordering. Again, consider awaiting element states instead of fixed cy.wait(500).


Line range hint 734-776: Creating a numerical question
Relies on a mandatory field approach before enabling save. A more event-driven wait rather than cy.wait(1000) at line 761 is recommended.


Line range hint 891-922: Creating a free text question
The approach is consistent with other types. Replacing cy.wait(500) with .should(...) checks can help reduce flakiness.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644521e and 57ab967.

📒 Files selected for processing (1)
  • cypress/cypress/e2e/D-questions-workflow.cy.ts (8 hunks)
🔇 Additional comments (25)
cypress/cypress/e2e/D-questions-workflow.cy.ts (25)

9-14: Flashcard constants look good
The naming and consistency align well with the content element constants. No issues found.


16-22: Single choice question constants
Neat approach to define initial and edited titles, content, and choices. This helps ensure clarity and maintainability of the test code.


23-29: Multiple choice question constants
Consistent array usage for choices. Nicely parallels the single choice setup.


30-36: KPRIM question constants
Straightforward naming convention. Keeps the code readable and easy to maintain.


37-53: Numerical range constants
Defining range boundaries, accuracy, and unit in separate constants is a clear approach. This will simplify updates and expansions.


55-65: Free text question constants
Clear naming and inclusion of sample solutions improves test reliability by verifying user input across multiple solution strings.


100-111: Good verification of content element persistence
This block confirms that values are properly stored and reloaded. You could expand coverage by testing edge cases such as empty or invalid content.


136-149: Verifying edited content element
These checks confirm that the updated title and text are displayed. Straightforward and effective.


182-196: Flashcard persistence checks
Ensuring the flashcard retains its title, status, and explanation fosters high confidence in data integrity. This is solid.


198-223: Editing flashcard with status change
Comprehensive coverage of changing and verifying text, explanation, and status. Good job.


225-241: Verifying edited flashcard
The checks confirm the new values and status. This closes the feature completeness loop for flashcards.


286-304: Single choice question storage validation
All essential fields are confirmed—title, status, and each registered choice. The test has a clear flow.


305-368: Editing single choice with sample solution
Thoroughly tests toggling correct answers and removing/adding answer options. This helps catch corner cases.


431-451: Multiple choice question validation
Reads back the question's title, status, and choices. Maintains consistent patterns with the single choice tests.


453-547: Extensive editing for multiple choice
Adding and deleting answers, setting correctness states, and verifying the final state covers key scenarios comprehensively.


636-661: KPRIM question stored values
Checks exist for the correct question type label, title, status, and rearranged answers. Nicely done.


663-732: Editing KPRIM question
Removing answers, adding new ones, and toggling correctness is tested thoroughly. The “no correct solution required” logic is well handled.


777-798: Confirming numerical question data
Verifies each numerical field is displayed correctly, including unit and accuracy. Straightforward and effective.


800-848: Editing and adding solution ranges
Excellent coverage adding multiple solution ranges. Ensuring at least one valid range is mandatory is tested well.


850-889: Verifying edited numerical question
Checks that revised min, max, and solution ranges persist and are displayed. This ensures data integrity.


923-932: Confirm free text question
Validates title, status, and text presence. Straightforward coverage.


934-962: Editing free text question with sample solutions
Ensures mandatory sample solutions are added before saving. This test comprehensively checks the entire editing flow.


963-980: Verifying edited free text question
Checks new title, content, length, and sample solutions. The coverage is robust.


Line range hint 981-1024: Duplicate and delete question flow
Ensures that duplication works correctly and deletion of the duplicate is successful. Great feature coverage.


1026-1054: Cleanup routine
Systematically deleting all created questions helps avoid test pollution in subsequent runs. Good closure step.

Copy link

@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: 0

🧹 Nitpick comments (2)
.github/workflows/cypress-testing.yml (2)

Line range hint 1-150: Consider workflow optimizations for faster CI runs.

While the current workflow is well-structured, here are some potential optimizations to consider:

  1. Uncomment and enable parallel test execution using the matrix strategy
  2. Consider using dependency caching more aggressively
  3. Enable test splitting and parallelization with Cypress

Apply these changes to optimize the workflow:

  strategy:
-   # fail-fast: false # https://github.com/cypress-io/github-action/issues/48
-   # matrix:
-   #   containers: [1, 2] # Run parallel instances
+   fail-fast: false
+   matrix:
+     containers: [1, 2]

  # In the Cypress step
  - name: Cypress run
    uses: cypress-io/github-action@v6
    timeout-minutes: 60
    with:
      install: false
      wait-on: 'http://127.0.0.1:3000/healthz, http://127.0.0.1:3001, http://127.0.0.1:3002, http://127.0.0.1:3003, http://127.0.0.1:3010'
      wait-on-timeout: 300
      record: true
      browser: electron
      working-directory: cypress
-     # parallel: true
+     parallel: true

Line range hint 118-150: Consider enabling code coverage reporting.

The commented-out code coverage configuration could be valuable for tracking test coverage metrics. Consider enabling it to ensure the extended question workflow tests maintain good coverage.

Uncomment and update the coverage configuration:

-     # - name: Archive code coverage results
-     #   uses: actions/upload-artifact@v3
-     #   with:
-     #     name: code-coverage
-     #     path: cypress/coverage
-
-     # - name: Coveralls
-     #   uses: coverallsapp/github-action@v2
+     - name: Archive code coverage results
+       uses: actions/upload-artifact@v3
+       with:
+         name: code-coverage
+         path: cypress/coverage
+         retention-days: 14
+
+     - name: Upload coverage to Coveralls
+       uses: coverallsapp/github-action@v2
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57ab967 and 90d3521.

📒 Files selected for processing (1)
  • .github/workflows/cypress-testing.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/cypress-testing.yml (1)

14-14: LGTM! Path filter addition aligns with PR objectives.

The addition of the cypress/** path filter ensures that the Cypress tests will run when test files are modified, which is essential for the extended question workflow coverage being added in this PR.

Copy link

cypress bot commented Dec 28, 2024

klicker-uzh    Run #3865

Run Properties:  status check passed Passed #3865  •  git commit 48c4468c25 ℹ️: Merge 90d352182451f08c64f71384d069fa3759e3842a into 644521e1267aa9cd621186b51564...
Project klicker-uzh
Branch Review element-test-suite-extension
Run status status check passed Passed #3865
Run duration 13m 29s
Commit git commit 48c4468c25 ℹ️: Merge 90d352182451f08c64f71384d069fa3759e3842a into 644521e1267aa9cd621186b51564...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 172
View all changes introduced in this branch ↗︎

@sjschlapbach sjschlapbach merged commit 1dde1a1 into v3 Dec 28, 2024
11 checks passed
@sjschlapbach sjschlapbach deleted the element-test-suite-extension branch December 28, 2024 19:34
Copy link

cypress bot commented Dec 28, 2024

klicker-uzh    Run #3869

Run Properties:  status check passed Passed #3869  •  git commit 1dde1a1c7a: chore(cypess): extend questions workflow with extended coverage of question crea...
Project klicker-uzh
Branch Review v3-new-elements
Run status status check passed Passed #3869
Run duration 13m 25s
Commit git commit 1dde1a1c7a: chore(cypess): extend questions workflow with extended coverage of question crea...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 172
View all changes introduced in this branch ↗︎

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

Successfully merging this pull request may close these issues.

1 participant