-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
refactoring to extract and test more AppStore functionality #6125
Conversation
fe1d0c3
to
0e1c93f
Compare
361a415
to
9071187
Compare
Opening this up for feedback - check out the new docs section that introduces this area. I'm currently looking for feedback about these areas:
|
Also, #6124 is marked for |
I would say that from my perspective this is a quite natural progression and it makes a lot of sense to export these from this updates folder. At first this felt a bit confusing, but I think it makes sense as it should make the
I'd say one benefit that I quite appreciate about this is that as functionality is branched out into their own files/folders it helps organize the relevant tests to a similar folder structure, which improves discoverability. Rather than potentially having quite as many jammed in one folder with potentially different naming schemes. (Such as may happen with the many files the base of the /lib/ folder). I'm going to explore this a bit further later today and update if I find anything I feel is worth some discussion on that may be more useful. So far I think this is a nice direction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice code 🎨
Co-Authored-By: shiftkey <brendan@github.com>
I merged |
Overview
There was a request in #6124 to decompose some complex code in
AppStore._loadStatus
to make it more readable, but I also wanted to take it further and see if I can get this code under test.Rendered Markdown
Closes #6124
Description
The goal with this PR was to be able to write some meaningful tests around complex parts of
AppStore
, while avoiding the overhead of gettingAppStore
setup and in the correct state for testing.The initial request to extract these into functions was a start, but I also wanted to achieve two things:
AppStore
I settled on just covering the important code paths for both
updateChangedFiles
andupdateConflictState
and was able to hit 100% coverage with a bit of work:The pattern that I ended up with does feel a bit like reducers in Redux, but with some caveats beyond the generic
function updateSomeState<T>(prevState: T, ...args): T
:T
, so making each function merge in previous state to then returnT
feels like overkill right nowRepositoryStateCache
to handle merging state changes togetherThings of note so far:
app/src/lib/stores/updates
so these are close toAppStore
, but avoid the churn of potential conflicts inAppStore
itselfIStatsStore
to stub and test the actions that we need to fire insideupdateConflictState
, and we can refine that as we need to test more thingsIChangesState
andIStatusResult
to work, and those contain a lot of noise. I fell into a pattern usingcreateState
andcreateStatus
factory functions to construct state needed for tests by taking a base object and merging it with just the fields that were relevant to the test. These helpers now live inapp/test/unit/stores/updates/changes-state-helper.ts
and they were a great help to keep the tests focus on the specific scenarioDiffSelectionType
enum is now a string enum because the strings help with readability in the tests ('All' !== 'None'
is much easier to understand than0 !== 1
)TODO:
app/src/lib/stores/updates/changes-state.ts
Release notes
Notes: no-notes