Skip to content

add task solution#1806

Open
OksanaSht wants to merge 2 commits into
mate-academy:masterfrom
OksanaSht:develop
Open

add task solution#1806
OksanaSht wants to merge 2 commits into
mate-academy:masterfrom
OksanaSht:develop

Conversation

@OksanaSht
Copy link
Copy Markdown

Copy link
Copy Markdown

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

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 some core requirements of the notification task are not yet met, and these gaps are causing the end‑to‑end tests to fail. In src/scripts/main.js, inside pushNotification, you correctly create the notification elements and call the function three times, but you never append the created node to the DOM (e.g., document.body.append(node)), so Cypress never finds .notification.success, .notification.error, or .notification.warning elements. The title h2 you create is missing the required title class, so you should add titleNode.classList.add('title') to satisfy the spec and related checklist items [CHECKLIST ITEM #7, #13]. The positioning logic assigns node.style.top = posTop and node.style.right = posRight without units, which breaks when numeric values are passed; concatenate 'px' or accept a full CSS unit string (e.g., node.style.top = posTop + 'px'). You also need to hide the notification visually after 2000 ms instead of removing it from the DOM by wrapping a style change (such as node.style.display = 'none' or node.style.visibility = 'hidden') in a setTimeout(..., 2000) to satisfy the timing and DOM‑persistence requirements [CHECKLIST ITEM #4, #12, #15]. These issues are all critical blockers because they prevent notifications from ever becoming visible to the user and from behaving as the tests expect. On the positive side, your function signature, class assignment for notification and type, and use of h2/p are aligned with the task, so once you wire the node into the DOM, fix the units, add the title class, and implement the timed hide, your solution should be in good shape.


✨ 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
const pushNotification = (posTop, posRight, title, description, type) => {
// write code here
const node = document.createElement('div');
const titleNode = document.createElement('h2');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You create the title h2 node but never give it the required title class. Per checklist items #7 and #13 add titleNode.classList.add('title') so the element has the expected class.

Comment thread src/scripts/main.js Outdated

node.classList.add(`notification`, type);

node.style.top = posTop;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assigning node.style.top = posTop will not include units when posTop is a number. Use a string with units (for example node.style.top = posTop + 'px') so positioning works reliably.

Comment thread src/scripts/main.js Outdated
node.classList.add(`notification`, type);

node.style.top = posTop;
node.style.right = posRight;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same for right: set node.style.right = posRight + 'px' (or accept a proper CSS unit string) so the value is valid CSS.

Comment thread src/scripts/main.js

node.append(titleNode);
node.append(descripNode);

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 notification node is never appended to the document, so it will not be visible. Append it (for example document.body.append(node)), ideally after setting its content and classes to satisfy checklist item #3.

Comment thread src/scripts/main.js
node.append(descripNode);

titleNode.innerText = title;
descripNode.innerText = description;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You must hide the message visually after 2 seconds instead of removing it from the DOM. Use setTimeout to change a style property (e.g., node.style.display = 'none' or node.style.visibility = 'hidden') after 2000ms to satisfy checklist items #4, #12 and #15.

Copy link
Copy Markdown

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

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 correctly implements pushNotification in src/scripts/main.js to meet all stated requirements. The function creates a notification element with both the base notification class and the dynamic type class, adds an h2 with the title class plus a p for the description, appends it to the document body, and positions it using pixel units for the coordinates. You also correctly trigger the three required notifications (success, error, warning) and use setTimeout to hide the notification visually after 2000 ms via style.visibility = 'hidden' instead of removing it from the DOM. There are no critical or blocking issues that would prevent the feature from working as specified. As minor, optional improvements, you might consider using style.display = 'none' if you want the element removed from the layout flow, and textContent instead of innerText for slightly more consistent behavior across environments. Overall, this is a solid, requirement-compliant implementation—well done.


✨ 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