Skip to content
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

feat: Add appless pre-PAT onboarding container #3629

Open
wants to merge 14 commits into
base: cy/non_pat_appless
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const user = {
student: false,
studentCreatedAt: null,
studentUpdatedAt: null,
customerIntent: 'PERSONAL',
},
trackingMetadata: {
service: 'github',
Expand Down
7 changes: 5 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ThemeContextProvider } from 'shared/ThemeContext'

import AccountSettings from './pages/AccountSettings'
import AdminSettings from './pages/AdminSettings'
import { OnboardingContainerProvider } from './pages/OwnerPage/OnboardingContainerContext/context'
const AnalyticsPage = lazy(() => import('./pages/AnalyticsPage'))
const CodecovAIPage = lazy(() => import('./pages/CodecovAIPage'))
const CommitDetailPage = lazy(() => import('./pages/CommitDetailPage'))
Expand Down Expand Up @@ -197,8 +198,10 @@ function App() {
<>
<ThemeContextProvider>
<ToastNotificationProvider>
<ReactQueryDevtools initialIsOpen={false} />
<MainAppRoutes />
<OnboardingContainerProvider>
<ReactQueryDevtools initialIsOpen={false} />
<MainAppRoutes />
</OnboardingContainerProvider>
</ToastNotificationProvider>
<Toaster />
</ThemeContextProvider>
Expand Down
Binary file added src/assets/onboarding/org_list_install_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 5 additions & 76 deletions src/layouts/BaseLayout/BaseLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ const mockedUseImpersonate = useImpersonate as Mock
vi.mock('shared/GlobalTopBanners', () => ({
default: () => 'GlobalTopBanners',
}))
vi.mock('./InstallationHelpBanner', () => ({
default: () => 'InstallationHelpBanner',
}))
vi.mock('pages/TermsOfService', () => ({ default: () => 'TermsOfService' }))
vi.mock('pages/DefaultOrgSelector', () => ({
default: () => 'DefaultOrgSelector',
}))
vi.mock('layouts/Header', () => ({ default: () => 'Header' }))
vi.mock('layouts/Footer', () => ({ default: () => 'Footer' }))

Expand All @@ -53,7 +47,6 @@ const mockUser = {
student: false,
studentCreatedAt: null,
studentUpdatedAt: null,
customerIntent: 'BUSINESS',
externalId: 'asdf',
owners: [
{
Expand Down Expand Up @@ -306,9 +299,6 @@ describe('BaseLayout', () => {
const hello = screen.getByText('hello')
expect(hello).toBeInTheDocument()

const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
expect(defaultOrg).not.toBeInTheDocument()

const termsOfService = screen.queryByText(/TermsOfService/)
expect(termsOfService).not.toBeInTheDocument()
})
Expand All @@ -328,9 +318,6 @@ describe('BaseLayout', () => {
const hello = screen.getByText('hello')
expect(hello).toBeInTheDocument()

const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
expect(defaultOrg).not.toBeInTheDocument()

const termsOfService = screen.queryByText(/TermsOfService/)
expect(termsOfService).not.toBeInTheDocument()
})
Expand Down Expand Up @@ -361,68 +348,19 @@ describe('BaseLayout', () => {
const header = screen.queryByText(/Header/)
expect(header).not.toBeInTheDocument()
})

it('renders help banner', async () => {
setup({
currentUser: userNoTermsAgreement,
internalUser: mockUserNoTermsAgreement,
})

render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
const helpBanner = await screen.findByText(/InstallationHelpBanner/)
expect(helpBanner).toBeInTheDocument()
})
})

describe('when no default org selected', () => {
it('renders the default org selector', async () => {
setup({
currentUser: loggedInUser,
internalUser: mockUser,
})
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const defaultOrgSelector = await screen.findByText(/DefaultOrgSelector/)
expect(defaultOrgSelector).toBeInTheDocument()
})

it('does not render the header', async () => {
setup({
currentUser: loggedInUser,
internalUser: mockUser,
})
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const defaultOrgSelector = await screen.findByText(/DefaultOrgSelector/)
expect(defaultOrgSelector).toBeInTheDocument()

const header = screen.queryByText(/Header/)
expect(header).not.toBeInTheDocument()
})

it('renders help banner', async () => {
setup({
currentUser: loggedInUser,
internalUser: mockUser,
})

render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })
const helpBanner = await screen.findByText(/InstallationHelpBanner/)
expect(helpBanner).toBeInTheDocument()
})
})

describe('when agreed to TOS and default org selected', () => {
describe('when agreed to TOS', () => {
it('renders children', async () => {
setup({ currentUser: userHasDefaultOrg })
setup({ currentUser: loggedInUser })
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const children = await screen.findByText(/hello/)
expect(children).toBeInTheDocument()
})

it('renders header', async () => {
setup({ currentUser: userHasDefaultOrg })
setup({ currentUser: loggedInUser })
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const header = await screen.findByText(/Header/)
Expand Down Expand Up @@ -464,9 +402,6 @@ describe('BaseLayout', () => {
const hello = screen.getByText('hello')
expect(hello).toBeInTheDocument()

const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
expect(defaultOrg).not.toBeInTheDocument()

const termsOfService = screen.queryByText(/TermsOfService/)
expect(termsOfService).not.toBeInTheDocument()
})
Expand All @@ -486,9 +421,6 @@ describe('BaseLayout', () => {
const hello = screen.getByText('hello')
expect(hello).toBeInTheDocument()

const defaultOrg = screen.queryByText(/DefaultOrgSelector/)
expect(defaultOrg).not.toBeInTheDocument()

const termsOfService = screen.queryByText(/TermsOfService/)
expect(termsOfService).not.toBeInTheDocument()
})
Expand Down Expand Up @@ -526,23 +458,20 @@ describe('BaseLayout', () => {

const header = await screen.findByText(/Header/)
expect(header).toBeInTheDocument()

const defaultOrgSelector = screen.queryByText(/DefaultOrgSelector/)
expect(defaultOrgSelector).not.toBeInTheDocument()
})
})

describe('when agreed to TOS and default org selected', () => {
it('renders children', async () => {
setup({ currentUser: userHasDefaultOrg })
setup({ currentUser: loggedInUser })
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const children = await screen.findByText(/hello/)
expect(children).toBeInTheDocument()
})

it('renders header', async () => {
setup({ currentUser: userHasDefaultOrg })
setup({ currentUser: loggedInUser })
render(<BaseLayout>hello</BaseLayout>, { wrapper: wrapper() })

const header = await screen.findByText(/Header/)
Expand Down
27 changes: 3 additions & 24 deletions src/layouts/BaseLayout/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import LoadingLogo from 'ui/LoadingLogo'
import { NavigatorDataQueryOpts } from './hooks/NavigatorDataQueryOpts'
import { useUserAccessGate } from './hooks/useUserAccessGate'

const DefaultOrgSelector = lazy(() => import('pages/DefaultOrgSelector'))
const InstallationHelpBanner = lazy(() => import('./InstallationHelpBanner'))
const TermsOfService = lazy(() => import('pages/TermsOfService'))

const FullPageLoader = () => (
Expand All @@ -30,20 +28,16 @@ const FullPageLoader = () => (
)

interface OnboardingOrChildrenProps extends React.PropsWithChildren {
isImpersonating: boolean
isFullExperience: boolean
showAgreeToTerms: boolean
redirectToSyncPage: boolean
showDefaultOrgSelector: boolean
}

function OnboardingOrChildren({
children,
isImpersonating,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the intention here is to never show onboarding when impersonating. What's the status of this for the new flow? It might not be relevant anymore, but I'm not sure. You could ask AJ to confirm whether this is something we want.

isFullExperience,
showAgreeToTerms,
redirectToSyncPage,
showDefaultOrgSelector,
}: OnboardingOrChildrenProps) {
if (showAgreeToTerms && !isFullExperience) {
return (
Expand All @@ -57,14 +51,6 @@ function OnboardingOrChildren({
return <Redirect to="/sync" />
}

if (showDefaultOrgSelector && !isFullExperience && !isImpersonating) {
return (
<Suspense fallback={null}>
<DefaultOrgSelector />
</Suspense>
)
}

return <>{children}</>
}

Expand All @@ -81,7 +67,6 @@ function BaseLayout({ children }: React.PropsWithChildren) {
const {
isFullExperience,
showAgreeToTerms,
showDefaultOrgSelector,
redirectToSyncPage,
isLoading: isUserAccessGateLoading,
} = useUserAccessGate()
Expand Down Expand Up @@ -117,11 +102,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
<GlobalTopBanners />
<Header hasRepoAccess={data?.hasRepoAccess} />
</>
) : (
<>
{showDefaultOrgSelector ? <InstallationHelpBanner /> : null}
</>
)}
) : null}
</SilentNetworkErrorWrapper>
</ErrorBoundary>
</Suspense>
Expand All @@ -135,9 +116,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
<OnboardingOrChildren
isFullExperience={isFullExperience}
showAgreeToTerms={showAgreeToTerms}
showDefaultOrgSelector={showDefaultOrgSelector}
redirectToSyncPage={redirectToSyncPage}
isImpersonating={isImpersonating}
>
{children}
</OnboardingOrChildren>
Expand All @@ -147,12 +126,12 @@ function BaseLayout({ children }: React.PropsWithChildren) {
</Suspense>

{/* Footer */}
{isFullExperience && (
{isFullExperience ? (
<>
<Footer />
<ToastNotifications />
</>
)}
) : null}
</RepoBreadcrumbProvider>
</>
)
Expand Down

This file was deleted.

Loading
Loading