Skip to content

js_notification_DOM#1845

Open
142536Def wants to merge 5 commits into
mate-academy:masterfrom
142536Def:develop
Open

js_notification_DOM#1845
142536Def wants to merge 5 commits into
mate-academy:masterfrom
142536Def:develop

Conversation

@142536Def

Copy link
Copy Markdown

Task: Create a notification

To inform the user about the success of the operation or any errors, websites typically use messages that appear on the screen for a short period.

Your task: Create a function pushNotification, which takes the coordinates of the message, title, description, and type
(success, error and warning). pushNotification creates an element to display the message, appends it to the document, and hides it from the DOM after 2 seconds.
Do not write any CSS styles or HTML code in this task. You should modify only the main.js file.

Implementation guideline:

  • Print three messages: success, error, warning (call methods already exist in the main.js file);
  • The message is a block element with class notification + class, which depends on the input parameter type (success, error, warning);
  • The message should have a title with class title (prefer h2 element);
  • The message should have a description (prefer tag p);
  • Use setTimeout to execute a function or specified piece of code once the timer expires;
  • Important: Do not remove elements from the DOM in this task; instead, use style attributes just to hide messages visually (f.e, display or visibility properties).

It's an expected result of your job:
Result

General instructions

  1. Replace <142536Def> with your GitHub username in the link
  2. Follow this instructions
    • Run npm run test command to test your code;
    • Run npm run test:only -- -n to run fast test ignoring linter;
    • Run npm run test:only -- -l to run fast test with additional info in console, ignoring linter.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because there is still a structural issue with the notification description that can cause tests or styles to fail. In src/scripts/main.js, you correctly create a p element for the description, but you add the desc class to the notification container div instead of to the description paragraph itself, which violates the requirement that the description element (preferably the p tag) be identifiable/styled via desc [CHECKLIST ITEM #11]. To fix this, move the desc class so it is applied to notificationDesc (the paragraph), e.g. notificationDesc.classList.add('desc');, and remove desc from the surrounding notification div. Functionally, your notifications, timing, and DOM behavior are all in good shape, so once this class placement is corrected you should fully meet the structural requirements. As a minor improvement, also remember to update the demo link in the description file to use your actual GitHub username instead of the <your_account> placeholder [CHECKLIST ITEM #13]. Overall, you are very close—fixing the description class will align your implementation with the expected markup and should allow all tests and styles to behave as intended.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated

const notificationDesc = document.createElement('p');

notification.classList.add('desc');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The class desc is being added to the notification div, but per the requirements the message should have a description element (preferably the p tag) that serves as the description. You likely need to add desc to notificationDesc instead, so that the description paragraph can be styled/identified correctly.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because the Cypress end‑to‑end tests show two critical, blocking issues with the notification behavior. First, your notification style attribute currently includes position: fixed; along with top and right, but the tests expect the style to contain only top and right (e.g. at the creation line where you call elem.setAttribute('style', ...)). This mismatch causes assertions to fail, so you need to adjust the style string to just top: ${top}px; right: ${right}px; to align with the test expectations and task requirements. Second, the auto‑dismiss behavior is not working as required: notifications remain visible after 2 seconds, whereas the task and tests expect them to be hidden or removed after that delay. You should ensure that your setTimeout callback either sets elem.style.visibility = 'hidden' or removes the element (e.g. elem.remove()) after 2000 ms, so the messages correctly disappear. Functionally, your pushNotification setup (parameters, classes, DOM structure) is solid, so once you fix the style attribute and the hide/remove logic, your solution should satisfy the core requirements. Keep up the good work—these are targeted fixes that will help your implementation fully pass the tests.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your solution is approved because it cleanly meets all the functional and structural requirements for the pushNotification feature. The function correctly accepts coordinates, title, description, and type, creates a div with both the notification and type-specific class, and appends it to document.body as required. You also implemented the title as an h2 with class title and the description as a p, and you handled positioning via style.top and style.right with the provided coordinates, matching the expected API. The auto-dismiss logic using setTimeout and visibility = 'hidden' after 2000 ms nicely respects the constraint that elements should not be removed from the DOM. It’s great that you kept styling inline and limited changes to main.js, which aligns with the constraints and shows careful attention to the checklist. Overall, this is a solid, requirements-focused implementation—well done tightening it up to match the tests and specification.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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