Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test cases showing and dismissing of toasts #280

Merged

Conversation

SDaniV
Copy link
Contributor

@SDaniV SDaniV commented Dec 1, 2024

Description

Add integration test cases showing and dismissing of toasts

Closes #110

What change does this PR introduce?

Please select the relevant option(s).

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to docs/code comments)

What is the proposed approach?

First commit introduces changes that cover toast message in the integrated tests.
Second commit updates formatting in App.tsx file.

Note: if the formatting is unwanted or not well-structured, I can revert that commit.

Checklist:

  • The commit message follows our adopted guidelines
  • Testing has been done for the change(s) added (for bug fixes/features)
  • Relevant comments/docs have been added/updated (for bug fixes/features)

@tjtanjin
Copy link
Owner

tjtanjin commented Dec 2, 2024

Hey @SDaniV! The integration test cases are failing, are you still working on this issue?

@SDaniV
Copy link
Contributor Author

SDaniV commented Dec 3, 2024

Hey @tjtanjin! Unfortunately, I didn't manage to understand the reason for the failure the day when I raised the PR. I will try to get it working today and let you know about the result.

@tjtanjin
Copy link
Owner

tjtanjin commented Dec 3, 2024

Hey @tjtanjin! Unfortunately, I didn't manage to understand the reason for the failure the day when I raised the PR. I will try to get it working today and let you know about the result.

Hey again! You can actually run the test locally with npm run int:test as well instead of relying on the GitHub pipeline to run. It'll hopefully ease your debugging process.

Hint: params.showToast is async.

@SDaniV
Copy link
Contributor Author

SDaniV commented Dec 3, 2024

Thanks for the hint @tjtanjin! I couldn't reproduce it locally at the beginning because I was running the tests with the UI turned on. Once I switched to running in headless mode, I got the same errors as on the CI. The problem was related to the formatting changes I made.
Now Integration Test Run passed but Compatibility Test failed 🤔
Regarding your hint, does it mean I need to change the way of how I test the toast?

@tjtanjin
Copy link
Owner

tjtanjin commented Dec 3, 2024

Thanks for the hint @tjtanjin! I couldn't reproduce it locally at the beginning because I was running the tests with the UI turned on. Once I switched to running in headless mode, I got the same errors as on the CI. The problem was related to the formatting changes I made. Now Integration Test Run passed but Compatibility Test failed 🤔 Regarding your hint, does it mean I need to change the way of how I test the toast?

Since params.showToast is async, the best practice is to await it. Otherwise the toast may not be present when the integration test case tries to look for it. You may find the documentation here helpful: https://react-chatbotify.com/docs/api/params#showtoast

@SDaniV
Copy link
Contributor Author

SDaniV commented Dec 4, 2024

@tjtanjin Thank you for sharing the details 🙇
I spent some time reading a bit more about how Cypress works. Looks like its commands (cy.get or cy.contains) have built-in functionality that waits and retries for 4 seconds (default timeout) if an element is not found. I think it should be enough in our case.
Also, I found the reason why the RC build failed in the previous run. After I updated cypress/fixtures/templates/ChatBotApp.tsx, the checks have passed.
Please, review the changes now 🙏

Copy link
Owner

@tjtanjin tjtanjin left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for taking the time!

@tjtanjin tjtanjin merged commit 1512edf into tjtanjin:main Dec 4, 2024
11 checks passed
@SDaniV SDaniV deleted the issue-110-add-integrated-test-cases-for-toasts branch December 4, 2024 14:55
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.

[Task] Add integration test cases showing and dismissing of toasts
2 participants