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: Playwright exam checklist e2e tests #10050

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

Conversation

muradium
Copy link
Contributor

@muradium muradium commented Dec 19, 2024

Checklist

General

Client

Motivation and Context

Functionality of the exam checklist is not being tested from the user perspective.

Description

Adds E2E tests that assert the states of all checks on exam checklist during various scenarios.

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/exam/ExamChecklists.spec.ts
  • Run npm run playwright:open to open the Playwright UI, search for the "Exam Checklists" test suite and run all tests of it
  1. Confirm that all tests pass

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features

    • Enhanced testability with the addition of data-testid attributes in various components.
    • New methods for managing exam functionalities, including setting publish and review dates, and managing exercise groups.
    • Comprehensive end-to-end tests for exam checklists and participation scenarios.
    • New methods for bulk student registration and exam time management.
  • Bug Fixes

    • Streamlined test structures for better encapsulation and clarity.
  • Documentation

    • Minor adjustments to documentation comments for clarity.
  • Chores

    • Removed unused imports and refactored test cases for improved organization.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) playwright labels Dec 19, 2024
@muradium muradium marked this pull request as ready for review December 21, 2024 15:50
@muradium muradium requested a review from a team as a code owner December 21, 2024 15:50
Copy link

coderabbitai bot commented Dec 21, 2024

Walkthrough

This pull request introduces enhancements to the exam management and testing infrastructure in the Artemis platform. The changes primarily focus on improving testability by adding data-testid attributes to various HTML components, expanding the test suite for exam-related functionalities, and updating existing page objects and API request classes. Key modifications include the addition of identifiers for easier test selection, new methods for managing exam processes, and comprehensive end-to-end tests for exam checklists and management.

Changes

File Path Change Summary
src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-checklist.component.html Added data-testid attributes to checklist components and navigation links
src/main/webapp/app/shared/components/checklist-check/checklist-check.component.html Added data-testid attributes to icon elements based on check state
src/test/playwright/e2e/exam/ExamAssessment.spec.ts Refactored prepareExam function and removed startAssessing function; updated test cases accordingly
src/test/playwright/e2e/exam/ExamChecklists.spec.ts Added new end-to-end tests for managing exam checklists
src/test/playwright/e2e/exam/ExamCreationDeletion.spec.ts Localized exam data within test cases for better encapsulation
src/test/playwright/e2e/exam/ExamParticipation.spec.ts Updated test annotations and variable names for clarity
src/test/playwright/support/fixtures.ts Removed EditExamPage import and related property from ArtemisPageObjects
src/test/playwright/support/pageobjects/exam/EditExamPage.ts Removed EditExamPage class
src/test/playwright/support/pageobjects/exam/ExamCreationPage.ts Added new methods for setting exam result and review dates
src/test/playwright/support/pageobjects/exam/ExamDetailsPage.ts Expanded functionality with new methods for interacting with exam details
src/test/playwright/support/pageobjects/exam/ExamExerciseGroupCreationPage.ts Added a method for setting mandatory checkbox state and updated existing methods
src/test/playwright/support/pageobjects/exam/StudentExamManagementPage.ts Added clickPrepareExerciseStart method
src/test/playwright/support/requests/ExamAPIRequests.ts Added methods for bulk student registration and exam time management
src/test/playwright/support/requests/ExerciseAPIRequests.ts Updated methods for exercise creation and submission with new parameters
src/test/playwright/support/utils.ts Added new utility functions for exam preparation and submission

Suggested labels

assessment

Suggested reviewers

  • SimonEntholzer
  • krusche
  • EneaGore
  • coolchock
  • BBesrour

Possibly related PRs

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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

🧹 Nitpick comments (19)
src/test/playwright/support/pageobjects/exam/ExamExerciseGroupCreationPage.ts (2)

30-36: Ensure proper naming or return value for the “isMandatoryBoxShouldBeChecked” usage
Although this code is correct in terms of toggling the checkbox, the method name "isMandatoryBoxShouldBeChecked" does not return the boolean promise, nor is it used as an assertion. You might consider renaming it to "checkMandatoryBoxState" and returning the boolean result from "isChecked()" if needed.


82-89: Check for consistent handling of undefined parameters
Similar to the above comment, "isMandatory" and "exerciseTemplate" are optional. Confirm that "isMandatory" defaults to a suitable fallback (e.g., false) and that "exerciseTemplate" is only used where relevant.

src/test/playwright/support/utils.ts (2)

198-258: Potentially broad function scope
The new “prepareExam” function incorporates several tasks (creating an exam, adding an exercise, registering students, generating exams, preparing for start, making a submission). While it works, consider whether the scope is too broad and if you can break it down into smaller, more focused functions for easier maintenance and test clarity.


260-275: Ensure robust error-handling for exam submission steps
The new “makeExamSubmission” method introduces a sequence of asynchronous steps. If any of these steps (e.g., “startParticipation”, “makeSubmission”, “handInEarly”) fails, a partial submission might occur. If possible, design a fallback or error-handling mechanism to handle partial exam submissions or issues during the submission process.

src/test/playwright/e2e/exam/ExamAssessment.spec.ts (2)

73-73: Prevent unclear time increments
Using “dayjs().add(45, 'seconds')” might be too short for all test steps in certain CI environments. Evaluate whether more generous time buffers are needed or if a dynamic wait is more consistent.


148-148: Add coverage for quiz after exam start
After the exam is prepared for “ExerciseType.QUIZ”, it’s beneficial to explicitly test that the student can see the questions, confirm the right quiz format, then proceed with submission.

src/test/playwright/e2e/exam/ExamChecklists.spec.ts (4)

30-43: Ensure consistent naming conventions
Consider aligning the “ExamChecklistItem.LEAST_ONE_EXERCISE_GROUP” naming with your existing naming patterns. Consistency in naming across specs and page objects makes it easier to track.


78-91: Refactor repetitive steps
The logic for adding empty vs. filled exercise groups might be extracted into a helper. This would reduce code duplication and make test steps more obvious.


193-213: Consider separate tests for date publishing vs. date review
You’re combining multiple date checks in a single test. Splitting them into smaller, more targeted tests could make it easier to isolate potential failures with publish date or review date logic.


277-304: Check for potential concurrency issues with “isMandatory”
You are toggling “isMandatory” in “addExamExerciseGroup”. If multiple instructors or parallel processes are updating exam groups, ensure that concurrency is handled gracefully.

src/main/webapp/app/shared/components/checklist-check/checklist-check.component.html (1)

2-2: Consider adding aria-label for better accessibility.

While the data-testid attributes are great for testing, consider adding aria-label attributes to improve accessibility for screen readers.

-    <fa-icon [icon]="faCheckCircle" [size]="size" [style]="{ color: iconColor ?? 'var(--green)' }" data-testid="check-icon-checked" />
+    <fa-icon [icon]="faCheckCircle" [size]="size" [style]="{ color: iconColor ?? 'var(--green)' }" data-testid="check-icon-checked" aria-label="Item checked" />
-    <fa-icon [icon]="faTimes" [size]="size" class="fs-5" [style]="{ color: iconColor ?? 'var(--markdown-preview-red)' }" data-testid="check-icon-unchecked" />
+    <fa-icon [icon]="faTimes" [size]="size" class="fs-5" [style]="{ color: iconColor ?? 'var(--markdown-preview-red)' }" data-testid="check-icon-unchecked" aria-label="Item unchecked" />

Also applies to: 4-4

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

24-26: Consider adding response waiting pattern for consistency.

Other methods in this class (e.g., clickGenerateStudentExams) wait for API responses. Consider applying the same pattern here for consistency and reliability.

     async clickPrepareExerciseStart() {
+        const responsePromise = this.page.waitForResponse(`${COURSE_BASE}/*/exams/*/prepare-exercise-start`);
         await this.page.click('#startExercisesButton');
+        await responsePromise;
     }
src/test/playwright/support/pageobjects/exam/ExamDetailsPage.ts (2)

13-15: Consider using consistent selector strategy.

Some methods use testid selectors while others use id selectors. For consistency and maintainability, consider using data-testid throughout.

-        await this.page.locator(`#exercises-button-groups`).click();
+        await this.page.getByTestId('exercises-button-groups').click();

-        await this.page.locator('#editButton_publish').click();
+        await this.page.getByTestId('edit-button-publish').click();

-        await this.page.locator('#editButton_review').click();
+        await this.page.getByTestId('edit-button-review').click();

-        await this.page.locator('#evaluateQuizExercisesButton').click();
+        await this.page.getByTestId('evaluate-quiz-exercises-button').click();

-        await this.page.locator('#assessUnsubmittedExamModelingAndTextParticipationsButton').click();
+        await this.page.getByTestId('assess-unsubmitted-participations-button').click();

Also applies to: 47-49, 51-53, 55-57, 59-61


17-22: Consider adding type for error messages.

The error messages could benefit from being defined as constants or in a separate type to ensure consistency and reusability.

type ChecklistErrorMessages = {
    [K in ExamChecklistItem]: string;
};

const CHECKLIST_ERROR_MESSAGES: ChecklistErrorMessages = {
    [ExamChecklistItem.LEAST_ONE_EXERCISE_GROUP]: 'Checklist item for "least one exercise group" is not checked or not found',
    // ... other messages
};

Also applies to: 24-29

src/test/playwright/e2e/exam/ExamCreationDeletion.spec.ts (1)

141-144: Consider using date objects for comparisons.

Using string comparison for dates can be fragile due to timezone and formatting differences. Consider comparing the actual date objects:

-expect(trimDate(editedExam.visibleDate)).toBe(trimDate(dayjsToString(editedExamData.visibleDate)));
-expect(trimDate(editedExam.startDate)).toBe(trimDate(dayjsToString(editedExamData.startDate)));
-expect(trimDate(editedExam.endDate)).toBe(trimDate(dayjsToString(editedExamData.endDate)));
+expect(dayjs(editedExam.visibleDate).isSame(editedExamData.visibleDate)).toBeTruthy();
+expect(dayjs(editedExam.startDate).isSame(editedExamData.startDate)).toBeTruthy();
+expect(dayjs(editedExam.endDate).isSame(editedExamData.endDate)).toBeTruthy();
src/test/playwright/support/requests/ExamAPIRequests.ts (2)

121-126: Enhance method documentation.

Consider adding more details to the JSDoc comment, such as the purpose of bulk registration and any prerequisites or side effects.

 /**
  * Register all course students for the exam
+ * @param exam The exam object for which to register all course students
+ * @description This method performs bulk registration of all students enrolled in the course
+ * for the specified exam. It's more efficient than registering students individually.
  */

218-229: LGTM! Well-implemented exam completion logic.

The method properly handles the exam completion by calculating and adjusting the working time. The defensive check for positive time is a good practice.

Consider clarifying the safety margin comment:

-// Determine the time left until the exam ends and add extra minute
-// to make sure the exam is finished after subtracting it from the working time
+// Add a 60-second safety margin to ensure the exam is marked as finished
+// when subtracting the remaining time from the working time
src/test/playwright/support/requests/ExerciseAPIRequests.ts (1)

220-227: LGTM! Consider adding type safety for exerciseTemplate.

The new parameter addition is well documented and implemented correctly. However, consider replacing any with a proper type definition for better type safety.

-exerciseTemplate: any = textExerciseTemplate,
+type TextExerciseTemplate = typeof textExerciseTemplate;
+exerciseTemplate: TextExerciseTemplate = textExerciseTemplate,
src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-checklist.component.html (1)

Line range hint 1-671: Consider adding data-testid to remaining interactive elements.

For comprehensive E2E testing coverage, consider adding data-testid attributes to other interactive elements like:

  • Edit buttons (e.g., editButton_table, editButton_publish, editButton_review)
  • Assessment dashboard buttons
  • Score view button
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 50adb94 and 5bf7673.

📒 Files selected for processing (15)
  • src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-checklist.component.html (12 hunks)
  • src/main/webapp/app/shared/components/checklist-check/checklist-check.component.html (1 hunks)
  • src/test/playwright/e2e/exam/ExamAssessment.spec.ts (5 hunks)
  • src/test/playwright/e2e/exam/ExamChecklists.spec.ts (1 hunks)
  • src/test/playwright/e2e/exam/ExamCreationDeletion.spec.ts (3 hunks)
  • src/test/playwright/e2e/exam/ExamParticipation.spec.ts (4 hunks)
  • src/test/playwright/support/fixtures.ts (0 hunks)
  • src/test/playwright/support/pageobjects/exam/EditExamPage.ts (0 hunks)
  • src/test/playwright/support/pageobjects/exam/ExamCreationPage.ts (1 hunks)
  • src/test/playwright/support/pageobjects/exam/ExamDetailsPage.ts (2 hunks)
  • src/test/playwright/support/pageobjects/exam/ExamExerciseGroupCreationPage.ts (3 hunks)
  • src/test/playwright/support/pageobjects/exam/StudentExamManagementPage.ts (1 hunks)
  • src/test/playwright/support/requests/ExamAPIRequests.ts (2 hunks)
  • src/test/playwright/support/requests/ExerciseAPIRequests.ts (2 hunks)
  • src/test/playwright/support/utils.ts (2 hunks)
💤 Files with no reviewable changes (2)
  • src/test/playwright/support/pageobjects/exam/EditExamPage.ts
  • src/test/playwright/support/fixtures.ts
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/shared/components/checklist-check/checklist-check.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-checklist.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

🔇 Additional comments (22)
src/test/playwright/e2e/exam/ExamParticipation.spec.ts (4)

263-263: LGTM: Improved test execution granularity

Moving the @slow tag from the suite level to individual tests provides better control over test execution and allows faster tests to run independently.


281-318: LGTM: Well-structured test with appropriate tagging

The test is well-organized with clear phases and proper resource management. The @slow tag is appropriate given the multiple browser contexts and page interactions.


320-320: LGTM: Appropriate test categorization

The addition of the @slow tag is appropriate for this test given its complexity and multiple browser contexts.


Line range hint 361-382: LGTM: Improved naming with examDetails

The replacement of editExam with examDetails provides better clarity about the page object's purpose.

Let's verify that this rename is consistent across the codebase:

✅ Verification successful

The variable rename is consistent across the codebase

The verification shows that:

  • There are no remaining occurrences of editExam in the Playwright test files
  • The new examDetails variable is consistently used across multiple test files including:
    • ExamParticipation.spec.ts
    • ExamCreationDeletion.spec.ts
    • ExamChecklists.spec.ts
    • TestExamCreationDeletion.spec.ts
  • The variable is properly defined in fixtures.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining usage of editExam in test files
rg "editExam" "src/test/playwright"

# Check for the new examDetails usage pattern
rg "examDetails" "src/test/playwright"

Length of output: 9421

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

59-65: Validate optional parameters usage
You introduced optional parameters (isMandatory, exerciseTemplate). Ensure that downstream flows cover the case when they are undefined. For instance, confirm that any logic that depends on 'isMandatory' or 'exerciseTemplate' gracefully handles a non-passed or undefined value.

src/test/playwright/support/utils.ts (1)

277-297: ⚠️ Potential issue

Verify concurrency scenarios
The “startAssessing” function toggles second assessments and manipulates dashboards. Check if concurrency might be an issue here when multiple tutors initiate the assessment concurrently. Consider whether concurrency or lock states arise in your system.

Run the following script to search for concurrency or lock handling in the codebase:

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

16-16: Validate “startAssessing” usage
The import “startAssessing” is heavily utilized throughout this test file. Confirm that all invocation sites match updated signature changes (if any) and handle the second correction round toggling properly.
[approve]


49-49: Avoid silent test failures
When calling “prepareExam” here, consider adding more robust checks or asserts on the returned exam object to ensure the exam was correctly created before it’s used in subsequent steps. This will help avoid silent test failures if “prepareExam” ever fails.


111-111: Double-check “prepareExam” with the 2-round feature
When passing “2” as the numberOfCorrectionRounds, confirm that the exam is indeed configured for multiple assessment rounds. This might require verifying the relevant database or UI fields if these additional rounds are incorrectly set.

src/test/playwright/e2e/exam/ExamChecklists.spec.ts (5)

1-16: Great addition of comprehensive E2E coverage
The newly introduced “ExamChecklists.spec.ts” significantly improves coverage. It clearly tests each checklist item’s status and transitions. The step-by-step approach is well-structured.


52-69: Watch the loop iteration on exam.numberOfExercisesInExam
You loop from index 0 to exam.numberOfExercisesInExam! for adding exercise groups, then add additional groups. Confirm your logic around “NUMBER_OF_EXERCISE_GROUPS” to ensure you don’t create an off-by-one scenario or inadvertently skip the last item.


142-150: Validate student registration flow
After registering “at least one student,” confirm that the UI properly updates. If there are multiple students, you might need to confirm all are updated or only partial.
[approve]


167-187: Await the exam creation tasks before checking checklist
Sometimes the server might take a bit to generate individual exams. If your environment is slow, consider verifying the success of these actions (like ensuring the DB was updated) before re-checking the checklist.


215-229: Confirm race conditions between finishing exam and finalizing assessments
Using “startAssessing” after “finishExam” is valid, but check real usage. If finishing an exam triggers background processes, you may need an additional wait or check to avoid race conditions.

src/main/webapp/app/shared/components/checklist-check/checklist-check.component.html (1)

1-1: LGTM! Proper usage of new Angular control flow syntax.

The @if/@else syntax follows the new Angular guidelines correctly, replacing the older *ngIf directive.

Also applies to: 3-3

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

77-92: LGTM! Well-structured enum for checklist items.

The ExamChecklistItem enum provides good type safety and clear documentation of all possible checklist items.

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

54-73: LGTM! Well-structured date-setting methods.

The new methods maintain consistency with existing patterns and are properly documented.

src/test/playwright/e2e/exam/ExamCreationDeletion.spec.ts (1)

23-34: LGTM! Improved test isolation.

Moving exam data definitions into test scopes and using local exam variables improves test isolation and maintainability.

Also applies to: 69-70, 74-76, 89-90, 94-97

src/test/playwright/support/requests/ExerciseAPIRequests.ts (1)

281-281: LGTM! The new parameter enhances flexibility.

The addition of createNewSubmission parameter provides good control over submission behavior.

src/main/webapp/app/exam/manage/exams/exam-checklist-component/exam-checklist.component.html (3)

Line range hint 53-94: LGTM! Exercise group validation checks are well identified.

The data-testid attributes for exercise group checks follow a consistent naming pattern and cover all critical validations.


146-146: LGTM! Student management elements are properly identified.

The data-testid attributes for student registration check and related navigation buttons are well placed and consistently named.

Also applies to: 157-208


Line range hint 471-605: LGTM! Assessment validation checks are well identified.

The data-testid attributes for assessment-related checks follow a consistent pattern and cover all critical validations.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 21, 2024
SimonEntholzer
SimonEntholzer previously approved these changes Dec 23, 2024
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Tests work fine locally. Is there a reason the two tests in the checklist are skipped?

@muradium
Copy link
Contributor Author

@SimonEntholzer the skipped tests currently fail because of a bug. I created GitHub issues for them and added comments to the skipped tests to make the intention clear.

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 (4)
src/test/playwright/e2e/exam/ExamChecklists.spec.ts (4)

25-139: Consider extracting common verification patterns.

The exercise group tests are well-structured but contain repeated patterns of navigation and verification. Consider:

  1. Creating a helper function for the common pattern of "navigate and verify checklist item state"
  2. Adding descriptive messages to assertions for better debugging

Example helper function:

async function verifyChecklistItem(
  page: Page,
  course: Course,
  exam: Exam,
  examDetails: ExamDetailsPage,
  item: ExamChecklistItem,
  expectedState: 'checked' | 'unchecked',
  message?: string
) {
  await navigateToExamDetailsPage(page, course, exam);
  if (expectedState === 'checked') {
    await examDetails.checkItemChecked(item, message);
  } else {
    await examDetails.checkItemUnchecked(item, message);
  }
}

This would simplify the tests and make them more maintainable.


141-150: Consider adding negative test cases for student registration.

While the happy path is covered, consider adding test cases for:

  1. Attempting to register a student who is already registered
  2. Attempting to register a student who is not in the course
  3. Edge cases around registration deadlines

190-213: Consider additional date-related test cases.

The current test covers the happy path, but consider adding:

  1. Validation for invalid date combinations (e.g., review start date before exam end)
  2. Tests for timezone edge cases
  3. Tests for date modifications after exam creation

281-308: Add JSDoc documentation to helper functions.

The helper functions are well-structured but would benefit from JSDoc documentation to improve maintainability and IDE support.

Example documentation:

/**
 * Creates an exam with the specified configuration
 * @param course - The course to create the exam in
 * @param page - The Playwright page instance
 * @param customConfig - Optional custom configuration to override defaults
 * @returns The created exam instance
 */
async function createExam(course: Course, page: Page, customConfig?: any) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf7673 and 6ac351a.

📒 Files selected for processing (1)
  • src/test/playwright/e2e/exam/ExamChecklists.spec.ts (1 hunks)
🔇 Additional comments (2)
src/test/playwright/e2e/exam/ExamChecklists.spec.ts (2)

16-24: LGTM! Well-structured test setup.

The test suite follows best practices by using API calls for setup, properly managing test resources, and following the Arrange-Act-Assert pattern.


232-237: Monitor skipped tests and their associated issues.

Two tests are currently skipped due to known issues:

Consider setting up automated monitoring of these issues to re-enable the tests once fixed.

Also applies to: 248-274

✅ Verification successful

Both referenced issues are still open - continue skipping the tests

The verification confirms that GitHub issues #10074 and #10076 are still open, justifying the current test skip directives. Continue monitoring these issues:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the issues are still open
gh issue view 10074 --json state
gh issue view 10076 --json state

Length of output: 103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) playwright ready for review tests
Projects
Status: Work In Progress
Development

Successfully merging this pull request may close these issues.

2 participants