-
Notifications
You must be signed in to change notification settings - Fork 1
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
[DR-3123] Migrate to vite #1475
Conversation
d2883a4
to
4384ecb
Compare
The test datasets/snapshots used by the e2e tests exist but for some reason are not accessible to the test user (I can't access them with my dev account either). I created new ones in int-6 as a temporary work-around so I could run/fix the e2e tests locally, so they should pass once we can sort out the issue with int-4 and int-5! |
9e599f1
to
d5f8f36
Compare
The SonarCloud failure can be resolved by generating a hash for our fontawesome kit "https://kit.fontawesome.com/316fe749fb.js", but I get a 403 error when I try to do that (I used this website: https://www.srihash.org/). Does anyone have access? Or should I create a new custom kit? |
@samanehsan that FontAwesome question rings a bell, I'm not sure if this is possible :( From @snf2ye in February '23:
|
Thanks @okotsopoulos! That's helpful context! I'll mark that script as excluded |
d5f8f36
to
678f95c
Compare
I think the e2e tests aren't running because it waits on |
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.
I'm noticing a lot more casting than was there before - is this a result of the libraries changing? Casting like that can sometimes be a code smell, so I am curious if you know where its coming from.
cy.get('div#__cy_root > div > p').should('contain.text', 'A bad day'); | ||
cy.get('div#__cy_root > div > p').children().should('have.length', 0); | ||
cy.root().should('have.length', 1); | ||
cy.root().get('p').should('contain.text', 'A bad day'); |
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.
Just as a note, do you think this sort of test could maybe be simplified by doing a findByText on the page? That is what Terra-UI does
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.
Ah oops I missed this comment! It turns out findByText
requires another dependency so I'm inclined to leave it out for now if that's okay
@@ -1,5 +1,4 @@ | |||
import { CloudPlatform } from 'generated/tdr'; | |||
import _ from 'lodash'; |
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.
I'm surprised you can remove the import from lodash without any other changes to the file. Do you have any linting for unused imports?
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.
Good point! Our eslint rules don't include unused imports so I created a ticket for that: https://broadworkbench.atlassian.net/browse/DR-3176
// Don't reset state if the only change was query parameters | ||
const path = action.payload?.location?.pathname; | ||
if (path === state.lastPath) { | ||
return immutable(state, { | ||
lastPath: { $set: path }, | ||
}); | ||
lastPath: { $set: path as string }, |
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.
I'm surprised you have to do the casts here. Does typescript not type interpolate correctly for these?
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.
Yeah, weirdly there were a couple of places where the type couldn't be inferred and without making it explicit the server wouldn't run
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.
Ah, in this particular case it might be that it thinks path is string | undefined
given the ?s. Would you file a ticket to look into the specific casts? My guess is that they are resolvable using typescript but there may be some code structure changes needed.
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.
Here's the ticket! https://broadworkbench.atlassian.net/browse/DR-3177
- The gcloud libraries are not pinned to a version so we cannot use an integrity hash here - Fontawesome no longer supports SRI hashes
Also reenable linting on server start
ecb4cbe
to
fcbb24e
Compare
Work around wait-on 404 error Originally from: vitejs/vite#9520 (comment)
80fb251
to
7040f9f
Compare
7d41e77
to
2d265f2
Compare
Passing run #2946 ↗︎
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
de01eeb
to
6b514bc
Compare
Fixes build issue with vite
6b514bc
to
5b487a0
Compare
@@ -7,7 +7,7 @@ export const sagaMiddleware = createSagaMiddleware(); | |||
const middleware = [sagaMiddleware]; | |||
|
|||
/* istanbul ignore next */ | |||
if (process.env.NODE_ENV === 'development') { | |||
if (import.meta.env.DEV) { |
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 env variable is provided by Vite by default: https://vitejs.dev/guide/env-and-mode.html#env-variables
vite builds production by default
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
The "process not defined" issue causing the e2e tests to fail was due to to the version of jsondiffpatch we were using. Updating to the latest version fixed the issue! 🎉 |
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.
LGTM
# Copy the local code | ||
COPY . / | ||
# Copy the generated code | ||
COPY --from=codegen /local / | ||
# Run the build | ||
RUN export DISABLE_ESLINT_PLUGIN=true && \ | ||
npm ci && \ | ||
npm run build-no-code-gen --production |
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.
Is this flag removed?
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.
The --production
flag isn't needed because vite build
uses production by default
package.json
Outdated
@@ -24,6 +24,10 @@ | |||
"dependencies": { | |||
"@babel/runtime": "^7.21.5", | |||
"@codemirror/lang-javascript": "^6.1.5", | |||
"@cypress/vite-dev-server": "^5.0.5", |
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.
I believe there are some deps that can be moved to devDependencies
. This isn't a big deal, but more for package.json
hygiene
Feel free to do this in a follow up PR
package.json
Outdated
"classlist-polyfill": "^1.2.0", | ||
"clsx": "^1.1.0", | ||
"connected-react-router": "^6.9.3", | ||
"cypress": "^9.7.0", | ||
"cypress": "^12.17.3", |
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 can be moved to devDependencies
package.json
Outdated
@@ -97,25 +98,27 @@ | |||
"tss-react": "^4.8.4", | |||
"typescript": "^5.0.4", | |||
"validator": "^13.9.0", | |||
"vite": "^4.4.9", |
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.
I believe vite
can be moved to devDepenendcies
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR updates the UI to use Vite instead of create react app (
react-scripts
is one of the dependencies, which has not been maintained for over a year and contains a security vulnerability: https://broadworkbench.atlassian.net/browse/DR-3123).Some things to note:
I also updated Cypress from version 9 -> 12, which supports the latest version of Vite. This involved:
cypress.json
withcypress.config.ts
cypress/plugins/index.js
filecypress/support/component-index.html
file (where the component test html gets rendered)