File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed
Expand file tree Collapse file tree 3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 66 Hyperlink , Icon ,
77} from '@openedx/paragon' ;
88import { Institution } from '@openedx/paragon/icons' ;
9+ import classNames from 'classnames' ;
910import PropTypes from 'prop-types' ;
1011import Skeleton from 'react-loading-skeleton' ;
1112
@@ -47,14 +48,23 @@ const ThirdPartyAuth = (props) => {
4748 </ div >
4849 ) }
4950 { ( isLoginPage && ! isEnterpriseLoginDisabled && isSocialAuthActive ) && (
50- < Hyperlink className = "btn btn-link btn-sm text-body p-0 mb-4" destination = { enterpriseLoginURL } >
51+ < Hyperlink
52+ className = { classNames (
53+ 'btn btn-link btn-sm text-body p-0' ,
54+ { 'mb-0' : thirdPartyAuthApiStatus === PENDING_STATE } ,
55+ { 'mb-4' : thirdPartyAuthApiStatus !== PENDING_STATE } ,
56+ ) }
57+ destination = { enterpriseLoginURL }
58+ >
5159 < Icon src = { Institution } className = "institute-icon" />
5260 { formatMessage ( messages [ 'enterprise.login.btn.text' ] ) }
5361 </ Hyperlink >
5462 ) }
5563
5664 { thirdPartyAuthApiStatus === PENDING_STATE ? (
57- < Skeleton className = "tpa-skeleton" height = { 36 } count = { 2 } />
65+ < div className = "mt-4" >
66+ < Skeleton className = "tpa-skeleton" height = { 36 } count = { 2 } />
67+ </ div >
5868 ) : (
5969 < >
6070 { ( isEnterpriseLoginDisabled && isInstitutionAuthActive ) && (
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ const Logistration = (props) => {
7070 setInstitutionLogin ( ! institutionLogin ) ;
7171 } ;
7272
73- const handleOnSelect = ( tabKey ) => {
73+ const handleOnSelect = ( tabKey , currentTab ) => {
74+ if ( tabKey === currentTab ) {
75+ return ;
76+ }
7477 sendTrackEvent ( `edx.bi.${ tabKey . replace ( '/' , '' ) } _form.toggled` , { category : 'user-engagement' } ) ;
7578 props . clearThirdPartyAuthContextErrorMessage ( ) ;
7679 if ( tabKey === LOGIN_PAGE ) {
@@ -122,7 +125,7 @@ const Logistration = (props) => {
122125 ) ;
123126 }
124127 return (
125- < Tabs defaultActiveKey = { selectedPage } id = "controlled-tab" onSelect = { handleOnSelect } >
128+ < Tabs defaultActiveKey = { selectedPage } id = "controlled-tab" onSelect = { ( tabKey ) => handleOnSelect ( tabKey , selectedPage ) } >
126129 < Tab title = { formatMessage ( messages [ 'logistration.register' ] ) } eventKey = { REGISTER_PAGE } />
127130 < Tab title = { formatMessage ( messages [ 'logistration.sign.in' ] ) } eventKey = { LOGIN_PAGE } />
128131 </ Tabs >
Original file line number Diff line number Diff line change @@ -98,6 +98,14 @@ describe('Logistration', () => {
9898 } ) ;
9999 } ) ;
100100
101+ it ( 'should do nothing when user clicks on the same tab (login/register) again' , ( ) => {
102+ const { container } = render ( reduxWrapper ( < IntlLogistration /> ) ) ;
103+ // While staying on the registration form, clicking the register tab again
104+ fireEvent . click ( container . querySelector ( 'a[data-rb-event-key="/register"]' ) ) ;
105+
106+ expect ( sendTrackEvent ) . not . toHaveBeenCalledWith ( 'edx.bi.register_form.toggled' , { category : 'user-engagement' } ) ;
107+ } ) ;
108+
101109 it ( 'should render registration page' , ( ) => {
102110 mergeConfig ( {
103111 ALLOW_PUBLIC_ACCOUNT_CREATION : true ,
@@ -264,9 +272,11 @@ describe('Logistration', () => {
264272 fireEvent . click ( container . querySelector ( 'a[data-rb-event-key="/login"]' ) ) ;
265273 expect ( store . dispatch ) . toHaveBeenCalledWith ( backupRegistrationForm ( ) ) ;
266274 } ) ;
275+
267276 it ( 'should fire action to backup login form on tab click' , ( ) => {
268277 store . dispatch = jest . fn ( store . dispatch ) ;
269- const { container } = render ( reduxWrapper ( < IntlLogistration /> ) ) ;
278+ const props = { selectedPage : LOGIN_PAGE } ;
279+ const { container } = render ( reduxWrapper ( < IntlLogistration { ...props } /> ) ) ;
270280 fireEvent . click ( container . querySelector ( 'a[data-rb-event-key="/register"]' ) ) ;
271281 expect ( store . dispatch ) . toHaveBeenCalledWith ( backupLoginForm ( ) ) ;
272282 } ) ;
You can’t perform that action at this time.
0 commit comments