Skip to content

Commit 9baefae

Browse files
authored
fix: improve UI after design review of new reg flow [WPB-17795] (#19175)
* fix: improve UI after design review of new reg flow [WPB-17795] * Add condition for privacy checkbox * move file * fixed tests * fixed test * fixed test
1 parent 7af2ddb commit 9baefae

File tree

7 files changed

+60
-56
lines changed

7 files changed

+60
-56
lines changed

src/script/auth/component/AccountForm.test.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ describe('when entering account data', () => {
2929
let wrapper: RenderResult;
3030

3131
const nameInput = () => wrapper.getByTestId('enter-name') as HTMLInputElement;
32-
const emailInput = () => wrapper.getByTestId('enter-email') as HTMLInputElement;
33-
const passwordInput = () => wrapper.getByTestId('enter-password') as HTMLInputElement;
3432
const doNextButton = () => wrapper.getByTestId('do-next') as HTMLButtonElement;
35-
const doTermsCheckbox = () => wrapper.getByTestId('do-accept-terms') as HTMLInputElement;
3633
const validationErrorMessage = () => wrapper.getByTestId('error-message');
3734

3835
describe('the submit button', () => {
@@ -51,11 +48,6 @@ describe('when entering account data', () => {
5148
}),
5249
);
5350

54-
expect(nameInput().required).toBe(true);
55-
expect(emailInput().required).toBe(true);
56-
expect(passwordInput().required).toBe(true);
57-
expect(doTermsCheckbox().required).toBe(true);
58-
5951
expect(doNextButton().disabled).toBe(true);
6052
});
6153

@@ -110,8 +102,8 @@ describe('when entering account data', () => {
110102
});
111103

112104
it('appears when input gets trimmed', () => {
113-
const actualName = ' ';
114-
const expectedName = ' ';
105+
const actualName = 'M ';
106+
const expectedName = 'M ';
115107
const expectedErrorMessage = 'Enter a name with at least 2 characters';
116108

117109
wrapper = mountComponent(

src/script/auth/component/AccountForm.tsx

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import * as AccentColor from '../util/AccentColor';
4343
import {
4444
EventName,
4545
initializeTelemetry,
46+
isTelemetryEnabled,
4647
resetTelemetrySession,
4748
Segmentation,
4849
trackTelemetryEvent,
@@ -207,7 +208,6 @@ const AccountFormComponent = ({
207208
maxLength={64}
208209
minLength={2}
209210
pattern=".{2,64}"
210-
required
211211
data-uie-name="enter-name"
212212
/>
213213

@@ -228,7 +228,6 @@ const AccountFormComponent = ({
228228
onKeyDown={event => handleEnterDown(event, () => inputs.password.current?.focus())}
229229
maxLength={128}
230230
type="email"
231-
required
232231
data-uie-name="enter-email"
233232
/>
234233

@@ -248,7 +247,6 @@ const AccountFormComponent = ({
248247
type="password"
249248
placeholder={t('accountForm.passwordPlaceholder')}
250249
pattern={ValidationUtil.getNewPasswordPattern(Config.getConfig().NEW_PASSWORD_MINIMUM_LENGTH)}
251-
required
252250
data-uie-name="enter-password"
253251
/>
254252
<Text muted css={styles.passwordInfo(!!validationErrors.length)} data-uie-name="element-password-help">
@@ -270,7 +268,6 @@ const AccountFormComponent = ({
270268
type="password"
271269
placeholder={t('accountForm.confirmPasswordPlaceholder')}
272270
pattern={`^${registrationData.password?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`}
273-
required
274271
data-uie-name="enter-confirm-password"
275272
/>
276273

@@ -287,7 +284,6 @@ const AccountFormComponent = ({
287284
markInvalid={!validInputs.terms}
288285
name="accept-terms"
289286
id="accept-terms"
290-
required
291287
checked={registrationData.termsAccepted}
292288
data-uie-name="do-accept-terms"
293289
>
@@ -311,38 +307,40 @@ const AccountFormComponent = ({
311307
</CheckboxLabel>
312308
</Checkbox>
313309

314-
<Checkbox
315-
ref={inputs.privacyPolicy}
316-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
317-
inputs.privacyPolicy.current?.setCustomValidity('');
318-
setRegistrationData({...registrationData, privacyPolicyAccepted: event.target.checked});
319-
setValidInputs({...validInputs, privacyPolicy: true});
320-
}}
321-
markInvalid={!validInputs.privacyPolicy}
322-
name="accept-privacy-policy"
323-
id="accept-privacy-policy"
324-
checked={registrationData.privacyPolicyAccepted}
325-
data-uie-name="do-accept-privacy-policy"
326-
>
327-
<CheckboxLabel htmlFor="accept-privacy-policy" css={styles.checkboxLabel}>
328-
<FormattedMessage
329-
id="accountForm.privacyPolicy"
330-
values={{
331-
privacyPolicyLink: (
332-
<a
333-
target="_blank"
334-
rel="noopener noreferrer"
335-
data-uie-name="go-privacy-policy"
336-
href={Config.getConfig().URL.PRIVACY_POLICY}
337-
css={styles.checkboxLink}
338-
>
339-
{t('accountForm.privacyPolicyLink')}
340-
</a>
341-
),
342-
}}
343-
/>
344-
</CheckboxLabel>
345-
</Checkbox>
310+
{isTelemetryEnabled() && (
311+
<Checkbox
312+
ref={inputs.privacyPolicy}
313+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
314+
inputs.privacyPolicy.current?.setCustomValidity('');
315+
setRegistrationData({...registrationData, privacyPolicyAccepted: event.target.checked});
316+
setValidInputs({...validInputs, privacyPolicy: true});
317+
}}
318+
markInvalid={!validInputs.privacyPolicy}
319+
name="accept-privacy-policy"
320+
id="accept-privacy-policy"
321+
checked={registrationData.privacyPolicyAccepted}
322+
data-uie-name="do-accept-privacy-policy"
323+
>
324+
<CheckboxLabel htmlFor="accept-privacy-policy" css={styles.checkboxLabel}>
325+
<FormattedMessage
326+
id="accountForm.privacyPolicy"
327+
values={{
328+
privacyPolicyLink: (
329+
<a
330+
target="_blank"
331+
rel="noopener noreferrer"
332+
data-uie-name="go-privacy-policy"
333+
href={Config.getConfig().URL.PRIVACY_POLICY}
334+
css={styles.checkboxLink}
335+
>
336+
{t('accountForm.privacyPolicyLink')}
337+
</a>
338+
),
339+
}}
340+
/>
341+
</CheckboxLabel>
342+
</Checkbox>
343+
)}
346344

347345
<Button
348346
disabled={isSubmitDisabled}

src/script/auth/component/Layout.styles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ export const leftSectionCss: CSSObject = {
2525
background: 'black',
2626
margin: 0,
2727
height: '100vh',
28-
width: '460px',
28+
width: '360px',
2929
padding: '6rem 4rem',
3030
position: 'relative',
3131
minHeight: '42rem',
32+
[media.desktopXL]: {
33+
width: '460px',
34+
},
3235
[media.tabletDown]: {
3336
display: 'none',
3437
},
@@ -49,7 +52,7 @@ export const whiteFontCss: CSSObject = {
4952
export const bodyCss: CSSObject = {
5053
flex: 'auto',
5154
flexDirection: 'row',
52-
background: COLOR_V2.WHITE,
55+
background: COLOR_V2.GRAY_10,
5356
height: '100%',
5457
minHeight: '100vh',
5558
};

src/script/auth/page/SetAccountType.styles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const styles: {
4646
container: {
4747
width: '100%',
4848
padding: '38px',
49-
maxWidth: '1000px',
49+
maxWidth: '750px',
5050
margin: 'auto',
5151
marginBottom: '10vw',
5252
flexDirection: 'column',
@@ -105,6 +105,7 @@ export const styles: {
105105
flex: 1,
106106
height: 360,
107107
position: 'relative',
108+
background: COLOR_V2.WHITE,
108109
[mediaQueryDesktop]: {
109110
margin: '16px 0',
110111
},

src/script/auth/util/trackingUtil.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('trackingUtil', () => {
7878

7979
describe('initializeTelemetry', () => {
8080
it('should initialize telemetry and set device id if not present', () => {
81-
(Config.getConfig as jest.Mock).mockReturnValueOnce(configFactory());
81+
(Config.getConfig as jest.Mock).mockReturnValue(configFactory());
8282
localStorageMock.getItem.mockReturnValueOnce(null);
8383
trackingUtil.initializeTelemetry();
8484
expect(telemetry.initialize).toHaveBeenCalledWith(
@@ -99,13 +99,13 @@ describe('trackingUtil', () => {
9999
});
100100

101101
it('should not initialize telemetry if COUNTLY_ENABLE_LOGGING is false', async () => {
102-
(Config.getConfig as jest.Mock).mockReturnValueOnce(configFactory({COUNTLY_ENABLE_LOGGING: false}));
102+
(Config.getConfig as jest.Mock).mockReturnValue(configFactory({COUNTLY_ENABLE_LOGGING: false}));
103103
trackingUtil.initializeTelemetry();
104104
expect(telemetry.initialize).not.toHaveBeenCalled();
105105
});
106106

107107
it('should not initialize telemetry if COUNTLY_API_KEY is missing', () => {
108-
(Config.getConfig as jest.Mock).mockReturnValueOnce(configFactory({COUNTLY_API_KEY: ''}));
108+
(Config.getConfig as jest.Mock).mockReturnValue(configFactory({COUNTLY_API_KEY: ''}));
109109
trackingUtil.initializeTelemetry();
110110
expect(telemetry.initialize).not.toHaveBeenCalled();
111111
});

src/script/auth/util/trackingUtil.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,20 @@ export enum PageView {
5555
ACCOUNT_COMPLETION_SCREEN_4 = 'account_completion_screen_4',
5656
}
5757

58-
export const initializeTelemetry = () => {
59-
const {COUNTLY_ENABLE_LOGGING, VERSION, COUNTLY_API_KEY, COUNTLY_SERVER_URL} = Config.getConfig();
58+
export const isTelemetryEnabled = () => {
59+
const {COUNTLY_ENABLE_LOGGING, COUNTLY_API_KEY} = Config.getConfig();
6060

6161
if (!COUNTLY_ENABLE_LOGGING || !COUNTLY_API_KEY || !telemetry.isLoaded()) {
62+
return false;
63+
}
64+
65+
return true;
66+
};
67+
68+
export const initializeTelemetry = () => {
69+
const {VERSION, COUNTLY_API_KEY, COUNTLY_SERVER_URL} = Config.getConfig();
70+
71+
if (!isTelemetryEnabled()) {
6272
return;
6373
}
6474

test/e2e_tests/pages/registration.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class RegistrationPage {
4040
this.passwordInput = page.locator('[data-uie-name="enter-password"]');
4141
this.confirmPasswordInput = page.locator('[data-uie-name="enter-confirm-password"]');
4242
this.submitButton = page.locator('[data-uie-name="do-next"]');
43-
this.termsCheckbox = page.locator('[data-uie-name="do-terms"]');
43+
this.termsCheckbox = page.locator('[data-uie-name="do-accept-terms"]');
4444
}
4545

4646
async isPasswordPolicyInfoVisible() {

0 commit comments

Comments
 (0)