-
Notifications
You must be signed in to change notification settings - Fork 361
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-8602] - Fix plan-selection.spec.ts
test failures on retries
#10976
Changes from 4 commits
a90aba8
a2dc516
4d1de76
e3f339f
bacd56d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Fix plan selection test always failing on reattempts ([#10976](https://github.com/linode/manager/pull/10976)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; | ||
import MuiAutocomplete from '@mui/material/Autocomplete'; | ||
import React from 'react'; | ||
import React, { useCallback } from 'react'; | ||
|
||
import { Box } from 'src/components/Box'; | ||
import { TextField } from 'src/components/TextField'; | ||
|
@@ -17,6 +17,7 @@ import { | |
import type { AutocompleteProps } from '@mui/material/Autocomplete'; | ||
import type { SxProps } from '@mui/system'; | ||
import type { TextFieldProps } from 'src/components/TextField'; | ||
import type { PopperProps } from '@mui/base'; | ||
|
||
export interface EnhancedAutocompleteProps< | ||
T extends { label: string }, | ||
|
@@ -108,11 +109,17 @@ export const Autocomplete = < | |
|
||
const optionsWithSelectAll = [selectAllOption, ...options] as T[]; | ||
|
||
/* Memoize popper callback to prevent unnecessary popper re-rendering. */ | ||
const customPopper = useCallback( | ||
(props: PopperProps) => { | ||
return <CustomPopper {...props} sx={sxPopperComponent} />; | ||
}, | ||
[sxPopperComponent] | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a suggestion I saw on a StackOverflow thread, but hoping that somebody with more React expertise than me could take a look at this and double check that this is a sensible solution. It seems to make the tests very happy, and I didn't notice any regressions during my manual testing, but I'd be lying if I said I fully understand the implications of wrapping this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey Joe! Take a look at #10978. Do you think this could be a better way to approach it and would it fix the unexpected re-render / arrow function issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you @bnussman-akamai! Commented on your PR, but I think your solution is hands down better: it fixes the test failures and I'm guessing it's a lot more idiomatic / in line with the way we normally do things. Happy to either integrate your implementation into this PR or let you take the reins with #10978! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jdamore-linode Do you happen to have the link to the StackOverflow thread? I'm curious why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @carrillo-erik not on hand, no -- I could try to find it, but I was already a bit doubtful about |
||
return ( | ||
<MuiAutocomplete | ||
PopperComponent={(props) => { | ||
return <CustomPopper {...props} sx={sxPopperComponent} />; | ||
}} | ||
PopperComponent={customPopper} | ||
options={ | ||
multiple && !disableSelectAll && options.length > 0 | ||
? optionsWithSelectAll | ||
|
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.
Using
before
here instead ofbeforeEach
causes the mocks not to get applied on re-attempts which leads to failures.The initial failure is caused by the
cy.click()
issue, butplan-selection.spec.ts
failures are overrepresented in CI due to the re-attempts being guaranteed to fail.