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: Adds playwright e2e quiz exercise tests for different batch modes #8645

Merged
merged 12 commits into from
Jun 2, 2024

Conversation

muradium
Copy link
Contributor

@muradium muradium commented May 21, 2024

Checklist

General

Client

Motivation and Context

We want to test quiz exercise participation in different batch modes and time schedules.

Description

Adds E2E tests in Playwright for following types of exercises:

  • Quiz exercise with specified working time start date
  • Batched quiz exercises
  • Individual quiz exercises

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 checked by automatic run in CI environment. You can optionally run them locally and check if they pass.

Steps for running the tests:

  1. Navigate to src/tests/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 tests with following commands and confirm that they pass:
  • npx playwright test e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts -g "Quiz exercise scheduled participation"
  • npx playwright test e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts -g "Quiz exercise batched participation"
  • npx playwright test e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts -g "Quiz exercise individual participation"

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

@muradium muradium marked this pull request as ready for review May 23, 2024 11:57
@muradium muradium requested a review from a team as a code owner May 23, 2024 11:57
Copy link

coderabbitai bot commented May 23, 2024

Walkthrough

The updates enhance the functionality of quiz exercise participation tests by incorporating new parameters and scenarios, such as scheduled, batched, and individual quizzes. Additionally, the CourseOverviewPage has been improved with a method to practice exercises and refined navigation for running exercises.

Changes

File Path Change Summary
src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts Added instructor to imports, included dayjs and QuizMode, and expanded quizExercise creation with new parameters. Added new test scenarios for various quiz types.
src/test/playwright/support/pageobjects/course/CourseOverviewPage.ts Updated openRunningExercise to use getOpenRunningExerciseButton. Added practiceExercise method and getOpenRunningExerciseButton for retrieving the button locator.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant CourseOverviewPage
    participant QuizExerciseParticipation

    User->>CourseOverviewPage: openRunningExercise(exerciseId)
    CourseOverviewPage->>CourseOverviewPage: getOpenRunningExerciseButton(exerciseId)
    CourseOverviewPage-->>User: Click Button

    User->>QuizExerciseParticipation: Start Quiz
    QuizExerciseParticipation->>QuizExerciseParticipation: Initialize quiz parameters
    QuizExerciseParticipation-->>User: Participate in Quiz

    User->>CourseOverviewPage: practiceExercise()
    CourseOverviewPage-->>User: Initiate Exercise Practice
Loading

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

rstief
rstief previously approved these changes May 23, 2024
Copy link
Contributor

@rstief rstief left a comment

Choose a reason for hiding this comment

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

Demonstrated in testing session, code also LGTM

BBesrour
BBesrour previously approved these changes May 23, 2024
Copy link
Member

@BBesrour BBesrour left a comment

Choose a reason for hiding this comment

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

Demonstrated in testing session.

dmytropolityka
dmytropolityka previously approved these changes May 23, 2024
Copy link
Contributor

@dmytropolityka dmytropolityka left a comment

Choose a reason for hiding this comment

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

works as described

coolchock
coolchock previously approved these changes May 23, 2024
Copy link
Contributor

@coolchock coolchock left a comment

Choose a reason for hiding this comment

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

demonstrated in the testing session, LGTM

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

@muradium muradium dismissed stale reviews from rstief, coolchock, BBesrour, and dmytropolityka via 84f0c7e May 24, 2024 21:15
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: 2

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

Outside diff range and nitpick comments (5)
src/test/playwright/support/requests/ExerciseAPIRequests.ts (5)

Line range hint 107-107: Consider using template literals for string concatenation to improve readability and maintain consistency with modern JavaScript practices.

- title = 'Programming ' + generateUUID(),
+ title = `Programming ${generateUUID()}`,

Also applies to: 108-108, 132-132, 221-221, 225-225, 265-265, 269-269, 309-309, 317-317, 406-406, 419-419


Line range hint 119-119: Use strict equality checks (===) instead of loose equality (==) to avoid unexpected type coercion.

- if (programmingLanguage == ProgrammingLanguage.PYTHON) {
+ if (programmingLanguage === ProgrammingLanguage.PYTHON) {

Also applies to: 121-121, 123-123


Line range hint 183-183: Avoid using non-null assertions (!). Instead, handle potential null or undefined values gracefully.

- id: testCase.id!,
+ id: testCase.id ?? throw new Error('Test case ID is missing'),

Also applies to: 365-365


Line range hint 324-324: Avoid using any type for variables. Specify a more precise type to enhance type safety and code maintainability.

- const quizExercise: any = {
+ const quizExercise: QuizExercise = {

Also applies to: 413-413


Line range hint 326-326: Replace hasOwnProperty with a safer alternative to check property existence.

- if (body.hasOwnProperty('course')) {
+ if (Object.prototype.hasOwnProperty.call(body, 'course')) {

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

Outside diff range and nitpick comments (2)
src/test/playwright/e2e/course/CourseExercise.spec.ts (1)

Line range hint 30-42: Avoid using non-null assertions (!). Consider adding proper null checks or handling potential null values gracefully.

-            await exerciseAPIRequests.deleteQuizExercise(exercise1.id!);
-            await exerciseAPIRequests.deleteQuizExercise(exercise2.id!);
-            await exerciseAPIRequests.deleteQuizExercise(exercise3.id!);
+            if (exercise1.id && exercise2.id && exercise3.id) {
+                await exerciseAPIRequests.deleteQuizExercise(exercise1.id);
+                await exerciseAPIRequests.deleteQuizExercise(exercise2.id);
+                await exerciseAPIRequests.deleteQuizExercise(exercise3.id);
+            } else {
+                console.error('One of the exercises has a null id');
+            }
src/test/playwright/support/pageobjects/exam/ExamExerciseGroupCreationPage.ts (1)

Line range hint 48-48: Consider using template literals for string concatenation for better readability and performance.

-        const response = await this.handleAddGroupWithExercise(exam, 'Exercise ' + generateUUID(), exerciseType, additionalData);
+        const response = await this.handleAddGroupWithExercise(exam, `Exercise ${generateUUID()}`, exerciseType, additionalData);

Also, use strict equality (===) for comparisons to avoid unexpected type coercion.

-        if (exerciseType == ExerciseType.QUIZ) {
+        if (exerciseType === ExerciseType.QUIZ) {

Also applies to: 50-50

coderabbitai[bot]
coderabbitai bot previously approved these changes May 26, 2024
Copy link
Contributor

@marlon-luca-bu marlon-luca-bu left a comment

Choose a reason for hiding this comment

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

Changes look good to me

Copy link
Contributor

@sarpsahinalp sarpsahinalp left a comment

Choose a reason for hiding this comment

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

Code lgtm

Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

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

test cases LGTM👍

Copy link
Member

@BBesrour BBesrour left a comment

Choose a reason for hiding this comment

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

re-approve

Copy link
Contributor

@rstief rstief left a comment

Choose a reason for hiding this comment

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

Code changes lgtm

@krusche krusche changed the title Development: Adds quiz exercise tests for different batch modes Development: Adds playwright e2e quiz exercise tests for different batch modes Jun 2, 2024
@krusche krusche added this to the 7.1.2 milestone Jun 2, 2024
@krusche krusche merged commit 89fb93f into develop Jun 2, 2024
28 of 33 checks passed
@krusche krusche deleted the feature/playwright/quiz-exercise-batch-modes branch June 2, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants