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

Switch test runner card position after tests pass #2334

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

rohitpaulk
Copy link
Member

@rohitpaulk rohitpaulk commented Oct 18, 2024

  • fix dark mode hover effect
  • Add NonExpandableStep component and refactor ExpandableStepList logic.
  • Remove shadow-sm class from SVG and text in non-expandable-step component.
  • Update non-expandable step styles for improved visibility and clarity.
  • Update non-expandable step styles and add amber color to Tailwind config.
  • Fix data-test attribute in non-expandable step and update condition in step.ts.
  • Refactor TestRunnerCard visibility logic based on testsStatus in templates.

Summary by CodeRabbit

  • New Features
    • Enhanced display logic for the TestRunnerCard based on test status in the course instructions.
    • Introduced conditional rendering for the TestRunnerCard based on the current step's test status.
  • Bug Fixes
    • Simplified scrolling behavior for the TestRunnerCard to only trigger on 'evaluating' status.

Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request modifies the TestRunnerCardComponent by removing the handleDidUpdateTestsStatus method and associated scrolling logic, simplifying state management. A new method is introduced in the CourseStageInstructionsController to handle updates to tests status, which includes scrolling the test runner card into view. Additionally, the instructions.hbs template is updated to conditionally render the TestRunnerCard based on the current step's tests status and a new property, enhancing the control flow for its display.

Changes

File Path Change Summary
app/components/course-page/course-stage-step/... Removed did-update modifier and handleDidUpdateTestsStatus method; simplified state management in TestRunnerCardComponent.
app/controllers/course/stage/instructions.ts Added handleDidUpdateTestsStatus method to manage test status updates and scrolling behavior.
app/templates/course/stage/instructions.hbs Updated to include new did-update modifier and conditional rendering for TestRunnerCard.

Possibly related PRs

🐰 In the land of code where bunnies hop,
A card for tests, it won’t stop!
With conditions clear, it now will show,
Only when the tests are ready to glow.
Scrolls are simplified, oh what a cheer,
For every step, the path is now clear! 🐇✨


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

CodeRabbit Configuration 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

github-actions bot commented Oct 18, 2024

Test Results

  1 files  ±0    1 suites  ±0   6m 31s ⏱️ +7s
574 tests ±0  538 ✅ ±0  36 💤 ±0  0 ❌ ±0 
589 runs  ±0  553 ✅ ±0  36 💤 ±0  0 ❌ ±0 

Results for commit 399a020. ± Comparison against base commit 023efa7.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/controllers/course/stage/instructions.ts 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Oct 18, 2024

Bundle Report

Changes will decrease total bundle size by 1.37kB (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
client-array-push 35.76MB 1.37kB (-0.0%) ⬇️

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
app/templates/course/stage/instructions.hbs (2)

20-28: LGTM! Consider adding a comment for clarity.

The new conditional block for displaying the TestRunnerCard when tests are passed is well-implemented. It aligns with the PR objectives and improves the control flow. The non-collapsible state and upscroll behavior are appropriate for this scenario.

Consider adding a brief comment explaining the purpose of this block, such as:

{{!-- Display non-collapsible TestRunnerCard when tests are passed --}}
{{#if (and this.shouldShowTestRunnerCard (eq this.currentStep.testsStatus "passed"))}}
  ...
{{/if}}

This would enhance code readability and maintainability.


42-42: LGTM! Consider using consistent syntax for improved readability.

The updated condition for displaying the TestRunnerCard when tests are not passed is correct and aligns with the PR objectives. It complements the new block added earlier, ensuring appropriate visibility logic based on the test status.

For consistency with the earlier block, consider using the same syntax for the condition:

{{#if (and this.shouldShowTestRunnerCard (not (eq this.currentStep.testsStatus "passed")))}}

This makes the two conditions more visually similar and easier to compare.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 023efa7 and 7ce27b4.

📒 Files selected for processing (2)
  • app/components/course-page/course-stage-step/test-runner-card.ts (0 hunks)
  • app/templates/course/stage/instructions.hbs (2 hunks)
💤 Files with no reviewable changes (1)
  • app/components/course-page/course-stage-step/test-runner-card.ts
🧰 Additional context used
🔇 Additional comments (1)
app/templates/course/stage/instructions.hbs (1)

Line range hint 20-71: Overall, the changes look good and align with the PR objectives.

The modifications to the TestRunnerCard visibility logic enhance the control flow and user experience. The new conditional block for passed tests and the updated block for other test statuses work well together to provide appropriate displays based on the current step's test status.

The implementation is sound, with only minor suggestions for improved clarity and consistency. Great job on refactoring this component!

@rohitpaulk rohitpaulk changed the title expandable list hover effect Switch test runner card position after tests pass Oct 18, 2024
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
app/controllers/course/stage/instructions.ts (1)

72-85: LGTM with suggestions: New method handleDidUpdateTestsStatus added

The new method handleDidUpdateTestsStatus is well-implemented and aligns with the PR objectives. It correctly handles updates to the tests status and manages scrolling behavior. Here are a few suggestions for improvement:

  1. Consider adding a brief comment explaining the method's purpose.
  2. Replace the magic strings 'evaluating' and 'passed' with constants or an enum for better maintainability.
  3. If the elements with IDs 'test-runner-card' and 'course-page-scrollable-area' are frequently accessed, consider storing them as class properties to optimize performance.

Here's an example of how you might implement these suggestions:

// Constants for test status
const TEST_STATUS = {
  EVALUATING: 'evaluating',
  PASSED: 'passed',
} as const;

export default class CourseStageInstructionsController extends Controller {
  // ... existing code ...

  // Cache DOM elements
  testRunnerCard: HTMLElement | null = null;
  coursePageScrollableArea: HTMLElement | null = null;

  constructor() {
    super(...arguments);
    this.testRunnerCard = document.getElementById('test-runner-card');
    this.coursePageScrollableArea = document.getElementById('course-page-scrollable-area');
  }

  /**
   * Handles updates to the tests status and manages scrolling behavior
   * based on the new status.
   */
  @action
  handleDidUpdateTestsStatus(_element: HTMLDivElement, [newTestsStatus]: [CourseStageStep['testsStatus']]) {
    if (newTestsStatus === TEST_STATUS.EVALUATING) {
      // Ensure the new test runner card is in DOM (it shifts around when the tests status changes)
      next(() => {
        this.testRunnerCard?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
      });
    }

    // For tests passed, let's scroll all the way to the top
    if (newTestsStatus === TEST_STATUS.PASSED) {
      this.coursePageScrollableArea?.scrollTo({ top: 0, behavior: 'smooth' });
    }
  }

  // ... rest of the class ...
}

This refactored version improves code readability, maintainability, and potentially performance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7ce27b4 and 399a020.

📒 Files selected for processing (4)
  • app/components/course-page/course-stage-step/test-runner-card.hbs (0 hunks)
  • app/components/course-page/course-stage-step/test-runner-card.ts (0 hunks)
  • app/controllers/course/stage/instructions.ts (2 hunks)
  • app/templates/course/stage/instructions.hbs (3 hunks)
💤 Files with no reviewable changes (2)
  • app/components/course-page/course-stage-step/test-runner-card.hbs
  • app/components/course-page/course-stage-step/test-runner-card.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/templates/course/stage/instructions.hbs
🧰 Additional context used
🔇 Additional comments (2)
app/controllers/course/stage/instructions.ts (2)

11-11: LGTM: New import added correctly

The import of next from '@ember/runloop' is correctly placed and necessary for the new functionality in handleDidUpdateTestsStatus.


Line range hint 1-114: Overall assessment: Well-implemented changes

The changes in this file successfully implement the new functionality for handling test status updates and managing scrolling behavior. The new handleDidUpdateTestsStatus method aligns with the PR objectives and enhances the user experience. The code is well-structured and follows good practices, with only minor suggestions for improvement.

@rohitpaulk rohitpaulk merged commit d70e0c9 into main Oct 18, 2024
7 of 9 checks passed
@rohitpaulk rohitpaulk deleted the expandable-list-hover-effect branch October 18, 2024 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant