Skip to content

Commit

Permalink
fix(test): infinite routing (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdebon committed Dec 13, 2022
1 parent ddb40e1 commit 5bea7a1
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 59 deletions.
11 changes: 1 addition & 10 deletions apps/console/src/main.tsx
@@ -1,5 +1,4 @@
import { AppState, Auth0Provider } from '@auth0/auth0-react'
import { createBrowserHistory } from 'history'
import { Auth0Provider } from '@auth0/auth0-react'
import posthog from 'posthog-js'
import { createRoot } from 'react-dom/client'
import { Provider } from 'react-redux'
Expand All @@ -11,18 +10,11 @@ import { store } from '@qovery/store'
import App from './app/app'
import { environment } from './environments/environment'

export const history = createBrowserHistory()

// posthog init
posthog.init(environment.posthog, {
api_host: environment.posthog_apihost,
})

const onRedirectCallback = (appState: AppState | undefined) => {
// use the router's history module to replace the url
//history.replace(appState?.returnTo || window.location.pathname)
}

const container = document.getElementById('root') || document.createElement('div')
const root = createRoot(container)

Expand All @@ -35,7 +27,6 @@ root.render(
redirectUri={`${window.location.origin}${LOGIN_URL}${LOGIN_AUTH_REDIRECT_URL}`}
audience={environment.oauth_audience}
useRefreshTokens={true}
onRedirectCallback={onRedirectCallback}
cacheLocation={'localstorage'}
>
<Provider store={store}>
Expand Down
@@ -1,18 +1,22 @@
import { render } from '__tests__/utils/setup-jest'
import { Route, Routes } from 'react-router-dom'
import PageApplicationCreateFeature from './page-application-create-feature'

jest.mock('react-router-dom', () => ({
...(jest.requireActual('react-router') as any),
useParams: () => ({ organizationId: '1', projectId: '2', environmentId: '3' }),
}))

describe('PageApplicationCreateFeature', () => {
it('should render successfully', () => {
// const { baseElement } = render(
// <Routes location="/organization/1/project/2/environment/3/services/create">
// <Route
// path="/organization/1/project/2/environment/3/services/create/*"
// element={<PageApplicationCreateFeature />}
// />
// </Routes>
// )
// expect(baseElement).toBeTruthy()
const { baseElement } = render(
<Routes location="/organization/1/project/2/environment/3/services/create/general">
<Route
path="/organization/1/project/2/environment/3/services/create/*"
element={<PageApplicationCreateFeature />}
/>
</Routes>
)
expect(baseElement).toBeTruthy()
})
})
@@ -1,18 +1,22 @@
import { render } from '__tests__/utils/setup-jest'
import { Route, Routes } from 'react-router-dom'
import PageDatabaseCreateFeature from './page-database-create-feature'

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router'),
useParams: () => ({ organizationId: '1', projectId: '2', environmentId: '3' }),
}))

describe('PageDatabaseCreateFeature', () => {
it('should render successfully', () => {
// const { baseElement } = render(
// <Routes location="/organization/1/project/2/environment/3/services/create/database">
// <Route
// path="/organization/1/project/2/environment/3/services/create/database/*"
// element={<PageDatabaseCreateFeature />}
// />
// </Routes>
// )
// expect(baseElement).toBeTruthy()
const { baseElement } = render(
<Routes location="/organization/1/project/2/environment/3/services/create/database/general">
<Route
path="/organization/1/project/2/environment/3/services/create/database/*"
element={<PageDatabaseCreateFeature />}
/>
</Routes>
)
expect(baseElement).toBeTruthy()
})
})
16 changes: 10 additions & 6 deletions libs/pages/settings/src/lib/page-settings.spec.tsx
@@ -1,3 +1,7 @@
import { render } from '__tests__/utils/setup-jest'
import { Route, Routes } from 'react-router-dom'
import PageSettings from './page-settings'

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router'),
Link: 'Link',
Expand All @@ -6,11 +10,11 @@ jest.mock('react-router-dom', () => ({

describe('PagesSettings', () => {
it('should render successfully', () => {
// const { baseElement } = render(
// <Routes location="/organization/1/settings">
// <Route path="/organization/1/settings/*" element={<PagesSettings />} />
// </Routes>
// )
// expect(baseElement).toBeTruthy()
const { baseElement } = render(
<Routes location="/organization/1/settings/general">
<Route path="/organization/1/settings/*" element={<PageSettings />} />
</Routes>
)
expect(baseElement).toBeTruthy()
})
})
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -22,11 +22,11 @@
"@nrwl/eslint-plugin-nx": "15.0.3",
"@nrwl/linter": "15.1.0",
"@nrwl/nx-cloud": "15.0.2",
"@nrwl/react": "15.0.3",
"@nrwl/storybook": "15.0.3",
"@nrwl/tao": "15.0.3",
"@nrwl/workspace": "15.0.3",
"@nrwl/web": "15.0.3",
"@nrwl/react": "15.0.3",
"@nrwl/workspace": "15.0.3",
"@radix-ui/react-accordion": "^0.1.6",
"@radix-ui/react-dialog": "^1.0.2",
"@radix-ui/react-slider": "^1.0.0",
Expand All @@ -49,7 +49,6 @@
"date-fns": "^2.29.3",
"date-fns-tz": "^1.3.7",
"fast-deep-equal": "^3.1.3",
"history": "^5.2.0",
"logrocket": "^3.0.1",
"msw": "^0.42.1",
"postcss": "8.4.16",
Expand All @@ -62,7 +61,7 @@
"react-hook-form": "^7.34.2",
"react-hot-toast": "^2.4.0",
"react-redux": "8.0.2",
"react-router-dom": "6.4.1",
"react-router-dom": "^6.4.5",
"react-select": "^5.3.2",
"react-use-intercom": "^1.5.2",
"react-use-websocket": "^4.2.0",
Expand Down
22 changes: 1 addition & 21 deletions yarn.lock
Expand Up @@ -3139,11 +3139,6 @@
redux-thunk "^2.4.1"
reselect "^4.1.5"

"@remix-run/router@1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.0.1.tgz#88d7ac31811ab0cef14aaaeae2a0474923b278bc"
integrity sha512-eBV5rvW4dRFOU1eajN7FmYxjAIVz/mRHgUE9En9mBn6m3mulK3WTR5C3iQhL9MZ14rWAq+xOlEaCkDiW0/heOg==

"@remix-run/router@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.0.5.tgz#d5c65626add4c3c185a89aa5bd38b1e42daec075"
Expand Down Expand Up @@ -16997,29 +16992,14 @@ react-remove-scroll@2.5.5:
use-callback-ref "^1.3.0"
use-sidecar "^1.1.2"

react-router-dom@6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.4.1.tgz#99c9b7c4967890701c888517475aa5d54d25760e"
integrity sha512-MY7NJCrGNVJtGp8ODMOBHu20UaIkmwD2V3YsAOUQoCXFk7Ppdwf55RdcGyrSj+ycSL9Uiwrb3gTLYSnzcRoXww==
dependencies:
"@remix-run/router" "1.0.1"
react-router "6.4.1"

react-router-dom@^6.0.0:
react-router-dom@^6.0.0, react-router-dom@^6.4.5:
version "6.4.5"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.4.5.tgz#4fdb12efef4f3848c693a76afbeaed1f6ca02047"
integrity sha512-a7HsgikBR0wNfroBHcZUCd9+mLRqZS8R5U1Z1mzLWxFXEkUT3vR1XXmSIVoVpxVX8Bar0nQYYYc9Yipq8dWwAA==
dependencies:
"@remix-run/router" "1.0.5"
react-router "6.4.5"

react-router@6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.4.1.tgz#dd9cc4dfa264751d143a4b6c9d4faa60ab3ce26c"
integrity sha512-OJASKp5AykDWFewgWUim1vlLr7yfD4vO/h+bSgcP/ix8Md+LMHuAjovA74MQfsfhQJGGN1nHRhwS5qQQbbBt3A==
dependencies:
"@remix-run/router" "1.0.1"

react-router@6.4.5, react-router@^6.0.0:
version "6.4.5"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.4.5.tgz#73f382af2c8b9a86d74e761a7c5fc3ce7cb0024d"
Expand Down

0 comments on commit 5bea7a1

Please sign in to comment.