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

#9227 Refactor useTheme to use useManagedStorageState #9228

Merged
merged 31 commits into from
Oct 10, 2024

Conversation

mnholtz
Copy link
Collaborator

@mnholtz mnholtz commented Oct 3, 2024

What does this PR do?

Discussion

  • The useManagedStorageState hook throws on error, causing the unit test "uses activeTheme when error occurs in managed storage" to fail. Do we want to add error-handling to useManagedStorageState to preserve this behavior in the sidebar?

@mnholtz
Copy link
Collaborator Author

mnholtz commented Oct 3, 2024

Just calling out that I'd like clarification on

The useManagedStorageState hook throws on error, causing the unit test "uses activeTheme when error occurs in managed storage" to fail. Do we want to add error-handling to useManagedStorageState to preserve this behavior in the sidebar?

Base automatically changed from feature/9222_hide_sidebar_logo_policy to main October 3, 2024 20:17
# Conflicts:
#	src/hooks/useTheme.test.ts
#	src/hooks/useTheme.ts
Copy link

github-actions bot commented Oct 7, 2024

Playwright test results

passed  132 passed
flaky  6 flaky
skipped  4 skipped

Details

report  Open report ↗︎
stats  142 tests across 46 suites
duration  14 minutes, 2 seconds
commit  196be66
info  For more information on how to debug and view this report, see our readme

Flaky tests

chrome › tests/modLifecycle.spec.ts › create, run, package, and update mod
chrome › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
msedge › tests/pageEditor/addStarterBrick.spec.ts › Add new mod with different starter brick components
msedge › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
msedge › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration
msedge › tests/regressions/welcomeStarterBricks.spec.ts › #8740: can view the starter mods on the pixiebrix.com/welcome page

Skipped tests

chrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
msedge › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

data,
isLoading: data == null,
};
function useManagedStorageState() {
Copy link
Contributor

@twschiller twschiller Oct 8, 2024

Choose a reason for hiding this comment

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

NIT: I'd encourage us to declare the return type on exported functions

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: Typescript infers the return type very well:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

This was from hovering over useManagedStorageState in useTheme. I would actually prefer to not require return types in cases like this

Copy link
Contributor

@twschiller twschiller Oct 8, 2024

Choose a reason for hiding this comment

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

Your call since it's a philosophical distinction. Explicitly declaring the type better decouples the protocol/interface from the implementation. (And is required to hide certain properties from the caller)

See rule for more context: https://typescript-eslint.io/rules/explicit-module-boundary-types/

</bike-shedding>

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a better rule than requiring return types on all functions (which can be a nightmare). I could accept this, but I don't feel strongly that we need it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At this time I don't feel strongly about this either way. I would be open to experimenting with that rule

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.10%. Comparing base (8318d74) to head (196be66).
Report is 359 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9228      +/-   ##
==========================================
+ Coverage   74.24%   75.10%   +0.85%     
==========================================
  Files        1332     1369      +37     
  Lines       40817    42260    +1443     
  Branches     7634     7882     +248     
==========================================
+ Hits        30306    31740    +1434     
- Misses      10511    10520       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mnholtz mnholtz merged commit 0f478a7 into main Oct 10, 2024
20 checks passed
@mnholtz mnholtz deleted the feature/9227_refactor_use_theme branch October 10, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor useTheme to use useManagedStorageState
3 participants