Skip to content

Conversation

@SerhiiVeremiienko
Copy link

No description provided.

Copy link

@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’m requesting changes because there are critical blockers preventing full compliance with the task requirements.

Critical issues to fix:

  1. Missing list comments endpoint implementation

    • Where: src/api/resources/CommentsApi.js (no getComments) and src/api/ApiComposite.js (no wrapper)
    • Why: The task requires GET /api/articles/:slug/comments to list comments for an article. Without it, required functionality is incomplete.
    • How: Implement getComments(slug, token = null) in CommentsApi that performs a GET to /api/articles/:slug/comments, and expose it from ApiComposite as getComments(slug, authToken) delegating to CommentsApi.getComments.
  2. Authorization header handling for unauthenticated requests

    • Where: src/api/resources/CommentsApi.js, in both createComment and deleteComment (exact lines where headers are built)
    • Why: The Authorization header is always set even when token is null. This breaks unauthenticated scenarios and doesn’t reflect real API behavior.
    • How: Only include Authorization: Token ${token} when token is provided; otherwise omit the header entirely. For example, build headers with a conditional spread: { 'Content-Type': 'application/json', ...(token ? { Authorization: \ Token ${token} } : {}) }.
  3. Align method signatures and parameter names

    • Where: src/api/ApiComposite.js (wrappers) and optionally src/api/resources/CommentsApi.js
    • Why: The requirements specify explicit method signatures for clarity and correctness.
    • How: Rename and reorder parameters to match the spec:
      • createComment(slug, body, authToken) (not article, comment, token), and pass { comment: { body } } in the request body.
      • deleteComment(slug, commentId, authToken) (not article, commentId, token). Ensure the same ordering in CommentsApi or adapt the wrapper accordingly.

Minor suggestions (non-blockers):

  • Consider renaming ROUTES.comments(slug).create to a more generic key (e.g., list or index) if it’s also used for GET, to avoid confusion.
  • If you keep assertion helpers in ApiComposite, verify they’re correctly implemented in CommentsApi and used consistently.

You’re very close—create/delete flows and tests look solid. Addressing the GET method and header handling will bring this fully in line with the requirements. Keep up the good work!


✨ 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

return await this.articles.getArticleBySlug(slug, token);
}

async createComment(article, comment = null, token = null) {

Choose a reason for hiding this comment

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

The method signature for createComment should match the requirements: it should take slug, body, and authToken (not article, comment, token). Please align the parameter names and order with the requirements for clarity and correctness.

return await this.comments.createComment(article, comment, token);
}

async deleteComment(article, commentId, token = null) {

Choose a reason for hiding this comment

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

The method signature for deleteComment should match the requirements: it should take slug, commentId, and authToken (not article, commentId, token). Please align the parameter names and order with the requirements for clarity and correctness.

async deleteComment(article, commentId, token = null) {
return await this.comments.deleteComment(article, commentId, token);
}

Choose a reason for hiding this comment

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

You are missing a method to list comments for a specific article (GET /api/articles/:slug/comments), which is required by the task. Please add a method such as getComments(slug, authToken) that delegates to the corresponding method in CommentsApi.

expect(body.comment.author.username).toBe(username);
});
}
}

Choose a reason for hiding this comment

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

You are missing the required getComments(slug, token = null) method, which should perform a GET request to /api/articles/:slug/comments. This is necessary to fulfill the task requirements for listing comments.

...(comment ? { comment: { body: comment } } : {}),
},
headers: {
authorization: `Token ${token}`,

Choose a reason for hiding this comment

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

The Authorization header is always set, even if token is null. For unauthenticated requests, you should only include the Authorization header if token is provided. Otherwise, omit it to accurately simulate unauthenticated scenarios.

return await this.step(`Delete comment with id ${commentId}`, async () => {
return await this.client.delete(ROUTES.comments(slug, commentId).delete, {
headers: {
authorization: `Token ${token}`,

Choose a reason for hiding this comment

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

The Authorization header is always set, even if token is null. For unauthenticated requests, you should only include the Authorization header if token is provided. Otherwise, omit it to accurately simulate unauthenticated scenarios.

Copy link

@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

Decision: APPROVE

Your implementation fully meets the requirements for the Comments API feature set and its tests.

  • The CommentsApi class correctly implements create, list, and delete operations with proper endpoints, payloads, and conditional Authorization headers.
  • The composite API (ApiComposite.js) cleanly exposes createComment, getComments, and deleteComment with correct signatures.
  • Routes and status code constants are accurate and consistent.
  • Playwright fixtures integrate the Comments API cleanly, and the test suite robustly covers all required positive and negative scenarios (unauthorized, missing body, cross-user delete, own delete), asserting both status codes and response structures.

No critical blockers or functional gaps were found. Nice work on keeping the code clean, consistent with existing patterns, and well-tested. Keep it up!


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

3 participants