generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add upgrade screen at end of trial (#76)
- Loading branch information
Showing
17 changed files
with
1,141 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.trial-upgrade { | ||
border-radius: 99rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { Button, Icon } from '@openedx/paragon'; | ||
import { LockOpen } from '@openedx/paragon/icons'; | ||
import { useCourseUpgrade, useTrackEvent } from '../../hooks'; | ||
|
||
import './UpgradeButton.scss'; | ||
|
||
const UpgradeButton = ({ includeLockIcon, trackingEventName }) => { | ||
const { upgradeUrl } = useCourseUpgrade(); | ||
const { track } = useTrackEvent(); | ||
|
||
const handleClick = () => track(trackingEventName); | ||
|
||
return ( | ||
<Button | ||
onClick={handleClick} | ||
href={upgradeUrl} | ||
className="trial-upgrade mt-3" | ||
variant="brand" | ||
data-testid="upgrade-cta" | ||
block | ||
> | ||
{ includeLockIcon ? <Icon src={LockOpen} className="my-0 mx-2" data-testid="lock-icon" /> : null } | ||
Upgrade now | ||
</Button> | ||
); | ||
}; | ||
|
||
UpgradeButton.propTypes = { | ||
includeLockIcon: PropTypes.bool, | ||
trackingEventName: PropTypes.string.isRequired, | ||
}; | ||
|
||
UpgradeButton.defaultProps = { | ||
includeLockIcon: false, | ||
}; | ||
|
||
export default UpgradeButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { fireEvent, screen } from '@testing-library/react'; | ||
import { render } from '../../utils/utils.test'; | ||
import { useCourseUpgrade, useTrackEvent } from '../../hooks'; | ||
|
||
import UpgradeButton from '.'; | ||
|
||
jest.mock('../../hooks', () => ({ | ||
useCourseUpgrade: jest.fn(), | ||
useTrackEvent: jest.fn(), | ||
})); | ||
|
||
describe('UpgradeButton', () => { | ||
beforeEach(() => { | ||
useCourseUpgrade.mockReturnValue({ upgradeUrl: 'www.test.com' }); | ||
useTrackEvent.mockReturnValue({ track: jest.fn() }); | ||
}); | ||
|
||
it('should render UpgradeButton', () => { | ||
render(<UpgradeButton trackingEventName="test.tracking" />); | ||
expect(screen.queryByText('Upgrade now')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('upgrade-cta')).toHaveAttribute('href', 'www.test.com'); | ||
expect(screen.queryByTestId('lock-icon')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should call track event on click', () => { | ||
const mockedTrackEvent = jest.fn(); | ||
useTrackEvent.mockReturnValue({ track: mockedTrackEvent }); | ||
|
||
render(<UpgradeButton trackingEventName="test.tracking" />); | ||
|
||
const upgradeCta = screen.queryByTestId('upgrade-cta'); | ||
expect(mockedTrackEvent).not.toHaveBeenCalled(); | ||
fireEvent.click(upgradeCta); | ||
expect(mockedTrackEvent).toHaveBeenCalledWith('test.tracking'); | ||
}); | ||
|
||
it('should render lock icon', () => { | ||
render(<UpgradeButton trackingEventName="test.tracking" includeLockIcon />); | ||
expect(screen.queryByTestId('lock-icon')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@use '../../utils/variables'; | ||
|
||
.upgrade-panel { | ||
height: 100%; | ||
|
||
overflow-y: auto; | ||
background-color: variables.$dark-green; | ||
|
||
h2 { | ||
font-size: 1.375rem; | ||
} | ||
|
||
.xpert-value-prop-check { | ||
color: variables.$accent-yellow; | ||
} | ||
|
||
.xpert-value-prop { | ||
margin-bottom: 1rem; | ||
font-size: 0.875rem; | ||
} | ||
} |
Oops, something went wrong.