-
Notifications
You must be signed in to change notification settings - Fork 357
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
refactor: [M3-8291] - Enforce Factory.each to start increment at 1
#10619
Conversation
@@ -63,7 +63,7 @@ describe('database current configuration section', () => { | |||
getByText('1 GB'); | |||
|
|||
getByText('CPUs'); | |||
getByText('2'); | |||
getByText('4'); |
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.
because of databaseTypeFactory
:
vcpus: Factory.each((i) => i * 2)
@@ -118,7 +168,7 @@ describe('KubeCheckoutBar', () => { | |||
); | |||
|
|||
// 5 node pools * 3 linodes per pool * 12 per linode * 20% increase for Jakarta + UNKNOWN_PRICE | |||
await findByText(/\$180\.00/); | |||
await findByText(/\$183\.00/); |
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.
no entirely sure about how the prices are calculated but considering id: 0
k8 type may not have been taken into consideration before i assume this is right.
const stackscript = stackScriptFactory.build(); | ||
const stackscript = stackScriptFactory.build({ | ||
id: 1234, | ||
}); |
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.
avoiding multiple 1
assertions on the page
margin: 0, | ||
}, | ||
'-moz-appearance': 'textfield', | ||
MozAppearance: 'textfield', |
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.
unrelated to PR but was really tired to see this warning in the logs 🧹
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.
This has annoyed me forever too! 🙌
@@ -74,8 +77,9 @@ describe('ImageSelect', () => { | |||
describe('ImageSelect component', () => { | |||
it('should render', () => { | |||
const { getByText } = renderWithTheme(<ImageSelect {...props} />); | |||
getByText(/image-0/i); | |||
getByText(/image-1(?!\d)/i); |
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.
avoid matching image-10
Coverage Report: ✅ |
}, | ||
writable: false, | ||
}); | ||
} |
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.
@jdamore-linode this unblocks the issues we'll encounter with MSW however cypress is rather unhappy with overriding Factory.each.
We have a few options:
- We find a way for cypress to accept the override (if you remove this check you'll see every test with a factory fail)
- we go away from overriding the property and go a route of wrapping our factories in an HOC or use a custom
Each
for every factory or just add +1 everywhere, which I wanted to avoid - we leave as is and keep this change out of cypress
Thoughts?
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.
@jdamore-linode please see 886d981 and let me know what you think! I think this is clear and elegant enough to satisfy the requirements and have cypress benefit from this update
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.
Tests pass in CI (I did observe a handful of failures locally) ✅
packages/manager/.changeset/pr-10619-tech-stories-1719459021760.md
Outdated
Show resolved
Hide resolved
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.
packages/manager/src/features/Linodes/LinodesLanding/utils.test.ts
Outdated
Show resolved
Hide resolved
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, thanks for taking this on @abailly-akamai! Approved pending unit tests passing (seems there's currently a GHA incident which I'm assuming is the reason those jobs haven't run)
Description 📝
This PR makes sure
Factory.each
always start iterating from1
rather than0
. Having falsy entity IDs is responsible for for a few issues (unit tests false positives in, disabling queries based on a truthy entity id) and will help us with our "Next Gen MSW ©" where we will generate new entities based on factories and those can't have0
as an id.In order to do so I added a monkey patch (run time modifier) for
Factory.each
so that it increments from1
in every factory without having to modify every factory instance. This means not only IDs but also every value relying on aneach
was modified. As a result, many tests asserting either for some order, value or array length needed to be updated. It also surfaced a few issues with some tests, tho more could have been fixed (outside of scope for this PR).This PR does not touch any consumer code.
Changes 🔄
each
to increment from 1How to test 🧪
Verification steps
yarn test
and confirm all tests are passing locally and in CIAs an Author I have considered 🤔
Check all that apply