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

enhance(cypress): extend coverage of test suite, extract functions and simplify structure #4299

Merged
merged 17 commits into from
Oct 9, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Oct 7, 2024

With this pull request, the test suite is rewritten in most parts to remove dependencies on seeded elements whereever possible and the allow running tests multiple times without having the re-seed the database (except from group activity run at the moment).
Additionally, the test runs reduce duplication and are split into smaller segments, separating lecturer and student test cases more cleanly and allowing to locate errors more quickly later on.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced feedback management with improved mapping in the Feedback Channel.
    • Updated question editing interface with dynamic data attributes for answer choices.
    • Improved group creation and action components with new input data properties.
    • Added specific data attributes to various components for better testing capabilities.
  • Bug Fixes

    • Refined logic for handling response submissions in practice quizzes.
  • Documentation

    • Enhanced accessibility and testing capabilities across multiple components with new data attributes.
  • Chores

    • Updated Cypress configuration and added new environment variables for testing.

Copy link

gitguardian bot commented Oct 7, 2024

⚠️ GitGuardian has uncovered 9 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
1509427 Triggered Generic Password 6a94327 cypress/cypress.config.ts View secret
1509427 Triggered Generic Password 6a94327 packages/prisma/src/data/seedTEST.ts View secret
1509427 Triggered Generic Password 6a94327 packages/prisma/src/data/seedTEST.ts View secret
1509427 Triggered Generic Password cddb1af cypress/cypress.config.ts View secret
14050276 Triggered Generic Password 6a94327 packages/prisma/src/data/seedTEST.ts View secret
14050276 Triggered Generic Password 6a94327 packages/prisma/src/data/seedTEST.ts View secret
14050276 Triggered Generic Password 6a94327 cypress/cypress.config.ts View secret
14050276 Triggered Generic Password cddb1af cypress/cypress.config.ts View secret
14050276 Triggered Generic Password f42a129 cypress/cypress.config.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link

aviator-app bot commented Oct 7, 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 Oct 7, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request includes several updates across multiple components in the frontend and testing suites. Key changes involve the addition of dynamic data-cy attributes for improved testing capabilities, modifications to mapping functions in feedback components, and enhancements to the structure and organization of Cypress end-to-end tests. Additionally, environment variables in the Cypress configuration have been expanded, and several new constants have been introduced in various test files to improve clarity and maintainability.

Changes

File Path Change Summary
apps/frontend-manage/src/components/interaction/feedbacks/FeedbackChannel.tsx Updated mapping function to include an index parameter for sortedFeedbacks.
apps/frontend-manage/src/components/questions/QuestionEditModal.tsx Added dynamic data-cy attributes for answer choices; refined choice rendering logic.
apps/frontend-manage/src/components/sessions/creation/liveQuiz/LiveQuizCreationBlock.tsx Updated data-cy attributes for buttons and drop area to include the block's index.
apps/frontend-manage/src/pages/courses/[id].tsx Added data-cy attribute to the course pin code display for testing purposes.
apps/frontend-pwa/src/components/participant/groups/GroupAction.tsx Added optional inputData property to GroupActionProps interface for additional input data.
apps/frontend-pwa/src/components/participant/groups/GroupCreationBlock.tsx Introduced inputData property in GroupCreationBlock for passing data attributes.
apps/frontend-pwa/src/components/practiceQuiz/ElementStack.tsx Updated data attributes for buttons; refined response submission logic.
apps/frontend-pwa/src/pages/join.tsx Added data prop to FormikPinField and Button components for testing.
cypress/cypress.config.ts Added multiple new environment variables for student usernames; updated STUDENT_PASSWORD.
cypress/cypress/e2e/A-login-workflow.cy.ts Introduced new test cases for profile and password modifications; adjusted existing tests.
cypress/cypress/e2e/C-control-workflow.cy.ts Updated test cases for creating questions and live quizzes; streamlined login process.
cypress/cypress/e2e/E-course-workflow.cy.ts Restructured tests for course management; removed and replaced initial test for assigning random groups.
cypress/cypress/e2e/F-live-quiz-workflow.cy.ts Added global variables for quiz settings; reorganized test structures.
cypress/cypress/e2e/G-microlearning-workflow.cy.ts Added constants for question titles and descriptions; altered test structure for clarity.
cypress/cypress/e2e/H-practice-quiz-workflow.cy.ts Removed UUID-based variables; replaced with descriptive constants for quiz titles.
cypress/cypress/e2e/I-bookmarking-workflow.cy.ts Introduced new test suite for bookmarking functionalities.
cypress/cypress/e2e/I-practice-quiz-student.cy.ts Deleted file containing end-to-end tests for practice quizzes from a student perspective.
cypress/cypress/e2e/J-bookmarking-workflow.cy.ts Deleted file for question bookmarking and flagging workflow tests.
cypress/cypress/e2e/J-group-activity-workflow.cy.ts Added constants for various question types and activity parameters; comprehensive test setup.
cypress/cypress/support/commands.ts Enhanced custom commands related to user login and question creation.
cypress/package.json Updated to include a new development dependency.
cypress/tsconfig.json Updated compilerOptions to include new types.
packages/prisma/src/data/seedTEST.ts Updated participant password in the seeding logic.
packages/shared-components/src/questions/SCAnswerOptionsOLD.tsx Modified data attribute in Button component for unique cy value assignment.

Possibly related PRs

Suggested reviewers

  • rschlaefli: Suggested for review based on expertise and involvement in related components.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bf402ee and ac49c25.

📒 Files selected for processing (3)
  • cypress/cypress/e2e/F-live-quiz-workflow.cy.ts (6 hunks)
  • cypress/cypress/e2e/G-microlearning-workflow.cy.ts (3 hunks)
  • cypress/cypress/e2e/H-practice-quiz-workflow.cy.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (7)
cypress/cypress/e2e/F-live-quiz-workflow.cy.ts (1)

1-27: LGTM: Well-structured global variables and imports

The use of global variables for quiz settings, session names, and other configurations improves code readability and maintainability. The import of the UUID library for generating unique identifiers is a good practice. The use of constants for messages suggests proper internationalization support.

cypress/cypress/e2e/G-microlearning-workflow.cy.ts (6)

1-22: LGTM! Good use of constants and UUID for test data.

The use of constants for question titles and content improves maintainability and readability. The UUID library ensures unique identifiers, which is crucial for test isolation.


41-53: LGTM! Well-organized constants for different microlearning types.

The constants for future, complete, and duplicated microlearnings are well-named and organized. This approach enhances the readability and maintainability of the tests.


425-444: LGTM! Efficient test for future microlearning creation.

The use of the custom cy.createMicroLearning command streamlines the test and likely reduces code duplication. The dynamic calculation of the future start date ensures the test remains valid over time. The verification of the draft state is an important check.


550-582: LGTM! Comprehensive test for extending microlearning duration.

This test effectively covers both the successful extension of a microlearning and the prevention of setting invalid past dates. The verification of the updated end date display is a good touch. The inclusion of both positive and negative scenarios strengthens the test's effectiveness.


694-714: LGTM! Well-structured tests for future microlearnings.

These tests effectively cover the publishing process for future microlearnings and correctly verify their visibility (or lack thereof) to students. The check for the 'scheduled' state is an important detail that ensures the system correctly handles future-dated content.


859-867: LGTM! Important verification of microlearning deletion from student view.

This test effectively ensures that deleted microlearnings are no longer visible to students, which is crucial for maintaining the integrity of the learning environment. The check for multiple microlearnings adds to the thoroughness of the test.


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 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

cypress bot commented Oct 7, 2024

klicker-uzh    Run #3183

Run Properties:  status check passed Passed #3183  •  git commit 0cf794fc0d ℹ️: Merge ac49c25e1aa149439f8a407e2e452f9043d921aa into 9f8be29c87d0cfaf527683a23864...
Project klicker-uzh
Run status status check passed Passed #3183
Run duration 08m 58s
Commit git commit 0cf794fc0d ℹ️: Merge ac49c25e1aa149439f8a407e2e452f9043d921aa into 9f8be29c87d0cfaf527683a23864...
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 92

@sjschlapbach sjschlapbach marked this pull request as ready for review October 9, 2024 11:22
cypress/cypress/support/commands.ts Dismissed Show dismissed Hide dismissed
Copy link

sonarqubecloud bot commented Oct 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@sjschlapbach sjschlapbach merged commit 393e53e into v3 Oct 9, 2024
10 of 14 checks passed
@sjschlapbach sjschlapbach deleted the extended-test-suite branch October 9, 2024 12:28
Copy link

cypress bot commented Oct 9, 2024

klicker-uzh    Run #3184

Run Properties:  status check passed Passed #3184  •  git commit 393e53e59e: enhance(cypress): extend coverage of test suite, extract functions and simplify ...
Project klicker-uzh
Run status status check passed Passed #3184
Run duration 09m 20s
Commit git commit 393e53e59e: enhance(cypress): extend coverage of test suite, extract functions and simplify ...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
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 92

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