Conversation
|
I still need to resolve this error (which makes no sense to me yet. its talking about some other name?) |
|
🤖 Vercel preview here: https://docs-1udnodud2-goteleport.vercel.app/docs/ver/preview |
|
🤖 Vercel preview here: https://docs-p8zhhqtag-goteleport.vercel.app/docs/ver/preview |
ravicious
left a comment
There was a problem hiding this comment.
Geez, that's a ton of work with those msw changes. 🥵 Thanks a ton for doing this.
| plugin.name !== 'teleport-html-plugin' && | ||
| plugin.name !== 'teleport-transform-html-plugin' | ||
| plugin.name !== 'teleport-transform-html-plugin' && | ||
| plugin.name !== 'storybook:react-docgen-plugin' |
There was a problem hiding this comment.
Could you leave a comment explaining why we need to do this?
There was a problem hiding this comment.
We don't have to disable this plugin. It didn't work because Storybook still uses babel for the Vite framework and our babel config wasn't fully configured.
After I added typescript preset to it, the errors gone away (I have it in the patch above).
| msw: { | ||
| handlers: [ | ||
| rest.get(cfg.api.nodesPath, (req, res, ctx) => { | ||
| return res.once(ctx.json({ items: [] })); |
There was a problem hiding this comment.
PollingSuccess was not the only story that was supposed to use res.once. AFAIK, at the time of the upgrade to v7, all of the uses of res.once in teleport.e were unnecessary (see https://github.com/gravitational/teleport.e/pull/3256/commits/5d0367d6cceedc71a62f7fe425873820ca6df1c0), but there was a couple of places in OSS that actually do needed it.
Could you go through them on master and add { once: true } where necessary? I found that just going to the web dir and grepping for res.once is good enough.
| coverageReporters: ['text-summary', 'lcov'], | ||
| testPathIgnorePatterns: ['e2e'], | ||
| testEnvironmentOptions: { | ||
| customExportConditions: [''], |
There was a problem hiding this comment.
it had to do with the setupServer from msw but, I never got that working anyway. I'll fiddle around with those tests some more and if this is needed, I'll add a comment
There was a problem hiding this comment.
yes we do still need it for setupServer in our tests. More info here in migration guide
https://mswjs.io/docs/migrations/1.x-to-2.x/#cannot-find-module-mswnode-jsdom
|
I think I'll need another set of eyes on this So far, everything seems to match the migration guide. I'm sure it's a small config issue I'm not seeing |
There was a problem hiding this comment.
I think we don't need this package.
There was a problem hiding this comment.
It works without getAbsolutePath too.
| plugin.name !== 'teleport-html-plugin' && | ||
| plugin.name !== 'teleport-transform-html-plugin' | ||
| plugin.name !== 'teleport-transform-html-plugin' && | ||
| plugin.name !== 'storybook:react-docgen-plugin' |
There was a problem hiding this comment.
We don't have to disable this plugin. It didn't work because Storybook still uses babel for the Vite framework and our babel config wasn't fully configured.
After I added typescript preset to it, the errors gone away (I have it in the patch above).
|
Applied and patch and removed the extra loaders/initialize callsites. the rest of the stories are much smoother/work more reliably but the SetupConnect/PollingSuccess still breaks horrendously and then any story used after is broke. Diving in more |
|
I still need to fix the
|
There was a problem hiding this comment.
this was required to make the theme switcher work again
There was a problem hiding this comment.
we also have really old files that end in jsx, i put js just in case?
fa6fb1b to
abb94e4
Compare
|
i clicked through every story and fixed almost everything (EXCEPT teleterm... i couldn't handle it anymore, so i'll leave those to rafal or gz): see abb94e4 and https://github.com/gravitational/teleport.e/pull/3256/commits/ba1271c6faff653308e03292dcaacef918c8a1be
Here are some things i noticed:
|
There was a problem hiding this comment.
this was required for the styled-component css attribute to work
There was a problem hiding this comment.
Hmm, the comment says we don't use reactPlugin, yet it's clearly used here. What don't I understand?
(Also: would you mind putting this statement directly into the code comment?)
There was a problem hiding this comment.
I'm not sure why this happens. Looks like babel-plugin-styled-components is not transforming the css prop (but I believe it should). I couldn't find anything useful in the storybook docs and issues, but I will keeping looking.
There was a problem hiding this comment.
i don't understand it either, i just removed the comment for now
There was a problem hiding this comment.
I gave up on that, I don't know why it doesn't work with the babel plugin alone. I only corrected the mode passed to the react plugin.
There was a problem hiding this comment.
I get this when I open http://localhost:9002/?path=/story/teleport-discover-connectmycomputer-setupconnect--polling (which is a completely different story).
[MSW] Uncaught exception in the request handler for "GET http://localhost:9002/packages/teleport/src/Discover/ConnectMyComputer/TestConnection/TestConnection.story.tsx":
(bunch of indecipherable stacktrace)
This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error, as it indicates a mistake in your code. If you wish to mock an error response, please see this guide: https://mswjs.io/docs/recipes/mocking-error-responses
This seems like Vite failing when Storybook asks for that file. @gzdunek I believe not importing the general vite config might be a good idea, but it looks like we're missing something still.
There was a problem hiding this comment.
an api path with query params (with a question mark), makes stories break (and it starts breaking other stories). i found this issue which i took it to mean it's not supported (how did it work before)? i worked around this by stripping the affected path anything after the
?
It might have been something related to msw 1.x, I vaguely remember getting this error in v7 update but I'm not sure.
Currently, I see this when I open http://localhost:9002/?path=/story/teleporte-accesslists-list--list-unlimited.
[MSW] Found a redundant usage of query parameters in the request handler URL for "GET /v1/webapi/roles?startKey=&search=&limit=". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters
It comes from e/web/teleport/src/AccessListManagement/CreateAccessList/CreateAccessList.story.tsx.
I believe we should figure out why it was working, why it got broken, and how we're going to address this. Manually splitting the path in each story might not be the best way long term.
There was a problem hiding this comment.
Perhaps it'd be possible to override cfg.api within storybook so that it returns some kind of a proxy object with a custom getter that always strips the query params?
Maybe there's a simpler way to replace the whole cfg.api in storybook with a version that doesn't use query params. We probably don't want to touch teleport/src/config.ts itself that much.
There was a problem hiding this comment.
I believe we can setup something that will remove query params. i saw it somewhere in the msw docs, I'll look around again today
There was a problem hiding this comment.
It would be nice if the query params weren't in the cfg, it's one of the things blocking the upgrade to react-router 6 😔
Completely out of scope for this PR though of course
|
Removing the query param made most of the stories ( The next step is finding out how to handle missing web assets? althought it isn't really breaking stories for me. I go to the locked access requests story and the images are there and works. It's actually all running for me quite well now. I'll happily update all the stories that use query param urls if we are ok with this solution. i was hoping that we'd be able to somehow update the handler to do it for us automatically but then i realized that some stories might want access to the unfiltered query params so, i think just doing it manual is fine. |
|
I'll rebase this onto the pnpm master today |
|
In general, stories seem to work now. stories with I disabled one test because jest gets rid of a bunch of globals that |
b999365 to
619fdf2
Compare
There was a problem hiding this comment.
As mentioned on Slack, it might be better to move that to the patched JSDOM env. If that doesn't work, the file with test setup for Jest would be another good candidate.
There was a problem hiding this comment.
the patched JSDOM didn't work, but putting into setup test for jest did
There was a problem hiding this comment.
This shouldn't have been changed
There was a problem hiding this comment.
We don't need this polyfill.
There was a problem hiding this comment.
it's used in an external script but perhaps it can be removed from here
There was a problem hiding this comment.
I think we can rollback all changes in this file? We no longer have VITE_NO_PROXY.
There was a problem hiding this comment.
I gave up on that, I don't know why it doesn't work with the babel plugin alone. I only corrected the mode passed to the react plugin.
There was a problem hiding this comment.
As mentioned on Slack, it might be better to move that to the patched JSDOM env. If that doesn't work, the file with test setup for Jest would be another good candidate.
There was a problem hiding this comment.
I'm not sure if this needs to be here. 🤔
There was a problem hiding this comment.
the vite config filein storybook wasn't able to find this package without having this here. i could use relative paths but i wanted to keep the import cleaner
f0ac6fa to
43589b1
Compare
New branch which brings in the changes from #37331 . It was easier to do it this way over a rebase since the OG pr is a bit out of date
enterprise: https://github.com/gravitational/teleport.e/pull/3256
Closes gravitational/teleport-private#1494