Skip to content

solution#330

Open
pasha1932 wants to merge 3 commits into
mate-academy:mainfrom
pasha1932:e2e_testing
Open

solution#330
pasha1932 wants to merge 3 commits into
mate-academy:mainfrom
pasha1932:e2e_testing

Conversation

@pasha1932

Copy link
Copy Markdown

No description provided.

@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

Thank you for your hard work! 😊 There are a few critical issues that need to be fixed before your PR can be approved: (1) The filename acticlePage.pageObject.js is misspelled and should be articlePage.pageObject.js—this typo causes import errors and will prevent tests from running; (2) In your sign-up and user follow tests, asynchronous user data generation and registration are not handled correctly, which may lead to unreliable or broken tests; (3) Please remove the unnecessary src/package-lock.json unless your project specifically requires it. Once you address these issues, your PR should be ready for approval! Keep going—you’re almost there! 🚀


✨ 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 cypress/e2e/article.cy.js Outdated
/// <reference types='cypress' />
/// <reference types='../support' />

import ArticlePageObject from '../support/pages/acticlePage.pageObject';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a typo in the import path: 'acticlePage.pageObject' should be 'articlePage.pageObject'. This will cause a module not found error and must be fixed to run the tests.

Comment thread cypress/e2e/signUp.cy.js Outdated
Comment on lines +26 to +29
it('should sign up succefully', () => {
signInPage.visit();
cy.register(email, username, password);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: The test uses 'email', 'username', and 'password' variables that are set asynchronously in beforeEach. There is no guarantee that these variables are set before the test runs, which may lead to them being undefined. Consider returning the 'cy.task' promise or chaining the test logic to ensure the variables are set before use.

Comment thread cypress/e2e/user.cy.js
Comment on lines +15 to +24
userTarget = generateUser;
cy.register(userTarget.email, userTarget.username, userTarget.password);
userFollower = generateUser;
userFollower.email += 'world';
userFollower.username += 'follower';
cy.register(
userFollower.email,
userFollower.username,
userFollower.password
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: Both userTarget and userFollower are derived from the same generated user object, with userFollower being a mutated version. This could cause unexpected behavior since both users will share the same password and initial data. Consider generating two separate users using 'cy.task('generateUser')' for each.

Comment thread cypress/e2e/user.cy.js
Comment on lines +15 to +24
userTarget = generateUser;
cy.register(userTarget.email, userTarget.username, userTarget.password);
userFollower = generateUser;
userFollower.email += 'world';
userFollower.username += 'follower';
cy.register(
userFollower.email,
userFollower.username,
userFollower.password
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: The registration of both users is not properly chained. Since 'cy.register' is asynchronous, you should ensure that the registration of userFollower happens after userTarget is fully registered. Consider chaining the promises or using separate 'then' blocks.

@@ -0,0 +1,47 @@
import PageObject from '../PageObject';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Critical issue: The filename is misspelled as 'acticlePage.pageObject.js'. It should be 'articlePage.pageObject.js' to match the import statements in your test files and avoid module not found errors.

@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

Thank you for your hard work! There are still a few critical issues that need to be addressed before your PR can be approved. Specifically:

  • In article.cy.js, ensure the import path for ArticlePageObject matches the actual filename exactly (articlePage.pageObject.js), as mismatches will break your tests.
  • In signUp.cy.js, user data is generated asynchronously in the beforeEach hook, but your tests do not wait for this data to be set before using it. Please ensure your tests only run after the user data is generated.
  • In user.cy.js, both userTarget and userFollower are assigned from the same generated user object and then mutated. Please generate two separate users to avoid data overlap.

Once you fix these issues, your tests should run reliably and your PR will be ready for approval! Keep going—you're almost there! 🚀


✨ 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 cypress/e2e/article.cy.js
/// <reference types='cypress' />
/// <reference types='../support' />

import ArticlePageObject from '../support/pages/articlePage.pageObject';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There may be a mismatch between the import path '../support/pages/articlePage.pageObject' and the actual filename. Please ensure the file is named 'articlePage.pageObject.js' and the import path matches exactly, as a typo or case sensitivity issue will cause import errors. This is a critical issue that must be fixed for your tests to run.

Comment thread cypress/e2e/signUp.cy.js Outdated
Comment on lines 17 to 24
beforeEach(() => {
cy.task('db:clear');
cy.task('generateUser').then((user) => {
username = user.username;
email = user.email;
password = user.password;
});
});

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 user data is generated asynchronously in the beforeEach hook, but the test cases do not wait for this data to be set before using it. This can cause tests to run before username, email, and password are assigned, leading to failures. To fix this, ensure your tests only run after the user data is generated, for example by returning the promise from the beforeEach hook.

Comment thread cypress/e2e/user.cy.js
Comment on lines +14 to +25
cy.task('generateUser').then((generateUser) => {
userTarget = generateUser;
cy.register(userTarget.email, userTarget.username, userTarget.password);
userFollower = generateUser;
userFollower.email += 'world';
userFollower.username += 'follower';
cy.register(
userFollower.email,
userFollower.username,
userFollower.password
);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Both userTarget and userFollower are assigned from the same generated user object and then mutated. This can cause both users to have overlapping or invalid data. To ensure unique users, generate two separate users by calling cy.task('generateUser') twice.

@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

Great job addressing the previous issues! 🎉 Your updated tests now properly handle asynchronous user generation, ensuring that user data is always available before being used. Specifically:

  • In signIn.cy.js, please ensure that the test always waits for the user object to be generated before accessing it. This will prevent any race conditions or undefined errors.
  • In user.cy.js, you've improved the setup, but make sure both userTarget and userFollower are guaranteed to be available before the tests run. This is crucial for reliable and non-flaky tests.

All other core requirements are met: you use the Page Object Model, manage database state correctly, and generate fake user data as required. Your test structure is clear and follows best practices.

Next steps:
Please review the inline comments and make the suggested improvements to your asynchronous test setups. This will help you avoid potential issues in future projects and ensure your tests remain robust.

Keep up the good work and continue learning! If you need more information on handling asynchronous code in Cypress, check out the Cypress documentation on Promises and async code. 🚀


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

Footnotes

  1. Rate AI review example

Comment thread cypress/e2e/signIn.cy.js
Comment on lines +32 to 41
signInPage.visit();

signInPage.typeEmail(user.email);
signInPage.typePassword(user.password + 'wrong111');
signInPage.clickSignInBtn();

cy.contains('div[class="swal-title"]', 'Login failed!').should(
'be.visible'
);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: This test also uses the user object without ensuring it is available. Make sure the test waits for user generation before accessing user, as per the checklist requirements.

Comment thread cypress/e2e/user.cy.js
Comment on lines +28 to 42
it('should be able to follow the another user', () => {
signInPage.visit();

signInPage.typeEmail(userFollower.email);
signInPage.typePassword(userFollower.password);

signInPage.clickSignInBtn();

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);

cy.visit(`/#/@${userTarget.username.replace('follower', '')}`);

cy.contains('button', `Follow ${userTarget.username.replace('follower', '')}`).click();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: The test uses userTarget and userFollower without ensuring both are available before the test runs. Since user generation is asynchronous, you should guarantee both users are set before proceeding with the tests, as required by the checklist.

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