Skip to content

Commit

Permalink
Remove Questionnaire
Browse files Browse the repository at this point in the history
  • Loading branch information
michellescripts committed Feb 5, 2025
1 parent c0378e5 commit ba46cd3
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 94 deletions.
25 changes: 1 addition & 24 deletions web/packages/teleport/src/Main/Main.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ const setupContext = (): TeleportContext => {
return ctx;
};

test('displays questionnaire if present', () => {
test('renders', () => {
mockUserContextProviderWith(makeTestUserContext());
const ctx = setupContext();

const props: MainProps = {
features: getOSSFeatures(),
Questionnaire: () => <div>Passed Component!</div>,
};

render(
Expand All @@ -76,28 +75,6 @@ test('displays questionnaire if present', () => {
</MemoryRouter>
);

expect(screen.getByText('Passed Component!')).toBeInTheDocument();
});

test('renders without questionnaire prop', () => {
mockUserContextProviderWith(makeTestUserContext());
const ctx = setupContext();

const props: MainProps = {
features: getOSSFeatures(),
};
expect(props.Questionnaire).toBeUndefined();

render(
<MemoryRouter>
<LayoutContextProvider>
<ContextProvider ctx={ctx}>
<Main {...props} />
</ContextProvider>
</LayoutContextProvider>
</MemoryRouter>
);

expect(screen.getByTestId('teleport-logo')).toBeInTheDocument();
});

Expand Down
16 changes: 1 addition & 15 deletions web/packages/teleport/src/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, {
import {
createContext,
ReactNode,
Suspense,
Expand All @@ -31,7 +31,6 @@ import styled from 'styled-components';

import { Box, Flex, Indicator } from 'design';
import { Failed } from 'design/CardError';
import Dialog from 'design/Dialog';
import useAttempt from 'shared/hooks/useAttemptNext';

import { BannerList } from 'teleport/components/BannerList';
Expand All @@ -52,7 +51,6 @@ import { TopBar, TopBarProps } from 'teleport/TopBar';
import type { LockedFeatures, TeleportFeature } from 'teleport/types';
import { useUser } from 'teleport/User/UserContext';
import useTeleport from 'teleport/useTeleport';
import { QuestionnaireProps } from 'teleport/Welcome/NewCredentials';

import { MainContainer } from './MainContainer';
import { OnboardDiscover } from './OnboardDiscover';
Expand All @@ -62,7 +60,6 @@ export interface MainProps {
customBanners?: ReactNode[];
features: TeleportFeature[];
billingBanners?: ReactNode[];
Questionnaire?: (props: QuestionnaireProps) => React.ReactElement;
topBarProps?: TopBarProps;
inviteCollaboratorsFeedback?: ReactNode;
}
Expand Down Expand Up @@ -97,9 +94,6 @@ export function Main(props: MainProps) {
const [showOnboardDiscover, setShowOnboardDiscover] = useState(
!ctx.redirectUrl
);
const [showOnboardSurvey, setShowOnboardSurvey] = useState<boolean>(
!!props.Questionnaire
);

useEffect(() => {
if (
Expand Down Expand Up @@ -213,14 +207,6 @@ export function Main(props: MainProps) {
{displayOnboardDiscover && (
<OnboardDiscover onClose={handleOnClose} onOnboard={handleOnboard} />
)}
{showOnboardSurvey && (
<Dialog open={showOnboardSurvey}>
<props.Questionnaire
onSubmit={() => setShowOnboardSurvey(false)}
onboard={false}
/>
</Dialog>
)}
{props.inviteCollaboratorsFeedback}
</FeaturesContextProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,6 @@ test('renders credential flow for sso', () => {
expect(screen.getByText(/Set A Password/i)).toBeInTheDocument();
});

test('renders questionnaire', () => {
mockUserContextProviderWith(makeTestUserContext());

const props = makeProps();
props.fetchAttempt = { status: 'success' };
props.success = true;
props.recoveryCodes = undefined;
props.displayOnboardingQuestionnaire = true;
props.setDisplayOnboardingQuestionnaire = () => {};
props.Questionnaire = () => <div>Passed Component!</div>;
render(<NewCredentials {...props} />);

expect(screen.getByText(/Passed Component!/i)).toBeInTheDocument();
});

test('renders invite collaborators', () => {
mockUserContextProviderWith(makeTestUserContext());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export function NewCredentials(props: NewCredentialsProps) {
success,
finishedRegister,
isDashboard,
displayOnboardingQuestionnaire = false,
setDisplayOnboardingQuestionnaire = false,
Questionnaire = undefined,
displayInviteCollaborators = false,
setDisplayInviteCollaborators = null,
InviteCollaborators = undefined,
Expand Down Expand Up @@ -103,24 +100,6 @@ export function NewCredentials(props: NewCredentialsProps) {
);
}

if (
success &&
!resetMode &&
displayOnboardingQuestionnaire &&
setDisplayOnboardingQuestionnaire &&
Questionnaire
) {
return (
<OnboardCard>
<Questionnaire
username={resetToken.user}
onSubmit={() => setDisplayOnboardingQuestionnaire(false)}
onboard={true}
/>
</OnboardCard>
);
}

if (success) {
return (
<RegisterSuccess
Expand Down
16 changes: 0 additions & 16 deletions web/packages/teleport/src/Welcome/NewCredentials/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ export type UseTokenState = {
finishedRegister: () => void;
};

// Note: QuestionnaireProps is duplicated in Enterprise (e-teleport/Welcome/Questionnaire/Questionnaire)
export type QuestionnaireProps = {
onboard: boolean;
username?: string;
onSubmit?: () => void;
};

// Note: InviteCollaboratorsCardProps is duplicated in Enterprise
// (e-teleport/Welcome/InviteCollaborators/InviteCollaborators)
export type InviteCollaboratorsCardProps = {
Expand All @@ -61,15 +54,6 @@ export type NewCredentialsProps = UseTokenState & {
resetMode?: boolean;
isDashboard: boolean;

// support E questionnaire
displayOnboardingQuestionnaire?: boolean;
setDisplayOnboardingQuestionnaire?: (bool: boolean) => void;
Questionnaire?: ({
onboard,
username,
onSubmit,
}: QuestionnaireProps) => ReactElement;

// support for E's invite collaborators at onboarding
displayInviteCollaborators?: boolean;
setDisplayInviteCollaborators?: (bool: boolean) => void;
Expand Down
3 changes: 0 additions & 3 deletions web/packages/teleport/src/services/userEvent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export enum CaptureEvent {
PreUserRecoveryCodesContinueClickEvent = 'tp.ui.recoveryCodesContinue.click',
PreUserRecoveryCodesCopyClickEvent = 'tp.ui.recoveryCodesCopy.click',
PreUserRecoveryCodesPrintClickEvent = 'tp.ui.recoveryCodesPrint.click',

// Shared types; used in both pre-user and authenticated user settings
OnboardQuestionnaireSubmitEvent = 'tp.ui.onboard.questionnaire.submit',
}

/**
Expand Down

0 comments on commit ba46cd3

Please sign in to comment.