Skip to content

Conversation

@sfc-gh-bnisco
Copy link
Collaborator

Describe your changes

  • Modernizes SettingsDialog and its tests
  • There should be no functional changes, just a refactor onto modern React patterns

GitHub Issue Link (if applicable)

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python)
  • E2E Tests
  • Any manual testing needed?

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@sfc-gh-bnisco sfc-gh-bnisco added security-assessment-completed Security assessment has been completed for PR impact:internal PR changes only affect internal code change:refactor PR contains code refactoring without behavior change labels Oct 18, 2024
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the bnisco/modernize-settingsdialog branch from a6f9b92 to 45b1a3e Compare October 21, 2024 22:08
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the bnisco/modernize-settingsdialog branch from 45b1a3e to 17c192f Compare October 21, 2024 22:11
@sfc-gh-bnisco sfc-gh-bnisco marked this pull request as ready for review October 21, 2024 23:22
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

expect(screen.getByText("Run on save")).toBeInTheDocument()

screen.getByText("Run on save").click()
await user.click(screen.getByText("Run on save"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious question: what is the benefit of user.click() vs screen.getByText("Run on save").click()? From reading the docs, it sounds like that user-events is a more realistic simulation of user events. It might be good to start a list of tips & tricks in our wiki related to writing RTL tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's correct, user-event is more realistic to how a user interacts with the application. Generally speaking I prefer to lean on automated enforcement rather than documentation, so in that spirit, I have a follow-up PR that enforces user-event via eslint here

@sfc-gh-bnisco sfc-gh-bnisco merged commit ecda5ce into develop Oct 28, 2024
@sfc-gh-bnisco sfc-gh-bnisco deleted the bnisco/modernize-settingsdialog branch October 28, 2024 19:46
sfc-gh-bnisco added a commit that referenced this pull request Nov 20, 2024
## Describe your changes

- Based on some feedback in
#9684 this PR introduces a
new lint rule for RTL, encouraging usage of user-event.
- user-events gives us greater confidence in the way we write tests
because "fireEvent dispatches DOM events, whereas user-event simulates
full interactions, which may fire multiple events and do additional
checks along the way."
[[docs](https://testing-library.com/docs/user-event/intro/)]
- This PR adds inline disable comments to any usages that are currently
in violation, so there should be no changes to code as written today.

## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python) ✅
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
## Describe your changes

- Modernizes `SettingsDialog` and its tests
- There should be no functional changes, just a refactor onto modern
React patterns

## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python)
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
## Describe your changes

- Based on some feedback in
streamlit#9684 this PR introduces a
new lint rule for RTL, encouraging usage of user-event.
- user-events gives us greater confidence in the way we write tests
because "fireEvent dispatches DOM events, whereas user-event simulates
full interactions, which may fire multiple events and do additional
checks along the way."
[[docs](https://testing-library.com/docs/user-event/intro/)]
- This PR adds inline disable comments to any usages that are currently
in violation, so there should be no changes to code as written today.

## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python) ✅
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants