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: Fix e2e playwright tests that navigate to a course page #8764

Merged
merged 1 commit into from
Jun 8, 2024

Conversation

muradium
Copy link
Contributor

@muradium muradium commented Jun 7, 2024

Checklist

General

Client

Motivation and Context

After changes to course exercises page, directly accessing a course page does not open the first exercise. E2E tests relying on that fail.

Description

This PR fixes the failing tests by navigating to exercise page instead of the course page.

Steps for Testing

  • Code Review: Ensure that tests pass for valid reasons, functionality is adequately tested and check the code quality.
  • Run the tests: Tests are checked by automatic run in CI environment. You can also 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/modeling/ModelingExerciseParticipation.spec.ts
  • npx playwright test e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts
  • npx playwright test e2e/exercise/ExerciseImport.spec.ts

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

  • Refactor
    • Updated login URLs to include exercise IDs for text, quiz, modeling, and programming exercises in the Import exercises test suite.
    • Enhanced login process for modeling and quiz exercises to ensure proper navigation and participation by including exercise IDs in the URLs.

@muradium muradium requested a review from a team as a code owner June 7, 2024 13:59
Copy link

coderabbitai bot commented Jun 7, 2024

Walkthrough

The recent updates focus on refining the login URLs in various test suites to include specific exercise IDs. This enhancement ensures precise navigation for students to particular exercises within their courses, improving the accuracy and reliability of the test scenarios for text, quiz, modeling, and programming exercises.

Changes

File Path Change Summary
src/test/playwright/e2e/exercise/ExerciseImport.spec.ts Updated login URLs to include exercise IDs for different exercise types in the Import exercises test suite.
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts Modified login process to include exercise ID in the URL for modeling exercises.
src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts Updated login paths for students to include exercise IDs within course URLs for quiz exercises.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Student
    participant System

    Student->>System: Login with `/courses/{course.id}/exercises/{exercise.id}`
    System-->>Student: Authenticate and Redirect to Exercise Page
    Student->>System: Start Exercise
    System-->>Student: Display Exercise Interface
    Student->>System: Submit Exercise
    System-->>Student: Confirm Submission
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 21e2e0a and 739fa98.

Files selected for processing (3)
  • src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (4 hunks)
  • src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts (8 hunks)
Additional context used
Biome
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts

[error] 20-20: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 21-21: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 22-22: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 23-23: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 24-24: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 1-1: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.


[error] 1-2: All these imports are only used as types. (lint/style/useImportType)

Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.

src/test/playwright/e2e/exercise/ExerciseImport.spec.ts

[error] 45-45: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 47-47: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 48-48: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 57-57: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 58-58: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 62-62: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 62-62: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 75-75: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 77-77: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 78-78: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 84-84: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 86-86: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 87-87: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 88-88: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 98-98: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 101-101: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 102-102: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 111-111: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 112-112: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 113-113: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts

[error] 29-29: Template literals are preferred over string concatenation. (lint/style/useTemplate)

Unsafe fix: Use a template literal.


[error] 35-35: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 36-36: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 37-37: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 42-42: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 43-43: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 44-44: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 45-45: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 46-46: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 47-47: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 65-65: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 71-71: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 104-104: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 105-105: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 106-106: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 106-106: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 108-108: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 109-109: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 122-122: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 125-125: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Additional comments not posted (3)
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (1)

19-19: Update the login URL to include exercise ID.

This change aligns with the PR's objective to navigate directly to the exercise page, improving test accuracy and relevance.

src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (1)

56-56: Update the login URL to include exercise ID.

This change ensures that the test navigates directly to the specific exercise, which is crucial for the accuracy of the test.

src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts (1)

36-36: Update the login URL to include exercise ID.

This change ensures that the test navigates directly to the specific exercise, which is crucial for the accuracy of the test.

Also applies to: 44-44, 64-64, 70-70, 107-107, 124-124, 141-141, 162-162, 180-180

Tools
Biome

[error] 36-36: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


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.

@github-actions github-actions bot added the tests label Jun 7, 2024
@muradium muradium changed the title General: Fix E2E tests that navigate to an exercise General: Fix E2E tests that navigate to a course page Jun 7, 2024
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 comments (4)
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (2)

Line range hint 20-24: Remove non-null assertions.

- await courseOverview.startExercise(modelingExercise.id!);
- await courseOverview.openRunningExercise(modelingExercise.id!);
- await modelingExerciseEditor.addComponentToModel(modelingExercise.id!, 1, 310, 320);
- await modelingExerciseEditor.addComponentToModel(modelingExercise.id!, 2, 730, 500);
- await modelingExerciseEditor.addComponentToModel(modelingExercise.id!, 3, 1000, 100);
+ await courseOverview.startExercise(modelingExercise.id);
+ await courseOverview.openRunningExercise(modelingExercise.id);
+ await modelingExerciseEditor.addComponentToModel(modelingExercise.id, 1, 310, 320);
+ await modelingExerciseEditor.addComponentToModel(modelingExercise.id, 2, 730, 500);
+ await modelingExerciseEditor.addComponentToModel(modelingExercise.id, 3, 1000, 100);

Non-null assertions should be avoided unless absolutely necessary as they can lead to runtime errors if the values are null.

Tools
Biome

[error] 20-20: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 21-21: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 22-22: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


Line range hint 1-2: Use type-only imports for TypeScript entities.

- import { Course } from 'app/entities/course.model';
- import { ModelingExercise } from 'app/entities/modeling-exercise.model';
+ import type { Course } from 'app/entities/course.model';
+ import type { ModelingExercise } from 'app/entities/modeling-exercise.model';

This change ensures that these imports are used for type checking only and not included in the JavaScript output, optimizing the bundle size.

Tools
Biome

[error] 20-20: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 21-21: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 22-22: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (1)

Line range hint 45-48: Remove non-null assertions.

- await courseManagementExercises.clickImportExercise(textExercise.id!);
- await expect(page.locator('#field_title')).toHaveValue(textExercise.title!);
- await expect(page.locator('#field_points')).toHaveValue(`${textExercise.maxPoints!}`);
- await textExerciseCreation.setReleaseDate(dayjs());
- await textExerciseCreation.setDueDate(dayjs().add(1, 'days'));
- await textExerciseCreation.setAssessmentDueDate(dayjs().add(2, 'days'));
- await login(studentOne, `/courses/${secondCourse.id}/exercises/${exercise.id}`);
+ await courseManagementExercises.clickImportExercise(textExercise.id);
+ await expect(page.locator('#field_title')).toHaveValue(textExercise.title);
+ await expect(page.locator('#field_points')).toHaveValue(`${textExercise.maxPoints}`);
+ await textExerciseCreation.setReleaseDate(dayjs());
+ await textExerciseCreation.setDueDate(dayjs().add(1, 'days'));
+ await textExerciseCreation.setAssessmentDueDate(dayjs().add(2, 'days'));
+ await login(studentOne, `/courses/${secondCourse.id}/exercises/${exercise.id}`);

Non-null assertions should be avoided unless absolutely necessary as they can lead to runtime errors if the values are null.

Also applies to: 57-58, 62-62, 75-78, 84-88, 98-102, 111-113

Tools
Biome

[error] 57-57: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 58-58: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseParticipation.spec.ts (1)

Line range hint 29-29: Use template literals instead of string concatenation.

- await login(studentOne, '/courses/' + course.id);
+ await login(studentOne, `/courses/${course.id}`);

Using template literals improves readability and consistency in the code.

Tools
Biome

[error] 35-35: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 36-36: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 37-37: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 42-42: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 43-43: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 44-44: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 45-45: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 46-46: Forbidden non-null assertion. (lint/style/noNonNullAssertion)


[error] 47-47: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

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.

code changes and explanation make sense, the tests pass

Copy link
Contributor

@JohannesStoehr JohannesStoehr 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 and the corresponding e2e tests pass

Copy link
Contributor

@edkaya edkaya left a comment

Choose a reason for hiding this comment

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

Corresponding e2e tests pass

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.

shown in testing session 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.

Tested in a testing session

@krusche krusche changed the title General: Fix E2E tests that navigate to a course page Development: Fix e2e playwright tests that navigate to a course page Jun 7, 2024
@krusche krusche added this to the 7.2.0 milestone Jun 8, 2024
@krusche krusche merged commit c75be72 into develop Jun 8, 2024
41 of 44 checks passed
@krusche krusche deleted the feature/playwright/fix-exercise-open-in-tests branch June 8, 2024 19:21
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.

7 participants