8000 ENG-1057 - Improve modal experience by adamkecskes · Pull Request #7707 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ENG-1057 - Improve modal experience #7707

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

Merged
merged 3 commits into from
Sep 20, 2024
Merged

Conversation

adamkecskes
Copy link
Collaborator
@adamkecskes adamkecskes commented Sep 17, 2024
  • Only show one modal automatically.
  • When the modal was closed, save the date, and next modal should be shown only one week later.
  • <ModalDyanmicContent has a new prop: priority<number>. The modal with higher prio will be shown first.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced modal management with prioritized display based on user-specific promotion visibility.
    • Introduced a method to determine user eligibility for promotions, improving user engagement tracking.
    • Added a new property for modal prioritization in the UI.
  • Bug Fixes

    • Improved logic for retrieving the top modal, ensuring accurate display based on user interactions.
  • Tests

    • Added comprehensive unit tests for modal functionality and user promotion visibility, ensuring robust performance.
    • Enhanced test coverage for modal management and user promotion logic.
  • Documentation

    • Updated ESLint configuration to support Jest and Mocha, enhancing code quality during development.

Copy link
Contributor
coderabbitai bot commented Sep 17, 2024

Walkthrough

The changes primarily enhance the modal management system within the application. Modals are now prioritized based on their importance, with logic updated to control their visibility depending on user interactions with promotions. The User model has been updated to track when promotions are seen, allowing for more nuanced visibility rules. Additionally, new tests have been introduced to ensure the functionality of these changes is validated.

Changes

Files Change Summary
app/core/store/modules/modals.js, app/models/User.js, app/schemas/models/user.js, ozaria/site/components/teacher-dashboard/modals/ModalDynamicContent.vue Updated modal management logic to prioritize modals and control visibility based on user interactions with promotions. Introduced new methods in the User model to track promotion visibility. Modified schema to store dates for seen promotions.
test/.eslintrc Added ESLint configuration for Jest and Mocha testing frameworks.
test/app/core/store/modules/modals.spec.js, test/app/models/User.spec.js Implemented unit tests for modal functionality and User model methods to ensure proper behavior.

Assessment against linked issues

Objective Addressed Explanation
Show no more than 1 modal a week (ENG-1057)
Allow some modals to have an end-date (ENG-1057) No implementation for end-dates.
Show modals N times as reminders (ENG-1057) Logic for reminders is unclear.

Possibly related PRs

Poem

🐰 In a world of modals, bright and new,
We hop and dance, with a clearer view.
Priority set, no more cluttered sight,
Promotions now shown, just right and tight.
With dates to remember, we keep track of cheer,
A happier user, oh what a dear! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 54a74d6 and 91e4c6b.

Files selected for processing (2)
  • app/schemas/models/user.js (1 hunks)
  • test/app/models/User.spec.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/schemas/models/user.js
  • test/app/models/User.spec.js

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 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
@mrfinch mrfinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!!!

expect(user.shouldSeePromotion()).toBe(true)
})

it('returns false if promotion has been seen', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens for the users who have value true or false set instead of date?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrfinch tests pushed for legacy boolean values!

@adamkecskes adamkecskes force-pushed the adamk/improve-modal-experience branch from b92d1b2 to 3c6aaad Compare September 19, 2024 12:01
@adamkecskes adamkecskes requested a review from mrfinch September 19, 2024 12:07
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 3c6aaad and 54a74d6.

Files selected for processing (1)
  • test/app/models/User.spec.js (1 hunks)
Additional context used
Biome
test/app/models/User.spec.js

[error] 90-90: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Additional comments not posted (7)
test/app/models/User.spec.js (7)

10-16: LGTM!

The test cases for experience functions look good. They cover the expected behavior and edge cases.


18-25: LGTM!

The test cases for level calculation look good. They cover the expected behavior and edge cases.


27-54: LGTM!

The test cases for user email subscriptions look good. They cover the expected behavior and edge cases.


56-72: LGTM!

The test cases for user validation look good. They cover the expected behavior and edge cases.


74-88: LGTM!

The test cases for inEU function look good. They cover the expected behavior and edge cases.


101-114: Test cases for legacy promotion values look good.

The test cases cover the scenarios mentioned in the past review comment about handling users with legacy true or false values for promotions. The behavior looks correct.


116-135: LGTM!

The test cases for checking the last seen promotion date look good. They cover the expected behavior and edge cases.

})
})

fdescribe('shouldSeePromotion', function () {
Copy link
Contributor
@coderabbitai coderabbitai bot Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the focus from the test block.

The use of fdescribe is not recommended as it focuses only on this test block and skips others. This could lead to other test blocks being skipped, which may cause issues to go unnoticed.

Apply this diff to remove the focus:

-fdescribe('shouldSeePromotion', function () {
+describe('shouldSeePromotion', function () {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fdescribe('shouldSeePromotion', function () {
describe('shouldSeePromotion', function () {
Tools
Biome

[error] 90-90: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamkecskes can you change the fdescribe to describe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

})
})

fdescribe('shouldSeePromotion', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamkecskes can you change the fdescribe to describe?

'hackstack-beta-release-modal': { type: 'boolean' },
'curriculum-sidebar-promotion-modal': { type: 'boolean' },
'hp-junior-modal': { type: 'boolean' }
'hackstack-beta-release-modal': c.date(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless we are planning to backfill data, user.save might start to fail. Good idea to keep both boolean and date

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrfinch fixed.

@adamkecskes adamkecskes requested a review from mrfinch September 20, 2024 06:57
@mrfinch mrfinch merged commit 8f98bd7 into master Sep 20, 2024
0 of 2 checks passed
@mrfinch mrfinch deleted the adamk/improve-modal-experience branch September 20, 2024 17:32
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
0