-
-
Notifications
You must be signed in to change notification settings - Fork 734
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: show all envs in project tables unless you've explicitly hidden some #6812
Changes from 6 commits
3d25a4d
ec87c17
a01b6cf
2a34708
20c986c
9559f6f
e76d3cc
dbd1800
19037a3
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,74 @@ | ||
import theme from 'themes/theme'; | ||
import { screen } from '@testing-library/react'; | ||
import { useDefaultColumnVisibility } from './useDefaultColumnVisibility'; | ||
import { render } from 'utils/testRenderer'; | ||
import { ThemeProvider } from 'themes/ThemeProvider'; | ||
import mediaQuery from 'css-mediaquery'; | ||
|
||
const createMatchMedia = (width: number) => { | ||
return (query: string) => { | ||
return { | ||
matches: mediaQuery.match(query, { width }), | ||
media: '', | ||
addListener: () => {}, | ||
removeListener: () => {}, | ||
onchange: () => {}, | ||
addEventListener: () => {}, | ||
removeEventListener: () => {}, | ||
dispatchEvent: () => true, | ||
}; | ||
}; | ||
}; | ||
|
||
const resizeScreen = (width: number) => { | ||
window.matchMedia = createMatchMedia(width); | ||
}; | ||
|
||
const columnIds = [ | ||
'select', | ||
'favorite', | ||
'name', | ||
'createdAt', | ||
'lastSeenAt', | ||
'environment:development', | ||
'environment:production', | ||
'environment:dev2', | ||
'environment:prod2', | ||
'environment:staging', | ||
'environment:test', | ||
'actions', | ||
]; | ||
|
||
const TestComponent: React.FC = () => { | ||
const columns = useDefaultColumnVisibility(columnIds); | ||
|
||
return ( | ||
<ThemeProvider> | ||
<ul data-testid='wrapper'> | ||
{Object.keys(columns).map((column) => ( | ||
<li key={column}>{column}</li> | ||
))} | ||
</ul> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
test.each(Object.keys(theme.breakpoints.values))( | ||
'it renders all envs on %s screens', | ||
(screenSize) => { | ||
resizeScreen( | ||
theme.breakpoints.values[ | ||
screenSize as keyof typeof theme.breakpoints.values | ||
] + 1, | ||
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. I suspect we have an off-by-one issue here. If you cut a stick in 2 places, how many sticks you will end up with? It's the same with breakpoints. 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. That's a fair point. But I had in fact thought of this. The thing is, assuming I'm looking at the right file ( breakpoints: {
values: {
xs: 0,
sm: 600,
md: 960,
lg: 1280,
xl: 1536,
},
}, So in this case, the smallest size we set for the screen is 1 pixel. The way I read this, Am I making sense? 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. Or, the breakpoint values are defined by their lower bound. 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. O, perfect, thanks for clarification 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. In theory, we could probably skip the +1, but that just means we avoid any weird edge cases if we use strictly vs greater than or equal to |
||
); | ||
render(<TestComponent />); | ||
|
||
const allEnvs = columnIds.filter((column) => | ||
column.startsWith('environment:'), | ||
); | ||
|
||
for (const env of allEnvs) { | ||
screen.getByText(env); | ||
} | ||
}, | ||
); |
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 is the actual fix to the problem. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1399,6 +1399,11 @@ | |
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/css-mediaquery@^0.1.4": | ||
version "0.1.4" | ||
resolved "https://registry.yarnpkg.com/@types/css-mediaquery/-/css-mediaquery-0.1.4.tgz#8efbebbc0cebaf34c77db2b63892711e19143c63" | ||
integrity sha512-DZyHAz716ZUctpqkUU2COwUoZ4gI6mZK2Q1oIz/fvNS6XHVpKSJgDnE7vRxZUBn9vjJHDVelCVW0dkshKOLFsA== | ||
|
||
"@types/express-serve-static-core@^4.17.31": | ||
version "4.17.32" | ||
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz#93dda387f5516af616d8d3f05f2c4c79d81e1b82" | ||
|
@@ -2612,6 +2617,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.3: | |
shebang-command "^2.0.0" | ||
which "^2.0.1" | ||
|
||
css-mediaquery@^0.1.2: | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/css-mediaquery/-/css-mediaquery-0.1.2.tgz#6a2c37344928618631c54bd33cedd301da18bea0" | ||
integrity sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q== | ||
|
||
[email protected]: | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" | ||
|
@@ -6758,16 +6768,7 @@ string-length@^4.0.1: | |
char-regex "^1.0.2" | ||
strip-ansi "^6.0.0" | ||
|
||
"string-width-cjs@npm:string-width@^4.2.0": | ||
version "4.2.3" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" | ||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== | ||
dependencies: | ||
emoji-regex "^8.0.0" | ||
is-fullwidth-code-point "^3.0.0" | ||
strip-ansi "^6.0.1" | ||
|
||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: | ||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: | ||
version "4.2.3" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" | ||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== | ||
|
@@ -6806,14 +6807,7 @@ string_decoder@~1.1.1: | |
dependencies: | ||
safe-buffer "~5.1.0" | ||
|
||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1": | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
dependencies: | ||
ansi-regex "^5.0.1" | ||
|
||
strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
|
@@ -7425,7 +7419,7 @@ wordwrap@>=0.0.2: | |
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" | ||
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== | ||
|
||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": | ||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
|
@@ -7443,15 +7437,6 @@ wrap-ansi@^6.2.0: | |
string-width "^4.1.0" | ||
strip-ansi "^6.0.0" | ||
|
||
wrap-ansi@^7.0.0: | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
dependencies: | ||
ansi-styles "^4.0.0" | ||
string-width "^4.1.0" | ||
strip-ansi "^6.0.0" | ||
|
||
wrap-ansi@^8.1.0: | ||
version "8.1.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" | ||
|
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 bit allows us to resize the screen in the tests (based on this article that I found). I'm wondering whether we should extract it into a separate file or leave it here for now.