diff --git a/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.module.scss b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.module.scss new file mode 100644 index 000000000..5d5d7e440 --- /dev/null +++ b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.module.scss @@ -0,0 +1,49 @@ +@use '@jwp/ott-ui-react/src/styles/variables'; +@use '@jwp/ott-ui-react/src/styles/theme'; + +.topContainer { + display: flex; + flex-direction: column; + align-items: center; + padding-top: 40px; + row-gap: 32px; + + .circleHug { + display: flex; + justify-content: center; + align-items: center; + width: 80px; + height: 80px; + border: 2px solid variables.$green; + border-radius: 50%; + } +} + +.innerContainer { + display: flex; + flex-direction: column; + align-items: center; + row-gap: 8px; + + .title { + font-weight: var(--body-font-weight-bold); + font-size: 24px; + } + + .message { + margin: 0; + font-size: 16px; + text-align: center; + } +} + +.buttonContainer { + align-self: stretch; +} + +.welcome { + h2 { + font-weight: var(--body-font-weight-bold); + font-size: 24px; + } +} diff --git a/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.test.tsx b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.test.tsx new file mode 100644 index 000000000..6005e356a --- /dev/null +++ b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.test.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { act, fireEvent, render } from '@testing-library/react'; + +import PaymentSuccessful from './PaymentSuccessful'; + +describe('', () => { + test('renders and matches snapshot', () => { + const { container } = render(); + + expect(container).toMatchSnapshot(); + }); + + test('calls the onCloseButtonClick callback when clicking the close button', () => { + const onCloseButtonClick = vi.fn(); + const { getByText } = render(); + + fireEvent.click(getByText('checkout.start_watching')); + + expect(onCloseButtonClick).toBeCalled(); + }); + + test('calls the onCloseButtonClick callback when clicking the close button', () => { + vi.useFakeTimers(); + const onCountdownCompleted = vi.fn(); + + render(); + + let i = 10; + while (i--) { + act(() => { + vi.runAllTimers(); + }); + } + + expect(onCountdownCompleted).toBeCalled(); + vi.useRealTimers(); + }); +}); diff --git a/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.tsx b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.tsx new file mode 100644 index 000000000..90ce96d4c --- /dev/null +++ b/packages/ui-react/src/components/PaymentSuccessful/PaymentSuccessful.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import CheckmarkSVG from '@jwp/ott-theme/assets/icons/check-green.svg?react'; +import useCountdown from '@jwp/ott-hooks-react/src/useCountdown'; + +import Button from '../Button/Button'; + +import styles from './PaymentSuccessful.module.scss'; + +type Props = { + onCloseButtonClick?: () => void; + onCountdownCompleted?: () => void; + siteName?: string; +}; + +const PaymentSuccessful: React.FC = ({ onCloseButtonClick, onCountdownCompleted, siteName }) => { + const { t } = useTranslation('account'); + const countdown = useCountdown(10, 1, onCountdownCompleted); + + return ( +
+
+ +
+
+

{t('checkout.payment_successful_title')}

+

{t('checkout.payment_successful_description', { siteName })}

+
+
+
+
+ ); +}; + +export default PaymentSuccessful; diff --git a/packages/ui-react/src/components/PaymentSuccessful/__snapshots__/PaymentSuccessful.test.tsx.snap b/packages/ui-react/src/components/PaymentSuccessful/__snapshots__/PaymentSuccessful.test.tsx.snap new file mode 100644 index 000000000..da88c4471 --- /dev/null +++ b/packages/ui-react/src/components/PaymentSuccessful/__snapshots__/PaymentSuccessful.test.tsx.snap @@ -0,0 +1,55 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[` > renders and matches snapshot 1`] = ` +
+
+
+ + + +
+
+

+ checkout.payment_successful_title +

+

+ checkout.payment_successful_description +

+
+
+ +
+
+
+`; diff --git a/packages/ui-react/src/components/Welcome/Welcome.module.scss b/packages/ui-react/src/components/Welcome/Welcome.module.scss index 5d5d7e440..5472ff2d2 100644 --- a/packages/ui-react/src/components/Welcome/Welcome.module.scss +++ b/packages/ui-react/src/components/Welcome/Welcome.module.scss @@ -1,49 +1,9 @@ @use '@jwp/ott-ui-react/src/styles/variables'; @use '@jwp/ott-ui-react/src/styles/theme'; -.topContainer { - display: flex; - flex-direction: column; - align-items: center; - padding-top: 40px; - row-gap: 32px; - - .circleHug { - display: flex; - justify-content: center; - align-items: center; - width: 80px; - height: 80px; - border: 2px solid variables.$green; - border-radius: 50%; - } -} - -.innerContainer { - display: flex; - flex-direction: column; - align-items: center; - row-gap: 8px; - - .title { - font-weight: var(--body-font-weight-bold); - font-size: 24px; - } - - .message { - margin: 0; - font-size: 16px; - text-align: center; - } -} - -.buttonContainer { - align-self: stretch; -} - .welcome { h2 { font-weight: var(--body-font-weight-bold); font-size: 24px; } -} +} \ No newline at end of file diff --git a/packages/ui-react/src/components/Welcome/Welcome.tsx b/packages/ui-react/src/components/Welcome/Welcome.tsx index 8dfa6d2a9..93b215eb7 100644 --- a/packages/ui-react/src/components/Welcome/Welcome.tsx +++ b/packages/ui-react/src/components/Welcome/Welcome.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; -import CheckmarkSVG from '@jwp/ott-theme/assets/icons/check-green.svg?react'; import useCountdown from '@jwp/ott-hooks-react/src/useCountdown'; import Button from '../Button/Button'; @@ -18,17 +17,10 @@ const Welcome: React.FC = ({ onCloseButtonClick, onCountdownCompleted, si const countdown = useCountdown(10, 1, onCountdownCompleted); return ( -
-
- -
-
-

{t('checkout.welcome_title')}

-

{t('checkout.welcome_description', { siteName })}

-
-
-
+
+

{t('checkout.welcome_title', { siteName })}

+

{t('checkout.welcome_description', { siteName })}

+
); }; diff --git a/packages/ui-react/src/components/Welcome/__snapshots__/Welcome.test.tsx.snap b/packages/ui-react/src/components/Welcome/__snapshots__/Welcome.test.tsx.snap index 9db591ba3..3b93dde6e 100644 --- a/packages/ui-react/src/components/Welcome/__snapshots__/Welcome.test.tsx.snap +++ b/packages/ui-react/src/components/Welcome/__snapshots__/Welcome.test.tsx.snap @@ -3,53 +3,22 @@ exports[` > renders and matches snapshot 1`] = `
-
+ checkout.welcome_title + +

+ checkout.welcome_description +

+
-
-

- checkout.welcome_title -

-

- checkout.welcome_description -

-
-
- -
+ + checkout.start_watching + +
`; diff --git a/packages/ui-react/src/containers/AccountModal/AccountModal.tsx b/packages/ui-react/src/containers/AccountModal/AccountModal.tsx index 5a1b26a7f..3ca575597 100644 --- a/packages/ui-react/src/containers/AccountModal/AccountModal.tsx +++ b/packages/ui-react/src/containers/AccountModal/AccountModal.tsx @@ -10,6 +10,7 @@ import useQueryParam from '@jwp/ott-ui-react/src/hooks/useQueryParam'; import LoadingOverlay from '../../components/LoadingOverlay/LoadingOverlay'; import Welcome from '../../components/Welcome/Welcome'; +import PaymentSuccessful from '../../components/PaymentSuccessful/PaymentSuccessful'; import PaymentFailed from '../../components/PaymentFailed/PaymentFailed'; import Dialog from '../../components/Dialog/Dialog'; import DeleteAccountModal from '../../components/DeleteAccountModal/DeleteAccountModal'; @@ -48,6 +49,7 @@ export type AccountModals = { 'payment-error': 'payment-error'; 'payment-cancelled': 'payment-cancelled'; welcome: 'welcome'; + 'payment-successful': 'payment-successful'; 'reset-password': 'reset-password'; 'forgot-password': 'forgot-password'; 'add-password': 'add-password'; @@ -134,6 +136,8 @@ const AccountModal = () => { return ; case 'welcome': return ; + case 'payment-successful': + return ; case 'reset-password': return ; case 'forgot-password': diff --git a/packages/ui-react/src/containers/AccountModal/forms/ChooseOffer.tsx b/packages/ui-react/src/containers/AccountModal/forms/ChooseOffer.tsx index 14ed0998c..47ffaeb93 100644 --- a/packages/ui-react/src/containers/AccountModal/forms/ChooseOffer.tsx +++ b/packages/ui-react/src/containers/AccountModal/forms/ChooseOffer.tsx @@ -48,7 +48,7 @@ const ChooseOffer = () => { const url = await chooseOffer.mutateAsync({ offer, - successUrl: `${baseUrl}${modalURLFromLocation(location, 'welcome')}`, + successUrl: `${baseUrl}${modalURLFromLocation(location, 'payment-successful')}`, cancelUrl: `${baseUrl}${modalURLFromLocation(location, 'payment-cancelled')}`, }); diff --git a/platforms/web/public/locales/en/account.json b/platforms/web/public/locales/en/account.json index 43466c8f7..7f79e925c 100644 --- a/platforms/web/public/locales/en/account.json +++ b/platforms/web/public/locales/en/account.json @@ -30,7 +30,7 @@ "monthly": "Monthly subscription", "no_payment_needed": "No payment needed", "payment_cancelled": "Payment cancelled", - "payment_cancelled_message": "This payment attempt was cancelled and no charges were made. If this wasn’t intentional, please retry the payment process.", + "payment_cancelled_message": "You have cancelled the payment.", "payment_error": "Payment failed", "payment_method": "Payment method", "payment_method_fee": "Payment method fee", @@ -50,8 +50,10 @@ "upgrade_success": "Subscription updated!", "upgrade_success_message": "Your subscription is updated and can be used immediately.", "waiting_for_payment": "Waiting for payment", - "welcome_description": "Thank you for your subscription, enjoy all our content.", - "welcome_title": "Payment successful", + "welcome_description": "Thank you for subscribing to {{siteName}}. Please enjoy all our content.", + "welcome_title": "Welcome to {{siteName}}", + "payment_successful_title": "Payment successful", + "payment_successful_description": "Thank you for your subscription, enjoy all our content.", "yearly": "Yearly subscription" }, "choose_offer": { diff --git a/platforms/web/public/locales/es/account.json b/platforms/web/public/locales/es/account.json index a701dac76..98a77ccf8 100644 --- a/platforms/web/public/locales/es/account.json +++ b/platforms/web/public/locales/es/account.json @@ -55,6 +55,8 @@ "waiting_for_payment": "Esperando el pago", "welcome_description": "Gracias por suscribirte a {{siteName}}. Disfruta de todo nuestro contenido.", "welcome_title": "Bienvenido/a a {{siteName}}", + "payment_successful_title": "Pago exitoso", + "payment_successful_description": "Gracias por tu suscripción, disfruta de todo nuestro contenido.", "yearly": "Suscripción anual" }, "choose_offer": { diff --git a/platforms/web/test-e2e/tests/register_test.ts b/platforms/web/test-e2e/tests/register_test.ts index 0a35a366b..861353d45 100644 --- a/platforms/web/test-e2e/tests/register_test.ts +++ b/platforms/web/test-e2e/tests/register_test.ts @@ -153,6 +153,6 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) { I.click('Continue'); I.waitForLoaderDone(20); - I.see('Payment successful'); + I.see('Welcome to JW OTT Web App (AuthVod)'); }); } diff --git a/platforms/web/test-e2e/utils/constants.ts b/platforms/web/test-e2e/utils/constants.ts index f6e4c10b6..21f9d7757 100644 --- a/platforms/web/test-e2e/utils/constants.ts +++ b/platforms/web/test-e2e/utils/constants.ts @@ -102,6 +102,6 @@ export default { }, creditCard: { inplayer: '4111111111111111', - cleeng: '5555444433331111', + cleeng: '5555341244441115', }, }; diff --git a/platforms/web/test-e2e/utils/payments.ts b/platforms/web/test-e2e/utils/payments.ts index 4530e9e48..904b1e95b 100644 --- a/platforms/web/test-e2e/utils/payments.ts +++ b/platforms/web/test-e2e/utils/payments.ts @@ -31,8 +31,8 @@ export function formatDate(date: Date) { export async function finishSubscription(I: CodeceptJS.I) { I.click('Continue'); - I.waitForText('Payment successful', longTimeout); - I.waitForText('Thank you for your subscription, enjoy all our content.'); + I.waitForText(`Welcome to JW OTT Web App (SVOD)`, longTimeout); + I.waitForText(`Thank you for subscribing to JW OTT Web App (SVOD). Please enjoy all our content.`); I.click('Start watching'); }