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

CC-1539: Fix start-track button #2511

Merged
merged 2 commits into from
Jan 3, 2025
Merged

CC-1539: Fix start-track button #2511

merged 2 commits into from
Jan 3, 2025

Conversation

andy1li
Copy link
Member

@andy1li andy1li commented Dec 31, 2024

Clear repo in queryParams, so that previously created repos won't interfere with the result of clicking Start Track button again.

Checklist:

  • I've thoroughly self-reviewed my changes
  • I've added tests for my changes, unless they affect admin-only areas (or are otherwise not worth testing)
  • I've verified any visual changes using Percy (add a commit with [percy] in the message to trigger)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced routing behavior for starting a track, now including additional query parameters for non-anonymous users.
    • Added acceptance tests to verify the visibility and behavior of the "start track" button under various user scenarios.
    • Introduced methods to interact with the "start track" button in the testing framework.
  • Bug Fixes

    • Improved identifier for the "start track" button to ensure accurate testing.

Updated the start-track-button component to include a 'repo' query param when transitioning to the course route if the user is not anonymous. This change allows for better handling of repository information in the transition.
@andy1li andy1li self-assigned this Dec 31, 2024
Copy link

linear bot commented Dec 31, 2024

Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request introduces modifications to the handleClicked method in the CourseOverviewStartTrackButtonComponent class, updating the routing behavior for non-anonymous users by adding a new repo query parameter set to null. Additionally, it changes the identifier for the "start track" button in the template for testing purposes. New acceptance tests are added to validate the button's visibility and behavior under various user scenarios, and enhancements to the page object facilitate interaction with the button.

Changes

File Change Summary
app/components/track-page/start-track-button.ts Modified handleClicked method to include an additional repo: null query parameter during route transition for non-anonymous users.
app/components/track-page/start-track-button.hbs Changed data-test-start-track-button attribute to data-test-primary-start-track-button in PrimaryButton component.
tests/acceptance/track-page/start-track-test.js Added new acceptance test suite for track page with tests for button visibility and behavior across different user scenarios.
tests/pages/track-page.js Introduced clickOnStartTrackButton method and hasStartTrackButton property for interacting with and checking the visibility of the start track button.

Possibly related PRs

  • Add dark mode toggle #2039: The changes in this PR introduce a dark mode toggle, which is directly related to the modifications made in the main PR regarding the handling of dark mode features and user interface adjustments.
  • Add extensions dark mode styles #2045: This PR enhances dark mode styles across various components, which aligns with the changes in the main PR that also focus on improving the visual presentation and accessibility of components in dark mode.

Poem

🐰 A rabbit's routing tale unfolds,
With query params, new and bold.
repo joins the journey's track,
A null companion on the way back.
Navigating paths with subtle grace, 🚀
Our button shines in its new place!

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

🧹 Nitpick comments (1)
app/components/track-page/start-track-button.ts (1)

33-33: Consider adding a fallback if this.args.courses is empty.
While the non-null assertion ! indicates that you expect this.args.courses to contain at least one course, it can throw errors if that ever changes. For robustness, consider adding a check for an empty array to prevent errors in edge cases.

You could handle this more defensively, for example:

 @action
 handleClicked() {
   if (this.currentUserIsAnonymous) {
     this.authenticator.initiateLogin(null);
   } else {
+    if (!this.args.courses?.length) {
+      // Fallback: either return early or handle the missing course scenario
+      return;
+    }
     this.router.transitionTo('course', this.args.courses[0]!.slug, {
       queryParams: { repo: null, track: this.args.language.slug },
     });
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8fae04 and bd36fa6.

📒 Files selected for processing (1)
  • app/components/track-page/start-track-button.ts (1 hunks)

Copy link

github-actions bot commented Dec 31, 2024

Test Results

  1 files  ±0    1 suites  ±0   7m 11s ⏱️ -7s
595 tests +4  554 ✅ +4  41 💤 ±0  0 ❌ ±0 
610 runs  +4  569 ✅ +4  41 💤 ±0  0 ❌ ±0 

Results for commit 1d0c32a. ± Comparison against base commit e8fae04.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Dec 31, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
598 3 595 0
View the top 3 failed tests by shortest run time
Chrome 131.0 Acceptance | view-courses: it renders if user is not signed in
Stack Traces | 0.266s run time
No failure message available
Chrome 131.0 Acceptance | view-badges: it renders when all badges are unearned
Stack Traces | 1.18s run time
No failure message available
Chrome 131.0 Acceptance | course-page | course-stage-solutions: can view solution
Stack Traces | 1.74s run time
No failure message available

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

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

🧹 Nitpick comments (4)
tests/acceptance/track-page/start-track-test.js (4)

11-16: Grammar Improvement in Test Title

The test name "it display the start-track-button" can be phrased in a more grammatically correct way, e.g. "it displays the start-track-button…”.

- test('it display the start-track-button for anonymous user', async function (assert) {
+ test('it displays the start-track-button for anonymous user', async function (assert) {

18-24: Custom Assertions

Consider adding an additional assertion after a button click to ensure it behaves correctly for a logged-in user who has not started any course in the track, confirming that it transitions correctly to the next page or step.


26-41: Informative Happy Path Test

It might be valuable to also verify that subsequent visits or actions (like re-clicking the button) do not incorrectly re-initiate the track or re-insert the repo query param. This helps guard against regressions.


43-62: Ensuring Clarity on Query Params

The line:

assert.notOk(currentURL().includes('repo='));

correctly confirms that the repo query param is not present. Consider an explicit assertion or comment describing the significance of removing repo, since it’s closely tied to the root cause of the original bug.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd36fa6 and 1d0c32a.

📒 Files selected for processing (3)
  • app/components/track-page/start-track-button.hbs (1 hunks)
  • tests/acceptance/track-page/start-track-test.js (1 hunks)
  • tests/pages/track-page.js (1 hunks)
🔇 Additional comments (3)
app/components/track-page/start-track-button.hbs (1)

1-1: Consistent Test Identifier Update

Changing the attribute to data-test-primary-start-track-button looks consistent with the naming used in the tests. Ensure that any references to the older identifier across the codebase and tests are fully updated.

tests/pages/track-page.js (2)

16-16: Good Addition

Using a dedicated clickable property for the "start track" button helps keep the test code expressive and maintainable. This approach aligns well with page object best practices.


18-18: Visibility Check is Great

Introducing hasStartTrackButton provides a clear way to assert the button's presence. This is a straightforward solution that keeps the test code concise.

@andy1li andy1li merged commit d05b946 into main Jan 3, 2025
8 of 9 checks passed
@andy1li andy1li deleted the andy/fix branch January 3, 2025 10:45
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.

2 participants