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 flaky playwright e2e tests involving automatic exercise assessments #8740

Merged
merged 8 commits into from
Jun 8, 2024

Conversation

muradium
Copy link
Contributor

@muradium muradium commented Jun 4, 2024

Checklist

General

Client

Motivation and Context

There are some flaky Playwright e2e tests that are failing due to automatic exercise assessment taking too long

Description

This PR fixes 3 different test suites as follows:

  1. Exam results tests: divided sequential tests into isolated parametrized tests to reduce time and load of each exam assessment
  2. Quiz exercise assessment tests: automatic quiz assessments may take long when servers under load, thus, increased time for waiting for results from 20s to 60s
  3. Programming exercise team participation - instructor checks the results: this test involves a few programming exercise submissions, which takes long and loads the server. Decreased number of exercise submissions from 3 to 2 (as 2 is enough to check commit history ordering) and now test waits for one build to finish before starting another one to avoid slowing down the server.

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/programming/ProgrammingExerciseParticipation.spec.ts -g "Instructor checks the participation"
  • npx playwright test e2e/exercise/quiz-exercise/QuizExerciseAssessment.spec.ts
  • npx playwright test e2e/exam/ExamResults.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

@muradium muradium requested a review from a team as a code owner June 4, 2024 16:08
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Jun 4, 2024
Copy link

coderabbitai bot commented Jun 4, 2024

Walkthrough

The changes encompass enhancements to the exam participation and result summary features, including adding a data-testid attribute for better testability, restructuring test cases for exam results, refining the handling of exercise builds, and updating locators for result scores. These modifications streamline the testing process, improve the reliability of test cases, and enhance the user experience by ensuring accurate and timely feedback on exam performance.

Changes

File Path Change Summary
src/main/webapp/app/.../exam-result-summary-exercise-card-header.component.html Added data-testid attribute to <span> for achieved percentage display.
src/test/playwright/e2e/exam/ExamResults.spec.ts Refactored test cases, modified imports, and reorganized exam result tests for different exercise types.
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts Adjusted user imports, team creation, and submission handling in programming exercise participation tests.
src/test/playwright/support/commands.ts Introduced waitForExerciseBuildToFinish method in Commands class to wait for exercise builds to finish.
src/test/playwright/support/fixtures.ts Added waitForExerciseBuildToFinish function in ArtemisCommands type for waiting on exercise build completion.
src/test/playwright/support/pageobjects/exam/ExamParticipationActions.ts Updated locator for result score element to use getByTestId('achieved-percentage') and extended timeout for reloading.
src/test/playwright/support/pageobjects/exam/ExamResultsPage.ts Removed display of bonus points in the exam results page.
src/test/playwright/support/pageobjects/exercises/ExerciseResultPage.ts Added timeout parameters to shouldShowScore method call to enhance test reliability.

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.

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 (6)
src/test/playwright/support/pageobjects/exercises/ExerciseResultPage.ts (1)

Line range hint 1-1: Use type imports for Playwright types to optimize bundle size.

- import { Page } from 'playwright';
+ import type { Page } from 'playwright';
src/test/playwright/support/commands.ts (1)

Line range hint 10-96: Consider refactoring the Commands class to use simple functions instead of a class with only static members to simplify the structure and potentially reduce overhead.

Tools
Biome

[error] 10-96: Avoid classes that contain only static members. (lint/complexity/noStaticOnlyClass)

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


[error] 77-77: This type annotation is trivially inferred from its initialization. (lint/style/noInferrableTypes)

Safe fix: Remove the type annotation.


[error] 77-77: This type annotation is trivially inferred from its initialization. (lint/style/noInferrableTypes)

Safe fix: Remove the type annotation.

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

Line range hint 1-1: Use type imports for Playwright types to optimize bundle size.

- import { Page, expect } from '@playwright/test';
+ import type { Page, expect } from '@playwright/test';
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (2)

Line range hint 69-69: Avoid using non-null assertions.

It's generally safer to handle potential null or undefined values explicitly rather than using non-null assertions. This can help prevent runtime errors if unexpected null or undefined values occur.

Also applies to: 70-70, 71-71, 78-78, 116-116, 122-122, 137-137, 138-138, 145-145, 146-146, 153-153, 154-154, 156-156, 172-172, 176-176


Line range hint 89-89: Specify a more explicit type instead of any.

Using any can lead to potential bugs and maintenance issues as it bypasses TypeScript's static type checking. If possible, define a more specific type or interface.

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

Line range hint 2-3: Use import type for type-only imports.

- import { LoginPage } from './pageobjects/LoginPage';
- import { UserCredentials } from './users';
+ import type { LoginPage } from './pageobjects/LoginPage';
+ import type { UserCredentials } from './users';

This change ensures that these imports are used for types only and are erased during compilation, which can help optimize the bundle size.

@iyannsch iyannsch self-requested a review June 4, 2024 17:03
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.

Some tests seems to be failing on Playwright github action

@muradium
Copy link
Contributor Author

muradium commented Jun 4, 2024

Some tests seems to be failing on Playwright github action

Do you mean the Multi-Node build? Many tests consistently fail there, probably due to builds running too slowly. But we haven't decided on how to fix them yet.

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.

Code lgtm!
Tests are passing on CI,

However, when I try to run e2e/exam/ExamResults.spec.ts, this test fails e2e\exam\ExamResults.spec.ts:126:21 › Exam Results › Check exam exercise results › Check exam results for programming exercise › Check exam programming exercise results.
This may be OS dependant or due to my setup. I am using windows

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.

The issue previously mentioned is probably due to my setup.
Tests are passing on CI.

@muradium
Copy link
Contributor Author

muradium commented Jun 8, 2024

Current test failures on Bamboo build are solved by #8764

@krusche krusche added this to the 7.2.0 milestone Jun 8, 2024
@krusche krusche changed the title General: Fix flaky e2e tests involving automatic exercise assessments Development: Fix flaky playwright e2e tests involving automatic exercise assessments Jun 8, 2024
@krusche krusche merged commit 5bb7194 into develop Jun 8, 2024
31 of 33 checks passed
@krusche krusche deleted the feature/playwright/fix-flaky-exam-result-tests branch June 8, 2024 19:25
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!) ready for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants