From 7c8051a440654bf7571d96a30a10eaf2f33b3cf9 Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Thu, 26 Jun 2025 19:27:23 -0300 Subject: [PATCH] test: fix a couple of tests --- site.config.test.tsx | 1 - .../tests/BaseContainer.test.jsx | 9 ++++----- .../tests/ForgotPasswordPage.test.jsx | 17 +++++++---------- .../CountryField/CountryField.test.jsx | 8 +------- .../tests/RegistrationFailure.test.jsx | 13 ++++++------- .../components/tests/ThirdPartyAuth.test.jsx | 18 ++++++------------ 6 files changed, 24 insertions(+), 42 deletions(-) diff --git a/site.config.test.tsx b/site.config.test.tsx index b7fc3f43..2a1a3279 100644 --- a/site.config.test.tsx +++ b/site.config.test.tsx @@ -37,7 +37,6 @@ const siteConfig: SiteConfig = { PRIVACY_POLICY: null, SEARCH_CATALOG_URL: null, SESSION_COOKIE_DOMAIN: 'local.openedx.io', - SHOW_CONFIGURABLE_EDX_FIELDS: false, SHOW_REGISTRATION_LINKS: false, TOS_AND_HONOR_CODE: null, TOS_LINK: null, diff --git a/src/base-container/tests/BaseContainer.test.jsx b/src/base-container/tests/BaseContainer.test.jsx index d84c143a..aa530393 100644 --- a/src/base-container/tests/BaseContainer.test.jsx +++ b/src/base-container/tests/BaseContainer.test.jsx @@ -1,8 +1,9 @@ -import { IntlProvider, mergeSiteConfig } from '@openedx/frontend-base'; +import { IntlProvider, mergeAppConfig } from '@openedx/frontend-base'; import { render } from '@testing-library/react'; import { Context as ResponsiveContext } from 'react-responsive'; import BaseContainer from '../index'; +import { testAppId } from '../../setupTest'; const LargeScreen = { wrappingComponent: ResponsiveContext.Provider, @@ -25,10 +26,8 @@ describe('Base component tests', () => { }); it('renders Image layout when ENABLE_IMAGE_LAYOUT configuration is enabled', () => { - mergeSiteConfig({ - custom: { - ENABLE_IMAGE_LAYOUT: true, - } + mergeAppConfig(testAppId, { + ENABLE_IMAGE_LAYOUT: true, }); const { container } = render( diff --git a/src/forgot-password/tests/ForgotPasswordPage.test.jsx b/src/forgot-password/tests/ForgotPasswordPage.test.jsx index 2c4516df..3fdea9a8 100644 --- a/src/forgot-password/tests/ForgotPasswordPage.test.jsx +++ b/src/forgot-password/tests/ForgotPasswordPage.test.jsx @@ -1,7 +1,7 @@ import { Provider } from 'react-redux'; import { - configureI18n, injectIntl, IntlProvider, mergeSiteConfig + configureI18n, injectIntl, IntlProvider, mergeAppConfig } from '@openedx/frontend-base'; import { fireEvent, render, screen, @@ -11,6 +11,7 @@ import configureStore from 'redux-mock-store'; import { INTERNAL_SERVER_ERROR, LOGIN_PAGE } from '../../data/constants'; import { PASSWORD_RESET } from '../../reset-password/data/constants'; +import { testAppId } from '../../setupTest'; import { setForgotPasswordFormData } from '../data/actions'; import ForgotPasswordPage from '../ForgotPasswordPage'; @@ -41,11 +42,9 @@ const initialState = { }; describe('ForgotPasswordPage', () => { - mergeSiteConfig({ - custom: { - LOGIN_ISSUE_SUPPORT_LINK: '', - INFO_EMAIL: '', - } + mergeAppConfig(testAppId, { + LOGIN_ISSUE_SUPPORT_LINK: '', + INFO_EMAIL: '', }); let props = {}; @@ -81,10 +80,8 @@ describe('ForgotPasswordPage', () => { }); it('should display need other help signing in button', () => { - mergeSiteConfig({ - custom: { - LOGIN_ISSUE_SUPPORT_LINK: '/support', - } + mergeAppConfig(testAppId, { + LOGIN_ISSUE_SUPPORT_LINK: '/support', }); render(reduxWrapper()); const forgotPasswordButton = screen.findByText('Need help signing in?'); diff --git a/src/register/RegistrationFields/CountryField/CountryField.test.jsx b/src/register/RegistrationFields/CountryField/CountryField.test.jsx index aa286fbe..b798af32 100644 --- a/src/register/RegistrationFields/CountryField/CountryField.test.jsx +++ b/src/register/RegistrationFields/CountryField/CountryField.test.jsx @@ -1,6 +1,6 @@ import { Provider } from 'react-redux'; -import { injectIntl, IntlProvider, mergeSiteConfig } from '@openedx/frontend-base'; +import { injectIntl, IntlProvider } from '@openedx/frontend-base'; import { fireEvent, render } from '@testing-library/react'; import { BrowserRouter as Router } from 'react-router-dom'; import configureStore from 'redux-mock-store'; @@ -71,12 +71,6 @@ describe('CountryField', () => { }); describe('Test Country Field', () => { - mergeSiteConfig({ - custom: { - SHOW_CONFIGURABLE_EDX_FIELDS: true, - } - }); - const emptyFieldValidation = { country: 'Select your country or region of residence', }; diff --git a/src/register/components/tests/RegistrationFailure.test.jsx b/src/register/components/tests/RegistrationFailure.test.jsx index 94a8c728..e38ca183 100644 --- a/src/register/components/tests/RegistrationFailure.test.jsx +++ b/src/register/components/tests/RegistrationFailure.test.jsx @@ -1,7 +1,7 @@ import { Provider } from 'react-redux'; import { - configureI18n, getLocale, injectIntl, IntlProvider, mergeSiteConfig + configureI18n, getLocale, injectIntl, IntlProvider, mergeAppConfig } from '@openedx/frontend-base'; import { render, screen } from '@testing-library/react'; import { BrowserRouter as Router } from 'react-router-dom'; @@ -10,6 +10,7 @@ import configureStore from 'redux-mock-store'; import { FORBIDDEN_REQUEST, INTERNAL_SERVER_ERROR, TPA_AUTHENTICATION_FAILURE, TPA_SESSION_EXPIRED, } from '../../data/constants'; +import { testAppId } from '../../../setupTest'; import RegistrationPage from '../../RegistrationPage'; import RegistrationFailureMessage from '../RegistrationFailure'; @@ -40,12 +41,10 @@ jest.mock('react-router-dom', () => { }); describe('RegistrationFailure', () => { - mergeSiteConfig({ - custom: { - PRIVACY_POLICY: 'https://privacy-policy.com', - TOS_AND_HONOR_CODE: 'https://tos-and-honot-code.com', - USER_RETENTION_COOKIE_NAME: 'authn-returning-user', - } + mergeAppConfig(testAppId, { + PRIVACY_POLICY: 'https://privacy-policy.com', + TOS_AND_HONOR_CODE: 'https://tos-and-honot-code.com', + USER_RETENTION_COOKIE_NAME: 'authn-returning-user', }); let props = {}; diff --git a/src/register/components/tests/ThirdPartyAuth.test.jsx b/src/register/components/tests/ThirdPartyAuth.test.jsx index 8fbf46dd..841feea4 100644 --- a/src/register/components/tests/ThirdPartyAuth.test.jsx +++ b/src/register/components/tests/ThirdPartyAuth.test.jsx @@ -1,7 +1,7 @@ import { Provider } from 'react-redux'; import { - configureI18n, getSiteConfig, getLocale, injectIntl, IntlProvider, mergeSiteConfig + configureI18n, getSiteConfig, getLocale, injectIntl, IntlProvider, mergeAppConfig } from '@openedx/frontend-base'; import { fireEvent, render } from '@testing-library/react'; import { BrowserRouter as Router } from 'react-router-dom'; @@ -10,6 +10,7 @@ import configureStore from 'redux-mock-store'; import { COMPLETE_STATE, LOGIN_PAGE, PENDING_STATE, REGISTER_PAGE, } from '../../../data/constants'; +import { testAppId } from '../../../setupTest'; import RegistrationPage from '../../RegistrationPage'; jest.mock('@openedx/frontend-base', () => ({ @@ -39,12 +40,10 @@ jest.mock('react-router-dom', () => { }); describe('ThirdPartyAuth', () => { - mergeSiteConfig({ - custom: { - PRIVACY_POLICY: 'https://privacy-policy.com', - TOS_AND_HONOR_CODE: 'https://tos-and-honot-code.com', - USER_RETENTION_COOKIE_NAME: 'authn-returning-user', - } + mergeAppConfig(testAppId, { + PRIVACY_POLICY: 'https://privacy-policy.com', + TOS_AND_HONOR_CODE: 'https://tos-and-honot-code.com', + USER_RETENTION_COOKIE_NAME: 'authn-returning-user', }); let props = {}; @@ -128,11 +127,6 @@ describe('ThirdPartyAuth', () => { }; describe('Test Third Party Auth', () => { - mergeSiteConfig({ - custom: { - SHOW_CONFIGURABLE_EDX_FIELDS: true, - } - }); getLocale.mockImplementation(() => ('en-us')); const secondaryProviders = {