-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add a step to the stepper for academy selection and update lang… #128
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
Changes from all commits
cf19366
ac39df5
723837e
83dfa76
0b045be
30a9d95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { AppContext } from '@edx/frontend-platform/react'; | ||
| import React, { useContext } from 'react'; | ||
|
|
||
| import { TermsAndConditionsText } from '@/components/TermsAndConditionsText'; | ||
|
|
||
| const AcademicSelectionContent = () => { | ||
| const { authenticatedUser }: AppContextValue = useContext(AppContext); | ||
| return ( | ||
| <> | ||
| {authenticatedUser && ( | ||
| <p className="text-sm text-muted" data-testid="authenticated-user-email"> | ||
| Logged in as {authenticatedUser.email} | ||
| </p> | ||
| )} | ||
|
|
||
| <div data-testid="terms-and-conditions-wrapper"> | ||
| <TermsAndConditionsText /> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default AcademicSelectionContent; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* eslint-disable import/order */ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import React from 'react'; | ||
| import '@testing-library/jest-dom'; | ||
|
|
||
| import { AppContext } from '@edx/frontend-platform/react'; | ||
|
|
||
| import AcademicSelectionContent from '../AcademicSelectionContent'; | ||
|
|
||
| jest.mock('@/components/TermsAndConditionsText', () => ({ | ||
| TermsAndConditionsText: () => ( | ||
| <div data-testid="terms-and-conditions" /> | ||
| ), | ||
| })); | ||
|
|
||
| describe('AcademicSelectionContent', () => { | ||
| const renderWithContext = (contextValue: any) => render( | ||
| <AppContext.Provider value={contextValue}> | ||
| <AcademicSelectionContent /> | ||
| </AppContext.Provider>, | ||
| ); | ||
|
|
||
| it('renders authenticated user email when authenticatedUser exists', () => { | ||
| renderWithContext({ | ||
| authenticatedUser: { | ||
| email: 'testuser@example.com', | ||
| }, | ||
| }); | ||
|
|
||
| expect( | ||
| screen.getByText('Logged in as testuser@example.com'), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByTestId('terms-and-conditions'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does NOT render email paragraph when authenticatedUser is null', () => { | ||
| renderWithContext({ | ||
| authenticatedUser: null, | ||
| }); | ||
|
|
||
| expect( | ||
| screen.queryByText(/Logged in as/i), | ||
| ).not.toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByTestId('terms-and-conditions'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does NOT render email paragraph when authenticatedUser is undefined', () => { | ||
| renderWithContext({ | ||
| authenticatedUser: undefined, | ||
| }); | ||
|
|
||
| expect( | ||
| screen.queryByText(/Logged in as/i), | ||
| ).not.toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByTestId('terms-and-conditions'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('handles authenticatedUser object without email safely', () => { | ||
| renderWithContext({ | ||
| authenticatedUser: {}, | ||
| }); | ||
|
|
||
| expect( | ||
| screen.getByText('Logged in as'), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByTestId('terms-and-conditions'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; | ||
| import { Stack, Stepper } from '@openedx/paragon'; | ||
| import { Helmet } from 'react-helmet'; | ||
|
|
||
| import { CheckoutStepKey } from '@/constants/checkout'; | ||
|
|
||
| const AcademicSelection = () => { | ||
| const intl = useIntl(); | ||
| const eventKey = CheckoutStepKey.AcademicSelection; | ||
| return ( | ||
| <> | ||
| <Helmet | ||
| title={intl.formatMessage({ | ||
| id: 'AcademicSelection.title', | ||
| defaultMessage: 'Academic Selection', | ||
| })} | ||
| /> | ||
|
|
||
| <Stack gap={4}> | ||
| <Stepper.Step | ||
| eventKey={eventKey} | ||
| title="Academic Selection" | ||
| > | ||
| <Stack gap={3}> | ||
| <h3> | ||
| <FormattedMessage | ||
| id="AcademicSelection.header" | ||
| defaultMessage="Academic Selection" | ||
| /> | ||
| </h3> | ||
| <p> | ||
| <FormattedMessage | ||
| id="AcademicSelection.comingSoon" | ||
| defaultMessage="Coming soon, we will update you." | ||
| /> | ||
| </p> | ||
| </Stack> | ||
| </Stepper.Step> | ||
| </Stack> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default AcademicSelection; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { screen } from '@testing-library/react'; | ||
| import { fireEvent, screen } from '@testing-library/react'; | ||
| import '@testing-library/jest-dom'; | ||
|
|
||
| import { useFormValidationConstraints } from '@/components/app/data'; | ||
|
|
@@ -37,11 +37,9 @@ describe('AccountDetailsPage', () => { | |
| it('renders the continue button correctly', () => { | ||
| renderStepperRoute(CheckoutPageRoute.AccountDetails, { | ||
| config: {}, | ||
| authenticatedUser: { | ||
| userId: 12345, | ||
| }, | ||
| authenticatedUser: { userId: 12345 }, | ||
| }); | ||
| validateText('Continue'); | ||
| expect(screen.getByText('Continue')).toBeInTheDocument(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can remain as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
| }); | ||
|
|
||
| it('renders the CompanyNameField component', () => { | ||
|
|
@@ -51,7 +49,9 @@ describe('AccountDetailsPage', () => { | |
| userId: 12345, | ||
| }, | ||
| }); | ||
| validateText('What is the name of your company or organization?'); | ||
| expect( | ||
| screen.getByText('What is the name of your company or organization?'), | ||
| ).toBeInTheDocument(); | ||
|
Comment on lines
+52
to
+54
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can remain as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
| }); | ||
|
|
||
| it('renders the CustomUrlField component', () => { | ||
|
|
@@ -61,6 +61,35 @@ describe('AccountDetailsPage', () => { | |
| userId: 12345, | ||
| }, | ||
| }); | ||
| validateText('Create a custom URL for your team'); | ||
| expect( | ||
| screen.getByText('Create a custom URL for your team'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
Comment on lines
+64
to
+67
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can remain as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
|
||
| it('renders Back button and navigates to Plan Details', () => { | ||
| renderStepperRoute(CheckoutPageRoute.AccountDetails, { | ||
| config: {}, | ||
| authenticatedUser: { userId: 12345 }, | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByText('Back')); | ||
|
|
||
| // expect(screen.queryByText('Plan Details')).toBeInTheDocument(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be commented out?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
| }); | ||
|
|
||
| it('sets the page title using Helmet', () => { | ||
| renderStepperRoute(CheckoutPageRoute.AccountDetails, { | ||
| config: {}, | ||
| authenticatedUser: { userId: 12345 }, | ||
| }); | ||
|
|
||
| expect(document.title).toBe(''); | ||
| }); | ||
|
|
||
| it('renders the form wrapper element', () => { | ||
| renderStepperRoute(CheckoutPageRoute.AccountDetails, { | ||
| config: {}, | ||
| authenticatedUser: { userId: 12345 }, | ||
| }); | ||
| }); | ||
| }); | ||
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.
Hide behind feature flag since it is an incomplete feature. See rootloader.ts.