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

Development: E2E tests for programming exam participations using Git #10326

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

muradium
Copy link
Contributor

@muradium muradium commented Feb 14, 2025

Checklist

General

Client

Motivation and Context

We want to test the scenario where students participate in exams that contain programming exercises with automatic assessment and make submissions using Git.

Description

Adds 3 E2E tests in Playwright about participating exams with automatic programming exercise assessment and submitting solutions using Git. It includes Git submission using HTTPS + username/password, HTTPS + token and SSH using ED25519 key.

Steps for Testing

  • Code Review: Ensure that tests pass for valid reasons, functionality is adequately tested and check the code quality.
  • Run the tests (optional): Tests are executed during automatic run in CI environment. You can run them locally and check if they pass.

Steps for running the tests:

  1. Navigate to src/test/playwright
  2. Configure Playwright using playwright.env file based on your local setup. Current configuration should work for default Artemis setup.
  3. Run npm install && npm run playwright:setup
  4. Run the test group using one of the methods:
  • Run npx playwright test e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts -g "Programming exam with Git submissions"
  • Run npm run playwright:open to open the Playwright UI, search for the "Programming exam with Git submissions" test suite and run it
  1. Confirm that the "Participates in exam by Git submission using {https/https with token/ssh}" tests pass

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features

    • Enhanced programming exam participation with Git submissions, supporting multiple clone methods and automatic assessment for programming exercises.
  • Refactor

    • Streamlined submission handling and score verification to improve the overall exam experience.
  • Tests

    • Upgraded test setups with improved diagnostics, including video recordings on first retry for enhanced stability.

Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

This pull request refactors and enhances the Playwright test suite for exam participation and programming exercises using Git submissions. It updates test files by adding new imports, a dedicated test suite for Git-based programming exercises, and a new exam creation helper. The changes also remove an intermediary helper in favor of direct calls to the new GitExerciseParticipation class, update test configuration scripts with debugging and video recording settings, and modify page objects to better validate exercise scores and handle Git submissions.

Changes

Files Change Summary
src/test/playwright/e2e/exam/ExamParticipation.spec.ts
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts
Added new imports and test suites for programming exercises with Git submissions. Removed the helper function in favor of direct calls to GitExerciseParticipation.makeSubmission, streamlining the test logic.
src/test/playwright/package.json
src/test/playwright/playwright.config.ts
Modified the sequential test script to include DEBUG=pw:api for enhanced API debugging and added video recording for tests on the first retry.
src/test/playwright/support/pageobjects/exam/ExamParticipationPage.ts
src/test/playwright/support/pageobjects/exercises/programming/GitExerciseParticipation.ts
src/test/playwright/support/pageobjects/exercises/programming/ProgrammingExerciseOverviewPage.ts
Added a new method (checkExerciseScore) to validate exercise scores, introduced the GitExerciseParticipation class with methods for handling submissions and SSH credentials, and updated method names and enum values for clearer result score validation.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test Runner
    participant G as GitExerciseParticipation
    participant E as ExamParticipationPage
    T->>G: [If SSH] setupSSHCredentials(context, sshAlgorithm)
    T->>G: makeSubmission(..., cloneMethod, sshAlgorithm)
    G->>G: pushGitSubmissionFiles(...)  %% internal submission processing
    G-->>T: Submission completed
    T->>E: checkExerciseScore(expectedResult)
Loading

Possibly related PRs

Suggested labels

tests, ready for review, client, playwright, bugfix

Suggested reviewers

  • SimonEntholzer
  • az108
  • krusche
  • coolchock
  • BBesrour
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 or @coderabbitai title anywhere in the PR title to generate the title automatically.

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

🧹 Nitpick comments (1)
src/test/playwright/support/pageobjects/exercises/programming/GitExerciseParticipation.ts (1)

13-13: Consider simplifying static-only class.
The linter flags this class for containing only static members. Converting it to a module of standalone functions or a simple object may offer cleaner code and fewer dependencies.

🧰 Tools
🪛 Biome (1.9.4)

[error] 13-103: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b85116 and 64c970c.

📒 Files selected for processing (7)
  • src/test/playwright/e2e/exam/ExamParticipation.spec.ts (3 hunks)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (5 hunks)
  • src/test/playwright/package.json (1 hunks)
  • src/test/playwright/playwright.config.ts (1 hunks)
  • src/test/playwright/support/pageobjects/exam/ExamParticipationPage.ts (1 hunks)
  • src/test/playwright/support/pageobjects/exercises/programming/GitExerciseParticipation.ts (1 hunks)
  • src/test/playwright/support/pageobjects/exercises/programming/ProgrammingExerciseOverviewPage.ts (3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/test/playwright/support/pageobjects/exercises/programming/GitExerciseParticipation.ts

[error] 13-103: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: client-tests
  • GitHub Check: Analyse
🔇 Additional comments (12)
src/test/playwright/support/pageobjects/exercises/programming/GitExerciseParticipation.ts (2)

47-59: SSH setup appears valid.
The approach to retrieving and setting SSH keys for the user is straightforward and ensures the key is added to the test environment.


70-102: Well-structured Git submission process.
The sequence (deleting files, creating new files, committing, and pushing) is logically correct and ensures a clean working directory before submission. Please confirm error handling for cases when file operations or Git commands fail.

src/test/playwright/e2e/exam/ExamParticipation.spec.ts (3)

3-3: Additional import looks fine.
This import for ProgrammingExerciseAssessmentType is consistent with the new usage in the exam creation.


17-20: New imports for Git-based exam flows.
These imports correctly bring in classes and enums used for Git submissions in the new programming exam tests.


267-319: Dynamic testing of multiple Git clone methods.
Running the same test suite for HTTPS, HTTPS with token, and SSH ensures thorough coverage. The setup and teardown logic for SSH keys is well-placed under conditional hooks, promoting test stability.

src/test/playwright/playwright.config.ts (1)

35-37: Video recording on first retry is a good choice.
This configuration helps diagnose flaky tests without generating excessive video artifacts.

src/test/playwright/support/pageobjects/exercises/programming/ProgrammingExerciseOverviewPage.ts (2)

18-22: LGTM! Method rename improves clarity of intent.

The method rename from getResultScore to checkResultScore better reflects its assertion functionality, making the code more self-documenting.


76-80: LGTM! Enum values are now more descriptive.

The explicit string values in the GitCloneMethod enum improve readability and make the code more maintainable.

src/test/playwright/support/pageobjects/exam/ExamParticipationPage.ts (1)

128-132: LGTM! New method follows consistent pattern.

The checkExerciseScore method follows the same pattern as checkResultScore, maintaining consistency across the codebase.

src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (2)

79-83: LGTM! Test code simplified using direct calls.

The test now directly uses GitExerciseParticipation.makeSubmission, making it cleaner and more maintainable.


106-110: LGTM! Improved SSH key verification.

The code now properly verifies the absence of SSH key and displays appropriate alert before setup.

src/test/playwright/package.json (1)

20-20: LGTM! Enhanced debugging capabilities.

Adding DEBUG=pw:api to the sequential test script will help in diagnosing API-related issues during test runs.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

1 participant