Skip to content

Develop#3569

Open
AngelaStrechen wants to merge 24 commits intomate-academy:developfrom
AngelaStrechen:develop
Open

Develop#3569
AngelaStrechen wants to merge 24 commits intomate-academy:developfrom
AngelaStrechen:develop

Conversation

@AngelaStrechen
Copy link

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 am requesting changes as there are a few critical issues that need to be addressed. While the core functionality works well, the solution misses several key requirements.

First, in src/App.tsx, you are duplicating the rendering logic instead of using the TodoList component as required. Please delegate rendering the list to <TodoList todos={todos} />. Second, the form inputs are missing their required <label> elements, which is an important accessibility feature. Additionally, several checklist items were violated, such as redefining types instead of importing them [CHECKLIST ITEM #2] and using single-letter variable names [CHECKLIST ITEM #1]. Finally, the CI workflow in .github/workflows/test.yml is misconfigured and will fail to upload test reports due to an incorrect directory path.

Please fix these issues and resubmit. You're on the right track!


✨ 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 on lines 24 to 29
- name: Upload tests report(cypress mochaawesome merged HTML report)
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: report
path: reports

Choose a reason for hiding this comment

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

This step is likely to fail. Your cypress.config.ts specifies the reportDir as raw_reports, but this action attempts to upload artifacts from a directory named reports (on line 29). Please ensure the path here matches the output directory from your test reporter.

src/App.tsx Outdated
const [titleError, setTitleError] = useState(false);
const [userError, setUserError] = useState(false);

const handleSubmit = (e: React.FormEvent) => {

Choose a reason for hiding this comment

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

This violates checklist item #1: 'Don't use one-letter variable naming.' Please use a more descriptive name for the event object, like event. This also applies to the use of u as a variable name on lines 37 and 100, and e on lines 64 and 77.

Comment on lines +59 to +68
<input
type="text"
data-cy="titleInput"
placeholder="Enter a title"
value={title}
onChange={e => {
setTitle(e.target.value);
setTitleError(false);
}}
/>

Choose a reason for hiding this comment

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

This input field is missing a corresponding <label> element. The task description requires adding labels, which are important for accessibility and a better user experience.

Comment on lines +74 to 88
<select
data-cy="userSelect"
value={userId}
onChange={e => {
setUserId(Number(e.target.value));
setUserError(false);
}}
>
<option value="0">Choose a user</option>
{usersFromServer.map(user => (
<option key={user.id} value={user.id}>
{user.name}
</option>
))}
</select>

Choose a reason for hiding this comment

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

This select field is missing a corresponding <label> element. The task requires adding labels where needed for better accessibility.

src/App.tsx Outdated
Comment on lines 98 to 120
<section className="TodoList">
<article data-id="1" className="TodoInfo TodoInfo--completed">
<h2 className="TodoInfo__title">
delectus aut autem
</h2>

<a className="UserInfo" href="mailto:Sincere@april.biz">
Leanne Graham
</a>
</article>

<article data-id="15" className="TodoInfo TodoInfo--completed">
<h2 className="TodoInfo__title">delectus aut autem</h2>

<a className="UserInfo" href="mailto:Sincere@april.biz">
Leanne Graham
</a>
</article>

<article data-id="2" className="TodoInfo">
<h2 className="TodoInfo__title">
quis ut nam facilis et officia qui
</h2>

<a className="UserInfo" href="mailto:Julianne.OConner@kory.org">
Patricia Lebsack
</a>
</article>
{todos.map(todo => {
const user = usersFromServer.find(u => u.id === todo.userId);

return (
<article
key={todo.id}
data-id={todo.id}
className={`TodoInfo ${
todo.completed ? 'TodoInfo--completed' : ''
}`}
>
<h2 className="TodoInfo__title">{todo.title}</h2>

{user && (
<a className="UserInfo" href={`mailto:${user.email}`}>
{user.name}
</a>
)}
</article>
);
})}
</section>

Choose a reason for hiding this comment

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

This section duplicates the rendering logic that should be handled by the TodoList component. The task requires creating an App component that displays the todos using the TodoList component. You should remove this logic and instead render <TodoList todos={todos} />.

src/App.tsx Outdated
</a>
</article>
{todos.map(todo => {
const user = usersFromServer.find(u => u.id === todo.userId);

Choose a reason for hiding this comment

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

This find operation is executed on every render for every single todo item, which is inefficient. This violates checklist item #5, which states that data should be prepared in the root component. You should enrich the todosFromServer data with the full user object once when you initialize your state, rather than looking it up during rendering.

Comment on lines +3 to +16
type User = {
id: number;
name: string;
username: string;
email: string;
};

type Todo = {
id: number;
title: string;
completed: boolean;
userId: number;
user: User;
};

Choose a reason for hiding this comment

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

This violates checklist item #2: "Don't repeat yourself." The User and Todo types are already defined in src/types/Todo.ts. Instead of redefining them here, you should import them from that file to ensure consistency and avoid code duplication.

Comment on lines +1 to +6
type User = {
id: number;
name: string;
username: string;
email: string;
};

Choose a reason for hiding this comment

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

This violates checklist item #2: "Don't repeat yourself." The User type is already defined in src/types/Todo.ts. Instead of redefining it here, you should import it from the shared types file to maintain a single source of truth for your data structures.

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

Excellent work on implementing the required features! The application is fully functional, and you've addressed most of the previous feedback. However, a few changes are needed before this can be merged.

  • High Priority: The CI workflow will fail to upload test reports. The path in cypress.config.ts is set to raw_reports, but the workflow in .github/workflows/test.yml looks for reports. Please make these paths consistent to fix the build.
  • Code Style: In src/components/TodoInfo/TodoInfo.spec.tsx and src/components/UserInfo/UserInfo.spec.tsx, you are repeating test data. Please define it once and reuse it to follow the DRY principle [CHECKLIST ITEM #2].
  • Code Style: The test file cypress/integration/page.spec.js uses a single-letter variable e. Please rename it to something more descriptive like error or err [CHECKLIST ITEM #1].

Once you've addressed these points, this will be ready for approval. Great job so far!


✨ 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 on lines 26 to 29
uses: actions/upload-artifact@v4
with:
name: report
path: reports

Choose a reason for hiding this comment

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

This artifact upload step seems to have an incorrect path. The path is set to reports, but your cypress.config.ts specifies raw_reports as the output directory. Please verify where your final test report is generated and update the path accordingly.

screenshotOnRunFailure: true,
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'raw_reports',

Choose a reason for hiding this comment

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

The test reports are configured to be generated in the raw_reports directory. However, your CI workflow in .github/workflows/test.yml is configured to look for reports in a directory named reports. This mismatch will prevent the test reports from being uploaded correctly. Please make sure the paths are consistent.

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

Great job on fixing the critical CI issue and improving your test code! Your application is working well, and I'm happy to approve this submission to help you move forward.

For future reference, there are a couple of areas for improvement:

  • Don't Repeat Yourself (DRY) [CHECKLIST ITEM #2]: The test data in src/components/TodoInfo/TodoInfo.spec.tsx and src/components/UserInfo/UserInfo.spec.tsx is duplicated. A best practice is to move this mock data into a shared file and import it into your tests.
  • Performance: In src/App.tsx, the preparedTodos variable is recalculated on every render. Since the data doesn't change, you can move this calculation outside the component so it only runs once.

Keep up the excellent work and focus on these points in your next tasks!


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

Footnotes

  1. Rate AI review example

Comment on lines +11 to +18
const preparedTodos: Todo[] = todosFromServer.map(todo => {
const user = usersFromServer.find(userItem => userItem.id === todo.userId)!;

return {
...todo,
user,
};
});

Choose a reason for hiding this comment

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

This preparedTodos variable is recalculated on every render of the App component, which is unnecessary since the source data (todosFromServer and usersFromServer) is static. For better performance, you should compute this value only once by moving this logic outside the component body.

Comment on lines +4 to +23
const user1 = {
id: 1,
name: 'Leanne Graham',
username: 'Bret',
email: 'Sincere@april.biz',
};

const user2 = {
id: 2,
name: 'Ervin Howell',
username: 'Antonette',
email: 'Shanna@melissa.tv',
};

const user3 = {
id: 3,
name: 'Clementine Bauch',
username: 'Samantha',
email: 'Nathan@yesenia.net',
};

Choose a reason for hiding this comment

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

While it's good that you've defined the test data here, this same data (like user1 and user2) is also defined in src/components/UserInfo/UserInfo.spec.tsx. This violates the DRY principle mentioned in checklist item #2.

To fix this, consider creating a single file for your mock test data (e.g., in a fixtures or test-data directory) and import it into both test files.

Comment on lines +4 to +16
const user1 = {
id: 1,
name: 'Leanne Graham',
username: 'Bret',
email: 'Sincere@april.biz',
};

const user2 = {
id: 2,
name: 'Ervin Howell',
username: 'Antonette',
email: 'Shanna@melissa.tv',
};

Choose a reason for hiding this comment

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

This test data (user1 and user2) is also defined in src/components/TodoInfo/TodoInfo.spec.tsx. This repetition violates checklist item #2 (DRY principle).

To fix this, please create a shared file for this mock data (e.g., in a fixtures or test-data directory) and import it into all test files where it's needed.

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.

7 participants