-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files📢 Thoughts on this report? Let us know! |
Bundle ReportChanges will decrease total bundle size by 1.37kB (-0.0%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
There was a problem hiding this 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
📒 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!
There was a problem hiding this 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 methodhandleDidUpdateTestsStatus
addedThe 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:
- Consider adding a brief comment explaining the method's purpose.
- Replace the magic strings 'evaluating' and 'passed' with constants or an enum for better maintainability.
- 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
📒 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 correctlyThe import of
next
from '@ember/runloop' is correctly placed and necessary for the new functionality inhandleDidUpdateTestsStatus
.
Line range hint
1-114
: Overall assessment: Well-implemented changesThe 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.
Summary by CodeRabbit