@opexa/portal-components 0.0.958 → 0.0.960
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/components/Banner/Banner.test.js +1 -1
- package/dist/lib/components/Disclaimer/Disclaimer.test.js +7 -7
- package/dist/lib/components/Games/Game.js +1 -5
- package/dist/lib/components/SignIn/MobileNumberSignIn.test.js +9 -8
- package/dist/lib/components/SignIn/NameAndPasswordSignIn.test.js +14 -10
- package/dist/lib/components/SignIn/SignIn.test.js +4 -3
- package/dist/lib/components/UpdateMobileNumber/UpdateMobileNumber.d.ts +1 -3
- package/dist/lib/components/UpdateMobileNumber/UpdateMobileNumber.js +13 -8
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@ describe('Banner', () => {
|
|
|
52
52
|
expect(link2).toHaveAttribute('href', '/link2');
|
|
53
53
|
});
|
|
54
54
|
it('renders plain div for banners without redirectUrl', () => {
|
|
55
|
-
|
|
55
|
+
render(_jsx(Banner, { banners: mockBanners }));
|
|
56
56
|
// The 3rd banner image (index 2) should be present
|
|
57
57
|
const image3 = screen.getByTestId('banner-image-2');
|
|
58
58
|
expect(image3).toBeInTheDocument();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { screen, waitFor
|
|
2
|
+
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import { createMockGlobalStore, createMockSessionQuery, createMockSignOutMutation, createMockUseDisclaimer, } from '../../../__tests__/utils/mocks.js';
|
|
@@ -49,16 +49,19 @@ vi.mock('../../images/responsible-gaming-new.png', () => ({
|
|
|
49
49
|
}));
|
|
50
50
|
vi.mock('../../ui/Checkbox', () => {
|
|
51
51
|
const React = require('react');
|
|
52
|
-
const CheckboxContext = React.createContext({
|
|
52
|
+
const CheckboxContext = React.createContext({
|
|
53
|
+
onCheckedChange: (_) => { },
|
|
54
|
+
});
|
|
53
55
|
return {
|
|
54
56
|
Checkbox: {
|
|
55
57
|
Root: ({ children, onCheckedChange }) => (_jsx(CheckboxContext.Provider, { value: { onCheckedChange }, children: _jsx("div", { children: children }) })),
|
|
56
58
|
Control: ({ children }) => _jsx("div", { children: children }),
|
|
57
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
59
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? 'checkbox-input', ...props, children: children })),
|
|
58
60
|
Indicator: ({ children }) => _jsx("div", { children: children }),
|
|
59
61
|
HiddenInput: React.forwardRef((props, ref) => {
|
|
60
62
|
const { onCheckedChange } = React.useContext(CheckboxContext);
|
|
61
|
-
|
|
63
|
+
const id = props.id ?? 'checkbox-input';
|
|
64
|
+
return (_jsx("input", { type: "checkbox", "data-testid": "checkbox-input", id: id, ref: ref, ...props, onChange: (e) => {
|
|
62
65
|
if (onCheckedChange)
|
|
63
66
|
onCheckedChange({ checked: e.target.checked });
|
|
64
67
|
} }));
|
|
@@ -106,7 +109,6 @@ describe('DisclaimerV1', () => {
|
|
|
106
109
|
expect(acceptButton).not.toBeDisabled();
|
|
107
110
|
});
|
|
108
111
|
it('checkbox toggles when clicked', async () => {
|
|
109
|
-
const user = userEvent.setup();
|
|
110
112
|
render(_jsx(DisclaimerV1, { ...defaultProps }));
|
|
111
113
|
const checkbox = screen.getByTestId('checkbox-input');
|
|
112
114
|
fireEvent.click(checkbox);
|
|
@@ -164,7 +166,6 @@ describe('DisclaimerV2', () => {
|
|
|
164
166
|
expect(list.querySelectorAll('li').length).toBeGreaterThan(0);
|
|
165
167
|
});
|
|
166
168
|
it('checkbox controls both termsOfUse and responsibleGaming', async () => {
|
|
167
|
-
const user = userEvent.setup();
|
|
168
169
|
render(_jsx(DisclaimerV2, { ...defaultProps }));
|
|
169
170
|
const checkbox = screen.getByTestId('checkbox-input');
|
|
170
171
|
fireEvent.click(checkbox);
|
|
@@ -228,7 +229,6 @@ describe('DisclaimerV3', () => {
|
|
|
228
229
|
expect(list.querySelectorAll('li').length).toBeGreaterThan(0);
|
|
229
230
|
});
|
|
230
231
|
it('checkbox controls both termsOfUse and responsibleGaming', async () => {
|
|
231
|
-
const user = userEvent.setup();
|
|
232
232
|
render(_jsx(DisclaimerV3, { ...defaultProps }));
|
|
233
233
|
const checkbox = screen.getByTestId('checkbox-input');
|
|
234
234
|
fireEvent.click(checkbox);
|
|
@@ -89,11 +89,7 @@ function GameImage({ priority }) {
|
|
|
89
89
|
image: game.image,
|
|
90
90
|
}), [game.reference, game.provider, game.image]);
|
|
91
91
|
const [imgSrc, setImgSrc] = useState(initialImageUrl);
|
|
92
|
-
return (_jsx(Image, { src: game.name === 'Rainbow Ball'
|
|
93
|
-
? RainbowballImg
|
|
94
|
-
: imgSrc, alt: game.name, width: 200, height: 200, loading: priority ? undefined : 'lazy', priority: priority, unoptimized: true, sizes: "(max-width: 768px) 33vw, 200px", className: twMerge('aspect-square w-full rounded-t-md object-contain', game.name === 'Rainbow Ball' &&
|
|
95
|
-
game.id === '22wQ1YcMwrBaZH3Mx7' &&
|
|
96
|
-
'object-cover'), onError: () => {
|
|
92
|
+
return (_jsx(Image, { src: game.name === 'Rainbow Ball' ? RainbowballImg : imgSrc, alt: game.name, width: 200, height: 200, loading: priority ? undefined : 'lazy', priority: priority, unoptimized: true, sizes: "(max-width: 768px) 33vw, 200px", className: twMerge('aspect-square w-full rounded-t-md object-contain', game.name === 'Rainbow Ball' && 'object-cover'), onError: () => {
|
|
97
93
|
const fallbackThumbnail = props.fallbackThumbnails?.[game.provider];
|
|
98
94
|
if (fallbackThumbnail) {
|
|
99
95
|
setImgSrc(fallbackThumbnail);
|
|
@@ -42,10 +42,10 @@ vi.mock('next/navigation', () => ({
|
|
|
42
42
|
}));
|
|
43
43
|
// Mock external components
|
|
44
44
|
vi.mock('./GoogleSignInTrigger', () => ({
|
|
45
|
-
GoogleSignInTrigger: () => _jsx("button", { children: "Google Sign In" }),
|
|
45
|
+
GoogleSignInTrigger: () => _jsx("button", { type: "button", children: "Google Sign In" }),
|
|
46
46
|
}));
|
|
47
47
|
vi.mock('../../FacebookSignInTrigger', () => ({
|
|
48
|
-
FacebookSignInTrigger: () => _jsx("button", { children: "Facebook Sign In" }),
|
|
48
|
+
FacebookSignInTrigger: () => _jsx("button", { type: "button", children: "Facebook Sign In" }),
|
|
49
49
|
}));
|
|
50
50
|
vi.mock('../../ui/Checkbox', () => {
|
|
51
51
|
const React = require('react');
|
|
@@ -54,11 +54,12 @@ vi.mock('../../ui/Checkbox', () => {
|
|
|
54
54
|
Checkbox: {
|
|
55
55
|
Root: ({ children, onCheckedChange }) => (_jsx(CheckboxContext.Provider, { value: { onCheckedChange }, children: _jsx("div", { children: children }) })),
|
|
56
56
|
Control: ({ children }) => _jsx("div", { children: children }),
|
|
57
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
57
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? 'checkbox-input', ...props, children: children })),
|
|
58
58
|
Indicator: ({ children }) => _jsx("div", { children: children }),
|
|
59
59
|
HiddenInput: React.forwardRef((props, ref) => {
|
|
60
60
|
const { onCheckedChange } = React.useContext(CheckboxContext);
|
|
61
|
-
|
|
61
|
+
const id = props.id ?? 'checkbox-input';
|
|
62
|
+
return (_jsx("input", { type: "checkbox", "data-testid": "input-terms", id: id, ref: ref, ...props, onChange: (e) => {
|
|
62
63
|
if (onCheckedChange)
|
|
63
64
|
onCheckedChange({ checked: e.target.checked });
|
|
64
65
|
} }));
|
|
@@ -73,8 +74,8 @@ vi.mock('../../ui/Field', () => {
|
|
|
73
74
|
return {
|
|
74
75
|
Field: {
|
|
75
76
|
Root: ({ children }) => _jsx("div", { children: children }),
|
|
76
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
77
|
-
Input: React.forwardRef((props, ref) => _jsx("input", { "data-testid": `input-${props.name || 'field'}`, ref: ref, ...props })),
|
|
77
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? props.name ?? 'field', ...props, children: children })),
|
|
78
|
+
Input: React.forwardRef((props, ref) => (_jsx("input", { "data-testid": `input-${props.name || 'field'}`, id: props.id ?? props.name ?? 'field', ref: ref, ...props }))),
|
|
78
79
|
ErrorText: ({ children }) => _jsx("div", { children: children }),
|
|
79
80
|
},
|
|
80
81
|
};
|
|
@@ -84,8 +85,8 @@ vi.mock('../../ui/PinInput', () => {
|
|
|
84
85
|
return {
|
|
85
86
|
PinInput: {
|
|
86
87
|
Root: ({ children }) => _jsx("div", { children: children }),
|
|
87
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
88
|
-
Input: React.forwardRef((props, ref) => _jsx("input", { "data-testid": "input-otp", ref: ref, ...props })),
|
|
88
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? 'pin-input', ...props, children: children })),
|
|
89
|
+
Input: React.forwardRef((props, ref) => (_jsx("input", { "data-testid": "input-otp", id: props.id ?? 'pin-input', ref: ref, ...props }))),
|
|
89
90
|
Control: ({ children }) => _jsx("div", { children: children }),
|
|
90
91
|
HiddenInput: () => null,
|
|
91
92
|
},
|
|
@@ -36,10 +36,10 @@ vi.mock('@ark-ui/react/dialog', () => ({
|
|
|
36
36
|
}));
|
|
37
37
|
// Mock external components
|
|
38
38
|
vi.mock('./GoogleSignInTrigger', () => ({
|
|
39
|
-
GoogleSignInTrigger: () => _jsx("button", { children: "Google Sign In" }),
|
|
39
|
+
GoogleSignInTrigger: () => _jsx("button", { type: "button", children: "Google Sign In" }),
|
|
40
40
|
}));
|
|
41
41
|
vi.mock('./FacebookSignInTrigger', () => ({
|
|
42
|
-
FacebookSignInTrigger: () => _jsx("button", { children: "Facebook Sign In" }),
|
|
42
|
+
FacebookSignInTrigger: () => _jsx("button", { type: "button", children: "Facebook Sign In" }),
|
|
43
43
|
}));
|
|
44
44
|
vi.mock('../../ui/Checkbox', () => {
|
|
45
45
|
const React = require('react');
|
|
@@ -48,11 +48,12 @@ vi.mock('../../ui/Checkbox', () => {
|
|
|
48
48
|
Checkbox: {
|
|
49
49
|
Root: ({ children, onCheckedChange }) => (_jsx(CheckboxContext.Provider, { value: { onCheckedChange }, children: _jsx("div", { children: children }) })),
|
|
50
50
|
Control: ({ children }) => _jsx("div", { children: children }),
|
|
51
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
51
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? 'checkbox-input', ...props, children: children })),
|
|
52
52
|
Indicator: ({ children }) => _jsx("div", { children: children }),
|
|
53
53
|
HiddenInput: React.forwardRef((props, ref) => {
|
|
54
54
|
const { onCheckedChange } = React.useContext(CheckboxContext);
|
|
55
|
-
|
|
55
|
+
const id = props.id ?? 'checkbox-input';
|
|
56
|
+
return (_jsx("input", { type: "checkbox", "data-testid": "input-terms", id: id, ref: ref, ...props, onChange: (e) => {
|
|
56
57
|
if (onCheckedChange)
|
|
57
58
|
onCheckedChange({ checked: e.target.checked });
|
|
58
59
|
} }));
|
|
@@ -69,8 +70,8 @@ vi.mock('../../ui/Field', () => {
|
|
|
69
70
|
return {
|
|
70
71
|
Field: {
|
|
71
72
|
Root: ({ children }) => _jsx("div", { children: children }),
|
|
72
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
73
|
-
Input: React.forwardRef((props, ref) => _jsx("input", { "data-testid": `input-${props.name}`, ref: ref, ...props })),
|
|
73
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? props.name ?? 'field', ...props, children: children })),
|
|
74
|
+
Input: React.forwardRef((props, ref) => (_jsx("input", { "data-testid": `input-${props.name}`, id: props.id ?? props.name ?? 'field', ref: ref, ...props }))),
|
|
74
75
|
HelperText: ({ children }) => _jsx("div", { children: children }),
|
|
75
76
|
ErrorText: ({ children }) => _jsx("div", { children: children }),
|
|
76
77
|
},
|
|
@@ -79,18 +80,21 @@ vi.mock('../../ui/Field', () => {
|
|
|
79
80
|
vi.mock('../../ui/PasswordInput', () => {
|
|
80
81
|
const React = require('react');
|
|
81
82
|
const { useState, useContext, createContext } = React;
|
|
82
|
-
const VisibilityContext = createContext({
|
|
83
|
+
const VisibilityContext = createContext({
|
|
84
|
+
visible: false,
|
|
85
|
+
setVisible: (_v) => { },
|
|
86
|
+
});
|
|
83
87
|
return {
|
|
84
88
|
PasswordInput: {
|
|
85
89
|
Root: ({ children }) => {
|
|
86
90
|
const [visible, setVisible] = useState(false);
|
|
87
91
|
return (_jsx(VisibilityContext.Provider, { value: { visible, setVisible }, children: _jsx("div", { children: children }) }));
|
|
88
92
|
},
|
|
89
|
-
Label: ({ children }) => _jsx("label", { children: children }),
|
|
93
|
+
Label: ({ children, htmlFor, ...props }) => (_jsx("label", { htmlFor: htmlFor ?? 'password', ...props, children: children })),
|
|
90
94
|
Input: React.forwardRef((props, ref) => {
|
|
91
95
|
const { visible } = useContext(VisibilityContext);
|
|
92
96
|
// Ensure type is passed correctly if not overridden
|
|
93
|
-
return _jsx("input", { "data-testid": `input-${props.name || 'password'}`, ref: ref, type: visible ? 'text' : 'password', ...props });
|
|
97
|
+
return (_jsx("input", { "data-testid": `input-${props.name || 'password'}`, id: props.id ?? props.name ?? 'password', ref: ref, type: visible ? 'text' : 'password', ...props }));
|
|
94
98
|
}),
|
|
95
99
|
Control: ({ children }) => _jsx("div", { children: children }),
|
|
96
100
|
VisibilityTrigger: ({ children }) => {
|
|
@@ -197,7 +201,7 @@ describe('NameAndPasswordSignIn', () => {
|
|
|
197
201
|
expect(passwordInput).toHaveAttribute('type', 'password');
|
|
198
202
|
});
|
|
199
203
|
it('handles security question flow', async () => {
|
|
200
|
-
const
|
|
204
|
+
const _user = userEvent.setup();
|
|
201
205
|
// Mock SignInMutation returning a security question challenge
|
|
202
206
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
207
|
mockSignInMutation.data = {
|
|
@@ -26,7 +26,10 @@ vi.mock('./HappyBingo/SignInForm', () => ({
|
|
|
26
26
|
}));
|
|
27
27
|
// Mock Next.js Image since it's used in the wrapper
|
|
28
28
|
vi.mock('next/image', () => ({
|
|
29
|
-
default: (props) =>
|
|
29
|
+
default: (props) => {
|
|
30
|
+
// biome-ignore lint/performance/noImgElement: mock Next/Image with plain img in tests
|
|
31
|
+
return _jsx("img", { ...props, alt: props.alt || '' });
|
|
32
|
+
},
|
|
30
33
|
}));
|
|
31
34
|
const mockLogo = '/mock-logo.png';
|
|
32
35
|
describe('SignIn Wrapper', () => {
|
|
@@ -60,7 +63,6 @@ describe('SignIn Wrapper', () => {
|
|
|
60
63
|
expect(screen.getByTestId('mock-hb-sign-in-form')).toBeInTheDocument();
|
|
61
64
|
});
|
|
62
65
|
it('closes dialog when close trigger is clicked', async () => {
|
|
63
|
-
const user = require('@testing-library/user-event').default.setup();
|
|
64
66
|
render(_jsx(SignIn, { ...defaultProps }));
|
|
65
67
|
// Find close button (usually checking for label or class, assuming standard Dialog CloseTrigger)
|
|
66
68
|
// Our Dialog mock or real Dialog implementation needs to be checked.
|
|
@@ -74,7 +76,6 @@ describe('SignIn Wrapper', () => {
|
|
|
74
76
|
</Dialog.CloseTrigger>
|
|
75
77
|
*/
|
|
76
78
|
// Ark UI CloseTrigger usually renders a button.
|
|
77
|
-
const closeButtons = screen.getAllByRole('button');
|
|
78
79
|
// Assuming the first one or finding by icon logic?
|
|
79
80
|
// Actually, let's just use fireEvent on the overlay or trigger if finding it is hard without testId.
|
|
80
81
|
// But let's try finding by role.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
4
4
|
import Image from 'next/image';
|
|
5
|
-
import { useRef, useState } from 'react';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { Controller, useForm } from 'react-hook-form';
|
|
7
7
|
import z from 'zod';
|
|
8
8
|
import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
|
|
@@ -20,16 +20,21 @@ import { Dialog } from '../../ui/Dialog/index.js';
|
|
|
20
20
|
import { Field } from '../../ui/Field/index.js';
|
|
21
21
|
import { PinInput } from '../../ui/PinInput/index.js';
|
|
22
22
|
import { Portal } from '../../ui/Portal/index.js';
|
|
23
|
-
export function UpdateMobileNumber(
|
|
23
|
+
export function UpdateMobileNumber() {
|
|
24
24
|
const accountQuery = useAccountQuery();
|
|
25
25
|
const account = accountQuery.data;
|
|
26
26
|
const isAccountLoading = accountQuery.isLoading;
|
|
27
27
|
const hasMobileNumber = !!account?.mobileNumber;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
29
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We only want to open the dialog when the account data loads, not on every hasMobileNumber change
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!isAccountLoading && !!account && !hasMobileNumber) {
|
|
32
|
+
setIsDialogOpen(true);
|
|
33
|
+
}
|
|
34
|
+
else if (!isAccountLoading && !!account && hasMobileNumber) {
|
|
35
|
+
setIsDialogOpen(false);
|
|
36
|
+
}
|
|
37
|
+
}, [isAccountLoading, account?.mobileNumber]);
|
|
33
38
|
const [step, setStep] = useState(1);
|
|
34
39
|
const sendVerificationCodeMutation = useSendVerificationCodeMutation({
|
|
35
40
|
onSuccess: () => {
|
|
@@ -52,7 +57,7 @@ export function UpdateMobileNumber({ onClose }) {
|
|
|
52
57
|
title: 'Verification Successful',
|
|
53
58
|
description: 'Your mobile number has been verified.',
|
|
54
59
|
});
|
|
55
|
-
|
|
60
|
+
setIsDialogOpen(false);
|
|
56
61
|
},
|
|
57
62
|
onError: (err) => {
|
|
58
63
|
const errorMessage = err.message === 'Internal Server Error'
|