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

Add tests for Demo route and components on it #1977

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

VasylMarchuk
Copy link
Collaborator

@VasylMarchuk VasylMarchuk commented Jul 16, 2024

Related to #1231 #1415

Brief

This adds a bunch of tests for the Demo route, and also for components currently included on it.

Details

  • added/improved proper page objects for the following components:
    • CodeMirror
    • DarkModeToggle
    • FileContentsCard
  • added/improved proper page objects for the following pages:
    • CoursePage
    • DemoPage
  • added tests for the Demo route itself
  • added tests for Demo > CodeMirror
    • only testing visiting the route, doing nothing on it
    • CodeMirror component has it's own integration tests
  • added tests for Demo > DarkModeToggle (visiting and clicking on things)
  • added tests for Demo > FileContentsCard (visiting and clicking on things)
  • merged course-admin | view-code-example test into course-page | view-code-examples

Included tests

Знімок екрана 2024-07-16 о 21 01 09

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

  • New Features

    • Introduced structural enhancements to the FileContentsCard and dark mode toggle components for better layout organization and improved styling potential.
    • Added data-test attributes to various components for improved testability.
  • Bug Fixes

    • Enhanced the layout and semantic structure of multiple components, improving overall user experience.
  • Tests

    • Enhanced testability of the FileContentsCard component and other components by adding new data attributes.
    • Added new test cases to validate functionality across the demo page and established comprehensive test suites for viewing unchanged files in code examples and validating dark mode toggle interactions.

Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Warning

Rate limit exceeded

@VasylMarchuk has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 31 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 58ffdf0 and 1f782bb.

Walkthrough

The updates enhance the structure and testability of components in an Ember.js application, improving layout without disrupting core functionality. Key changes include adding data-test attributes for easier testing, restructuring templates for improved styling, and introducing acceptance tests to cover interactions such as viewing unchanged files and toggling dark mode. This results in a more reliable user experience and a robust testing framework.

Changes

File(s) Change Summary
app/components/... Restructured templates with new wrappers to enhance layout and styling while maintaining core functionalities, including FileContentsCard and DarkModeToggle.
app/templates/demo.hbs, app/templates/demo/dark-mode-toggle.hbs Introduced data-test attributes to boost testing reliability for demo templates, enabling better identification during automated testing.
app/components/file-contents-card.hbs Added data-test attributes to improve testability of interactive elements, enhancing the component's effectiveness in tests.
tests/acceptance/... Implemented new acceptance tests for various components, ensuring comprehensive coverage of functionality and interactions throughout the application.
tests/pages/course-page.js Updated component references to reflect changes in the test environment, enhancing clarity and functionality concerning unchanged files.
tests/pages/demo-page.ts, tests/pages/components/... Introduced new page objects to streamline testing processes, improving maintainability and readability of test code.

Poem

In a world where shadows play,
The dark mode shines bright as day.
Cards of content, wrapped with care,
Testing ensures they’re always fair.
With each update, our code will gleam,
Together we build the perfect dream.
🐇✨


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 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 Jul 16, 2024

Test Results

  1 files  ± 0    1 suites  ±0   5m 58s ⏱️ - 1m 15s
564 tests +11  529 ✅ +11  35 💤 ±0  0 ❌ ±0 
579 runs  +11  544 ✅ +11  35 💤 ±0  0 ❌ ±0 

Results for commit 1f782bb. ± Comparison against base commit f92f666.

This pull request removes 3 and adds 14 tests. Note that renamed tests count towards both.
Chrome 126.0 ‑ Acceptance | course-admin | view-code-example: can view code example
Chrome 126.0 ‑ Acceptance | view demo page > CodeMirror: visiting /demo/code-mirror renders a CodeMirror editor
Chrome 126.0 ‑ Acceptance | view demo page: visiting /demo redirects to /demo/code-mirror
Chrome 126.0 ‑ Acceptance | course-page | view-code-examples: can view unchanged files in code examples
Chrome 126.0 ‑ Acceptance | demo page | code-mirror: it works
Chrome 126.0 ‑ Acceptance | demo page | dark-mode-toggle: it adds a '.dark' class to application container when Dark mode is active
Chrome 126.0 ‑ Acceptance | demo page | dark-mode-toggle: it shows current localStorage preference
Chrome 126.0 ‑ Acceptance | demo page | dark-mode-toggle: it shows current system preference
Chrome 126.0 ‑ Acceptance | demo page | dark-mode-toggle: it updates localStorage preference after clicking on mode-switching buttons
Chrome 126.0 ‑ Acceptance | demo page | dark-mode-toggle: it works
Chrome 126.0 ‑ Acceptance | demo page | file-contents-card: it allows toggling 'foldGutter' option
Chrome 126.0 ‑ Acceptance | demo page | file-contents-card: it allows toggling 'headerTooltipText' option
Chrome 126.0 ‑ Acceptance | demo page | file-contents-card: it allows toggling `isCollapsible` option
…

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Jul 16, 2024

Bundle Report

Changes will decrease total bundle size by 1.23kB ⬇️

Bundle name Size Change
client-array-push 35.27MB 1.23kB ⬇️

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, codebase verification and nitpick comments (2)
tests/pages/course-page.js (2)

18-18: Updated import from CodeMirror to FileContentsCard.

The search results indicate that CodeMirror is still actively referenced in various test files. Ensure that all references to CodeMirror are updated or removed as needed across the project to maintain consistency.

  • Files with CodeMirror references:
    • tests/integration/components/code-mirror-test.js
    • tests/acceptance/demo-page-test.js
    • tests/acceptance/demo-page/file-contents-card-test.js
    • tests/acceptance/demo-page/code-mirror-test.js
    • tests/acceptance/course-page/view-code-examples-test.js
Analysis chain

Updated import from CodeMirror to FileContentsCard.

This change aligns with the PR's focus on enhancing page objects for specific components. Ensure that all references to CodeMirror are updated or removed as needed across the project.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to `CodeMirror` are updated or removed.

# Test: Search for `CodeMirror` in the codebase. Expect: No occurrences or only occurrences related to other contexts.
rg --type python -A 5 $'CodeMirror'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify that all references to `CodeMirror` are updated or removed.

# Test: Search for `CodeMirror` in the codebase. Expect: No occurrences or only occurrences related to other contexts.
rg --type js -A 5 $'CodeMirror'

Length of output: 27000


58-58: Replaced clickOnExpandButton with fileContentsCard.

The refactoring to replace clickOnExpandButton with fileContentsCard is not fully complete. There are still instances of clickOnExpandButton in the course-page tests that need to be updated or deprecated. Please ensure that all occurrences are replaced with fileContentsCard to avoid breaking existing functionality.

  • tests/acceptance/course-page/view-code-examples-test.js
  • tests/acceptance/course-page/language-guides-test.js
Analysis chain

Replaced clickOnExpandButton with fileContentsCard.

This change seems to be part of the refactoring to use more descriptive and component-specific page objects. Confirm that this change does not break existing functionality and that all tests relying on the previous clickOnExpandButton method are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all tests relying on the previous `clickOnExpandButton` method are updated.

# Test: Search for `clickOnExpandButton` in the test files. Expect: No occurrences or only occurrences that are commented out or deprecated.
rg --type python -A 5 $'clickOnExpandButton'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify that all tests relying on the previous `clickOnExpandButton` method are updated.

# Test: Search for `clickOnExpandButton` in the test files. Expect: No occurrences or only occurrences that are commented out or deprecated.
rg 'clickOnExpandButton'

Length of output: 688


Script:

#!/bin/bash
# Description: Verify that `fileContentsCard` is being used in the test files.

# Test: Search for `fileContentsCard` in the test files.
rg 'fileContentsCard'

Length of output: 9297

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e27dd2 and aca42de.

Files selected for processing (16)
  • app/components/course-page/course-stage-step/community-solution-card/content.hbs (1 hunks)
  • app/components/dark-mode-toggle.hbs (1 hunks)
  • app/components/file-contents-card.hbs (3 hunks)
  • app/templates/demo.hbs (1 hunks)
  • app/templates/demo/dark-mode-toggle.hbs (1 hunks)
  • tests/acceptance/course-page/view-code-examples-test.js (1 hunks)
  • tests/acceptance/demo-page-test.js (1 hunks)
  • tests/acceptance/demo-page/code-mirror-test.js (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
  • tests/acceptance/demo-page/file-contents-card-test.js (1 hunks)
  • tests/integration/components/code-mirror-test.js (1 hunks)
  • tests/pages/components/code-mirror.ts (2 hunks)
  • tests/pages/components/dark-mode-toggle.ts (1 hunks)
  • tests/pages/components/file-contents-card.ts (1 hunks)
  • tests/pages/course-page.js (2 hunks)
  • tests/pages/demo-page.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/templates/demo/dark-mode-toggle.hbs
Additional comments not posted (18)
tests/pages/components/dark-mode-toggle.ts (1)

1-14: Well-structured page object model for Dark Mode Toggle

The page object model is well-structured and follows Ember's conventions. The methods findOptionButtonByText and clickOnOptionButton are clear and should function correctly provided that the buttons collection is accurately defined with the correct selector.

app/components/dark-mode-toggle.hbs (1)

1-11: Template restructuring in dark-mode-toggle.hbs

The move of the <dark-mode-toggle> component wrapper outside the <each> block is a significant change. This should ensure that the toggle functionality is applied consistently across all preference buttons. It's important to verify that this change does not introduce any side effects, particularly in terms of event handling and state management within the component.

tests/acceptance/demo-page/code-mirror-test.js (1)

1-18: Comprehensive tests for the CodeMirror component on the Demo page

The tests provided are well-structured and cover both navigation and rendering aspects of the CodeMirror component. The use of currentURL() and hasRendered checks are appropriate and should effectively validate the functionality of the component within the Demo route.

tests/pages/components/file-contents-card.ts (1)

1-34: Well-implemented page object model for File Contents Card

The page object model for the File Contents Card is comprehensive, covering various interactions such as clicking, hovering, and text retrieval. The use of clickable, triggerable, and text from ember-cli-page-object is appropriate and should facilitate robust testing of the component.

tests/pages/components/code-mirror.ts (3)

9-27: Enhanced structure for editor.scroller

The nested structure under editor.scroller with gutters, lineNumbers, and foldGutter is well-organized and follows a logical hierarchy. This should improve the maintainability and readability of the component's page object.


50-55: New method setLineText implementation

The implementation of setLineText to focus, click, fill in, and blur a line is a robust way to interact with the CodeMirror component programmatically. This addition should facilitate more precise testing scenarios.


42-42: Check for potential duplication of componentText

The componentText property has been moved outside the editor section. Ensure that this move does not duplicate or conflict with similar properties elsewhere in the component or application.

Verification successful

No duplication of componentText found

The componentText property is unique within the tests/pages/components directory and does not conflict with other properties.

  • tests/pages/components/code-mirror.ts: componentText: text()
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for potential duplication of `componentText` in other components.

# Test: Search for `componentText` usage. Expect: Unique occurrences in the context of CodeMirror.
rg --type typescript 'componentText' -- 'tests/pages/components'

Length of output: 97


Script:

#!/bin/bash
# Description: Search for potential duplication of `componentText` in other components.

# Test: Search for `componentText` usage. Expect: Unique occurrences in the context of CodeMirror.
rg 'componentText' --glob 'tests/pages/components/*.ts'

Length of output: 118

tests/acceptance/demo-page-test.js (1)

6-34: Comprehensive tests for the Demo page

The tests cover various scenarios including redirection, tab presence, default active tab, and tab switching functionality. These tests are well-structured and appear to cover the intended behaviors effectively.

app/templates/demo.hbs (1)

11-11: Addition of data-test-demo-tab-switcher

Adding the data-test-demo-tab-switcher attribute enhances the testability of the tab switcher component. This is a good practice for facilitating more targeted and reliable tests.

tests/pages/demo-page.ts (1)

6-69: Well-structured page objects for the Demo page

The page objects for tabSwitcher and demoTabs are well-defined. Methods like findTabByText and clickOnTab are implemented correctly, facilitating easy interaction with the UI components. This structure should support robust and maintainable tests.

app/components/file-contents-card.hbs (3)

3-3: Added data attributes for component testing.

Adding data-test-file-contents-card-component enhances the testability of the component, allowing for more robust integration and end-to-end tests.


27-32: Enhanced interactive elements for expand/collapse functionality.

The addition of data-test-file-contents-card-header-hover-target on the hover target and specific data attributes on the Pill components (data-test-file-contents-card-header-expand-button and data- test-file-contents-card-header-collapse-button) improves the testability and accessibility of these interactive elements.


66-66: Added data attribute to collapse button.

The data-test-file-contents-card-collapse-button attribute on the TertiaryButton component will aid in more precise targeting during automated testing, ensuring that functionality related to collapsing the file content is easily testable.

app/components/course-page/course-stage-step/community-solution-card/content.hbs (1)

57-84: Reorganized layout within the FileContentsCard component.

Moving the <div class="contents"> outside the FileContentsCard component and adjusting the nesting of elements within it appears to be aimed at improving the structural clarity and possibly the styling of the component. Ensure this change aligns with the intended visual and functional requirements of the application.

Verification successful

Review the test cases for FileContentsCard to ensure coverage of recent changes.

The search results indicate that the FileContentsCard component is tested in various files. To ensure that the reorganization of the layout within this component does not break existing functionality or visual requirements, review the following test files:

  • tests/pages/course-page.js
  • tests/acceptance/course-page/view-code-examples-test.js
  • tests/acceptance/demo-page-test.js
  • tests/acceptance/demo-page/file-contents-card-test.js

Verify that these tests cover the visual and functional aspects of the FileContentsCard component, especially in the context of the changes made.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the visual and functional requirements of the reorganized layout.
# Test: Search for CSS or JS that might be affected by the layout change.
rg --type css --type js 'FileContentsCard'

Length of output: 944

tests/acceptance/demo-page/dark-mode-toggle-test.js (1)

1-82: Comprehensive tests added for DarkModeToggle component.

The tests cover various scenarios including URL correctness, component rendering, localStorage preference handling, and system preference interaction. These tests are well-structured and appear to cover the critical functionalities of the DarkModeToggle component effectively.

tests/acceptance/demo-page/file-contents-card-test.js (1)

1-116: Comprehensive tests added for FileContentsCard component.

The tests thoroughly cover the collapsibility feature, interaction with different component options like isCollapsible, scrollIntoViewOnCollapse, headerTooltipText, and foldGutter. These tests are structured to validate both the presence and absence of UI elements based on the component state, ensuring robust behavior under various scenarios.

tests/integration/components/code-mirror-test.js (1)

84-84: Simplified interaction with CodeMirror by directly setting text.

This change improves the clarity and reliability of tests by directly setting the text content of a line. Ensure that all related tests are updated to reflect this new method of interaction and verify that it does not introduce regressions in the behavior of the CodeMirror component.

Verification successful

Simplified interaction with CodeMirror by directly setting text.

This change improves the clarity and reliability of tests by directly setting the text content of a line. The search results confirm that the new method setLineText is used in the tests. Ensure that all instances where text is set in CodeMirror use this method to maintain consistency and avoid regressions.

  • tests/integration/components/code-mirror-test.js uses await codeMirror.setLineText(0, 'New Content');.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all related tests are updated and check for regressions.

# Test: Search for tests related to `CodeMirror` interaction. Expect: All tests should use the new method for setting text.
rg --type python -A 5 $'CodeMirror'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify that all related tests are updated and check for regressions.

# Test: Search for tests related to `CodeMirror` interaction. Expect: All tests should use the new method for setting text.
rg --type js -A 5 'CodeMirror'

Length of output: 27000

tests/acceptance/course-page/view-code-examples-test.js (1)

173-200: Added test for viewing unchanged files in code examples.

This test enhances coverage by verifying the functionality of viewing unchanged files within code examples. Ensure the test setup accurately reflects the intended user interactions and that all assertions are correctly validating the expected UI elements and content.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aca42de and 07c6085.

Files selected for processing (2)
  • tests/acceptance/demo-page-test.js (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tests/acceptance/demo-page-test.js
  • tests/acceptance/demo-page/dark-mode-toggle-test.js

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 07c6085 and 0c4f9cc.

Files selected for processing (1)
  • app/components/dark-mode-toggle.hbs (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/components/dark-mode-toggle.hbs

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0c4f9cc and a15471b.

Files selected for processing (3)
  • app/components/course-page/course-stage-step/community-solution-card/content.hbs (1 hunks)
  • app/components/dark-mode-toggle.hbs (1 hunks)
  • app/components/file-contents-card.hbs (3 hunks)
Files skipped from review due to trivial changes (2)
  • app/components/course-page/course-stage-step/community-solution-card/content.hbs
  • app/components/file-contents-card.hbs
Files skipped from review as they are similar to previous changes (1)
  • app/components/dark-mode-toggle.hbs

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

Outside diff range, codebase verification and nitpick comments (3)
tests/acceptance/demo-page/dark-mode-toggle-test.js (3)

8-12: Consider adding error handling.

The setLocalStoragePreference function lacks error handling, which could be useful to catch potential issues with the run loop.

function setLocalStoragePreference(darkModeService, preference) {
  run(() => {
    try {
      darkModeService.localStoragePreference = preference;
    } catch (error) {
      console.error('Error setting localStoragePreference:', error);
    }
  });
}

14-18: Consider adding error handling.

The setSystemPreference function lacks error handling, which could be useful to catch potential issues with the run loop.

function setSystemPreference(darkModeService, preference) {
  run(() => {
    try {
      darkModeService.systemPreference = preference;
    } catch (error) {
      console.error('Error setting systemPreference:', error);
    }
  });
}

24-28: Consider adding more assertions.

The it works test could benefit from additional assertions to verify the initial state of the component.

test('it works', async function (assert) {
  await demoPage.demoTabs.darkModeToggle.visit();
  assert.strictEqual(currentURL(), '/demo/dark-mode-toggle', 'URL is correct');
  assert.ok(demoPage.demoTabs.darkModeToggle.component.isVisible, 'component has rendered');
+ assert.strictEqual(demoPage.demoTabs.darkModeToggle.currentLocalStoragePreference.text, 'null', 'localStorage preference is null by default');
+ assert.strictEqual(demoPage.demoTabs.darkModeToggle.currentSystemPreference.text, '', 'system preference is empty by default');
});
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between af03460 and a2d6c42.

Files selected for processing (3)
  • app/templates/application.hbs (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
  • tests/pages/demo-page.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/templates/application.hbs
Files skipped from review as they are similar to previous changes (1)
  • tests/pages/demo-page.ts
Additional context used
Biome
tests/acceptance/demo-page/dark-mode-toggle-test.js

[error] 65-87: This code is unreachable

... because this statement will throw an exception beforehand

(lint/correctness/noUnreachable)

Additional comments not posted (3)
tests/acceptance/demo-page/dark-mode-toggle-test.js (3)

30-38: LGTM!

The it shows current localStorage preference test is comprehensive and correct.


41-46: LGTM!

The it shows current system preference test is comprehensive and correct.


49-57: LGTM!

The it updates localStorage preference after clicking on mode-switching buttons test is comprehensive and correct.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a2d6c42 and 6c322b0.

Files selected for processing (3)
  • app/templates/application.hbs (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
  • tests/pages/demo-page.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/templates/application.hbs
Files skipped from review as they are similar to previous changes (1)
  • tests/pages/demo-page.ts
Additional context used
Biome
tests/acceptance/demo-page/dark-mode-toggle-test.js

[error] 65-87: This code is unreachable

... because this statement will throw an exception beforehand

(lint/correctness/noUnreachable)

Additional comments not posted (6)
tests/acceptance/demo-page/dark-mode-toggle-test.js (6)

8-11: LGTM!

The function setLocalStoragePreference correctly sets the localStoragePreference using the run loop.


14-17: LGTM!

The function setSystemPreference correctly sets the systemPreference using the run loop.


24-28: LGTM!

The test case it works correctly verifies the component's visibility and URL.


30-38: LGTM!

The test case it shows current localStorage preference correctly sets and verifies the localStoragePreference for different values.


41-46: LGTM!

The test case it shows current system preference correctly sets and verifies the systemPreference for different values.


49-57: LGTM!

The test case it updates localStorage preference after clicking on mode-switching buttons correctly verifies the localStoragePreference after interacting with the mode-switching buttons.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c322b0 and 594af31.

Files selected for processing (3)
  • app/templates/application.hbs (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
  • tests/pages/demo-page.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/templates/application.hbs
Files skipped from review as they are similar to previous changes (1)
  • tests/pages/demo-page.ts
Additional context used
Biome
tests/acceptance/demo-page/dark-mode-toggle-test.js

[error] 65-87: This code is unreachable

... because this statement will throw an exception beforehand

(lint/correctness/noUnreachable)

Additional comments not posted (7)
tests/acceptance/demo-page/dark-mode-toggle-test.js (7)

1-6: Imports look good.

The necessary modules and helpers for testing are correctly imported.


8-12: Helper function setLocalStoragePreference looks good.

The function correctly sets the localStoragePreference of the darkModeService using the run loop.


14-18: Helper function setSystemPreference looks good.

The function correctly sets the systemPreference of the darkModeService using the run loop.


24-28: Test case it works looks good.

The test case correctly verifies the rendering of the DarkModeToggle component.


30-39: Test case it shows current localStorage preference looks good.

The test case correctly sets and verifies the localStoragePreference using the helper function.


41-47: Test case it shows current system preference looks good.

The test case correctly sets and verifies the systemPreference using the helper function.


49-58: Test case it updates localStorage preference after clicking on mode-switching buttons looks good.

The test case correctly simulates user interactions and verifies the localStoragePreference.

tests/acceptance/demo-page/dark-mode-toggle-test.js Outdated Show resolved Hide resolved
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 594af31 and 58ffdf0.

Files selected for processing (14)
  • app/components/file-contents-card.hbs (3 hunks)
  • app/templates/application.hbs (1 hunks)
  • app/templates/demo.hbs (1 hunks)
  • app/templates/demo/dark-mode-toggle.hbs (1 hunks)
  • tests/acceptance/course-page/view-code-examples-test.js (1 hunks)
  • tests/acceptance/demo-page-test.js (1 hunks)
  • tests/acceptance/demo-page/code-mirror-test.js (1 hunks)
  • tests/acceptance/demo-page/dark-mode-toggle-test.js (1 hunks)
  • tests/acceptance/demo-page/file-contents-card-test.js (1 hunks)
  • tests/integration/components/code-mirror-test.js (1 hunks)
  • tests/pages/components/code-mirror.ts (2 hunks)
  • tests/pages/components/file-contents-card.ts (1 hunks)
  • tests/pages/course-page.js (2 hunks)
  • tests/pages/demo-page.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • app/components/file-contents-card.hbs
  • app/templates/application.hbs
  • tests/pages/components/file-contents-card.ts
Files skipped from review as they are similar to previous changes (10)
  • app/templates/demo.hbs
  • app/templates/demo/dark-mode-toggle.hbs
  • tests/acceptance/course-page/view-code-examples-test.js
  • tests/acceptance/demo-page-test.js
  • tests/acceptance/demo-page/code-mirror-test.js
  • tests/acceptance/demo-page/dark-mode-toggle-test.js
  • tests/acceptance/demo-page/file-contents-card-test.js
  • tests/integration/components/code-mirror-test.js
  • tests/pages/course-page.js
  • tests/pages/demo-page.ts
Additional comments not posted (4)
tests/pages/components/code-mirror.ts (4)

13-26: LGTM! The addition of the gutters property is well-structured.

The gutters property and its nested properties (allGutters, lineNumbers, and foldGutter) are clearly defined, enhancing the maintainability and readability of the code.


45-45: LGTM! The addition of the gutters alias enhances usability.

The gutters alias provides a convenient way to access the newly structured gutter elements, improving the overall usability of the component.


48-48: LGTM! The addition of the hasRendered alias is a useful enhancement.

The hasRendered alias provides a clear and concise way to check if the content is present.


50-55: LGTM! The setLineText method is well-implemented.

The setLineText method allows users to set the text of a specific line in the editor, facilitating programmatic editing of individual lines.

tests/pages/components/code-mirror.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants