-
Notifications
You must be signed in to change notification settings - Fork 364
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
fix: [M3-8739] - Fix MSW 2.0 initial mock store and support ticket seeder bugs #11090
fix: [M3-8739] - Fix MSW 2.0 initial mock store and support ticket seeder bugs #11090
Conversation
Coverage Report: ✅ |
|
||
// Return the existing mockState if it includes all keys from the empty store; | ||
// else, discard the existing mockState because we've introduced new values. | ||
if (emptyStoreKeys.every((key) => mockStateKeys.includes(key))) { |
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.
Fix: Ensure that every empty store key is represented in mock state.
Note: I didn't compare the number of keys in the empty store and mock state, because mock state seems to always get an id
key added that is not part of the empty store. (See screenshots in testing section to see it.) I am not quite sure the purpose of the id
but am sure they're useful for something and maybe @abailly-akamai can clarify.
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.
@mjac0bs it is how IndexedDB works - it's meant to behave like a DB to it has auto ID increment. We're not really using indexedDB the way it's supposed to, I just used this storage solution as a blob store
7fc4177
to
2580fdf
Compare
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.
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.
Thanks @mjac0bs ! confirmed this fixes the error we were seeing
Cloud Manager E2E Run #6697
Run Properties:
|
Project |
Cloud Manager E2E
|
Run status |
Passed #6697
|
Run duration | 45m 50s |
Commit |
1d622f4c37: fix: [M3-8739] - Fix MSW 2.0 initial mock store and support ticket seeder bugs (...
|
Committer | Mariah Jacobs |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
4
|
Pending |
2
|
Skipped |
0
|
Passing |
438
|
Description 📝
This PR fixes an existing bug in the way the MSW2.0 was creating the initial mock store. It made itself known after #10937 was merged because that's the first time that many of us already had an existing store, and now new values were being added to it.
🐛 Bug:
When we are trying to create our initial mock store and access
initialContext.supportReplies
orinitialContext.supportTickets
, developers were encountering a console error and white screen if they already had an existing IndexedDB that did not havesupportReplies
orsupportTickets
in the mockStore. This could be worked around by clearing the Application data in the browser console to reset the IndexedDB, but it would continue to happen in the future with every new set of values we track in the store.❓ Why:
This was happening due to the logic in
createInitialMockStore
. We already had old mock state (even when it is just a bunch of empty lists), so we return it asinitialContext
. It doesn't includesupportReplies
orsupportTickets
. When we have new values, we need theinitialContext
to be the emptyStore, which has the empty key-value pair for those new values.🔧 Fix:
Adding a conditional check ensure the mockState and emptyStore keys are the same before returning that mockState. If the keys aren't the same, there's new entities to include in the mock store, so disregard the old store.
Changes 🔄
createInitialMockStore
to return an emptyStore if there's new values to create in the storeremoveSeeder
function for consistency - it was an oversight in the original PR.How to test 🧪
Prerequisites
(How to setup test environment)
Reproduction steps
packages/manager/src/mocks/types.ts
and makesupportTickets
andsupportReplies
optional types.packages/manager/src/mocks/mockState.ts
and comment outsupportReplies
andsupportTickets
in theemptyStore
.supportReplies
andsupportTickets
(browser dev tools > Application > Storage > IndexedDB > mockStateVerification steps
(How to verify changes)
git restore .
supportReplies
andsupportTickets
Video
Screen.Recording.2024-10-10.at.4.52.32.PM.mov
Screen.Recording.2024-10-10.at.4.54.20.PM.mov
As an Author I have considered 🤔
Check all that apply