Skip to content

Commit

Permalink
fix: #234 remove snapshot for login page due to only show tab on PROD (
Browse files Browse the repository at this point in the history
  • Loading branch information
duong-se authored Feb 13, 2020
1 parent e33e706 commit 4084938
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ exports[`Router should match a snapshot 1`] = `
Array [
"/developer/login",
"/admin/login",
"/client/login",
]
}
render={[Function]}
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/src/core/__tests__/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Router from '../router'

describe('Router', () => {
it('should match a snapshot', () => {
process.env.REAPIT_ENV = 'DEV'
expect(shallow(<Router />)).toMatchSnapshot()
})
})
183 changes: 97 additions & 86 deletions packages/marketplace/src/core/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,92 +30,103 @@ const AdminAppsPage = React.lazy(() => import('../components/pages/admin-apps'))
const RegisterConfirm = React.lazy(() => import('../components/pages/register-confirm'))
const AdminStats = React.lazy(() => import('../components/pages/admin-stats'))

const reapitEnv = process.env.REAPIT_ENV || 'LOCAL'
const isReapitEnvProd = reapitEnv === 'PROD'
const Router = () => (
<BrowserRouter history={history}>
<React.Suspense fallback={null}>
<Switch>
<Route
path={[Routes.DEVELOPER_LOGIN, Routes.ADMIN_LOGIN, ...(isReapitEnvProd ? [] : [Routes.CLIENT_LOGIN])]}
exact
render={() => <Login />}
/>
<Route path={Routes.DEVELOPER_RESET_PASSWORD} component={ResetPassword} />
{/* <Route path={Routes.REGISTER} exact component={Register} /> */}
<Route path={Routes.REGISTER_CONFIRM} exact component={RegisterConfirm} />
<Route path={Routes.FORGOT_PASSWORD} component={ForgotPassword} />
<Route path={Routes.FOUR_O_FOUR} exact render={() => <Info infoType="404" />} />
<PrivateRouteWrapper path="/">
<Switch>
<PrivateRoute allow="CLIENT" path={Routes.INSTALLED_APPS_PAGINATE} component={InstalledApps} fetcher />
<PrivateRoute allow="CLIENT" path={Routes.INSTALLED_APPS} component={InstalledApps} fetcher exact />
<PrivateRoute allow="CLIENT" path={Routes.MY_APPS_PAGINATE} component={MyApps} fetcher />
<PrivateRoute allow="CLIENT" path={Routes.MY_APPS} component={MyApps} fetcher exact />
<PrivateRoute allow="CLIENT" path={Routes.CLIENT} component={Client} exact fetcher />
const Router = () => {
const isReapitEnvProd = process.env.REAPIT_ENV === 'PROD'
const paths = [Routes.DEVELOPER_LOGIN, Routes.ADMIN_LOGIN]
if (isReapitEnvProd) {
paths.push(Routes.CLIENT_LOGIN)
}
return (
<BrowserRouter history={history}>
<React.Suspense fallback={null}>
<Switch>
<Route path={paths} exact render={() => <Login />} />
<Route path={Routes.DEVELOPER_RESET_PASSWORD} component={ResetPassword} />
{/* <Route path={Routes.REGISTER} exact component={Register} /> */}
<Route path={Routes.REGISTER_CONFIRM} exact component={RegisterConfirm} />
<Route path={Routes.FORGOT_PASSWORD} component={ForgotPassword} />
<Route path={Routes.FOUR_O_FOUR} exact render={() => <Info infoType="404" />} />
<PrivateRouteWrapper path="/">
<Switch>
<PrivateRoute allow="CLIENT" path={Routes.INSTALLED_APPS_PAGINATE} component={InstalledApps} fetcher />
<PrivateRoute allow="CLIENT" path={Routes.INSTALLED_APPS} component={InstalledApps} fetcher exact />
<PrivateRoute allow="CLIENT" path={Routes.MY_APPS_PAGINATE} component={MyApps} fetcher />
<PrivateRoute allow="CLIENT" path={Routes.MY_APPS} component={MyApps} fetcher exact />
<PrivateRoute allow="CLIENT" path={Routes.CLIENT} component={Client} exact fetcher />

<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_MY_APPS} component={DeveloperHome} exact fetcher />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_MY_APPS_PAGINATE}
component={DeveloperHome}
exact
fetcher
/>
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_MY_APPS_EDIT}
component={DeveloperSubmitApp}
exact
fetcher
/>
<PrivateRoute allow="DEVELOPER" path={Routes.SUBMIT_APP} fetcher component={DeveloperSubmitApp} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_API_DOCS} exact component={ApiDocsPage} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_SWAGGER} exact component={SwaggerPage} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_ELEMENTS} exact component={ElementsPage} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_ANALYTICS} fetcher exact component={AnalyticsPage} />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_ANALYTICS_PAGINATE}
fetcher
exact
component={AnalyticsPage}
/>
<PrivateRoute allow="DEVELOPER" path={Routes.SETTINGS} fetcher exact component={SettingsPage} />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_WELCOME}
fetcher
exact
component={DeveloperWelcomePage}
/>
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_HELP} exact fetcher component={HelpPage} />

<PrivateRoute allow="ADMIN" path={Routes.ADMIN_APPROVALS} component={AdminApprovalsPage} exact fetcher />
<PrivateRoute allow="ADMIN" path={Routes.ADMIN_APPROVALS_PAGINATE} component={AdminApprovalsPage} fetcher />
<PrivateRoute allow="ADMIN" path={Routes.ADMIN_APPS} component={AdminAppsPage} fetcher exact />
<PrivateRoute
allow="ADMIN"
path={Routes.ADMIN_DEV_MANAGEMENT}
component={AdminDevManagementPage}
exact
fetcher
/>
<PrivateRoute
allow="ADMIN"
path={Routes.ADMIN_DEV_MANAGEMENT_PAGINATE}
component={AdminDevManagementPage}
exact
fetcher
/>
<PrivateRoute allow="ADMIN" path={Routes.ADMIN_STATS} component={AdminStats} exact fetcher />
<Route render={() => <Info infoType="404" />} />
</Switch>
</PrivateRouteWrapper>
<Redirect to={Routes.CLIENT_LOGIN} />
</Switch>
</React.Suspense>
</BrowserRouter>
)
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_MY_APPS} component={DeveloperHome} exact fetcher />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_MY_APPS_PAGINATE}
component={DeveloperHome}
exact
fetcher
/>
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_MY_APPS_EDIT}
component={DeveloperSubmitApp}
exact
fetcher
/>
<PrivateRoute allow="DEVELOPER" path={Routes.SUBMIT_APP} fetcher component={DeveloperSubmitApp} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_API_DOCS} exact component={ApiDocsPage} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_SWAGGER} exact component={SwaggerPage} />
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_ELEMENTS} exact component={ElementsPage} />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_ANALYTICS}
fetcher
exact
component={AnalyticsPage}
/>
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_ANALYTICS_PAGINATE}
fetcher
exact
component={AnalyticsPage}
/>
<PrivateRoute allow="DEVELOPER" path={Routes.SETTINGS} fetcher exact component={SettingsPage} />
<PrivateRoute
allow="DEVELOPER"
path={Routes.DEVELOPER_WELCOME}
fetcher
exact
component={DeveloperWelcomePage}
/>
<PrivateRoute allow="DEVELOPER" path={Routes.DEVELOPER_HELP} exact fetcher component={HelpPage} />

<PrivateRoute allow="ADMIN" path={Routes.ADMIN_APPROVALS} component={AdminApprovalsPage} exact fetcher />
<PrivateRoute
allow="ADMIN"
path={Routes.ADMIN_APPROVALS_PAGINATE}
component={AdminApprovalsPage}
fetcher
/>
<PrivateRoute allow="ADMIN" path={Routes.ADMIN_APPS} component={AdminAppsPage} fetcher exact />
<PrivateRoute
allow="ADMIN"
path={Routes.ADMIN_DEV_MANAGEMENT}
component={AdminDevManagementPage}
exact
fetcher
/>
<PrivateRoute
allow="ADMIN"
path={Routes.ADMIN_DEV_MANAGEMENT_PAGINATE}
component={AdminDevManagementPage}
exact
fetcher
/>
<PrivateRoute allow="ADMIN" path={Routes.ADMIN_STATS} component={AdminStats} exact fetcher />
<Route render={() => <Info infoType="404" />} />
</Switch>
</PrivateRouteWrapper>
<Redirect to={Routes.CLIENT_LOGIN} />
</Switch>
</React.Suspense>
</BrowserRouter>
)
}
export default Router
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/marketplace/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4084938

Please sign in to comment.