From ef4b7ecb5d5515342f0406f2be05ed41c0d11b41 Mon Sep 17 00:00:00 2001 From: Jason Wesson Date: Thu, 28 Mar 2024 16:43:59 +0000 Subject: [PATCH] feat: merge JS config variables in initialized config --- src/config/index.js | 6 ++++++ src/setupTest.jsx | 21 --------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 5efd3d1..4430482 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,3 +1,6 @@ +import { mergeConfig } from '@edx/frontend-platform'; +import envConfig from 'env.config'; + const configuration = { // BASE_URL: process.env.BASE_URL, LMS_BASE_URL: process.env.LMS_BASE_URL, @@ -20,6 +23,9 @@ const configuration = { ENABLE_EDX_PERSONAL_DASHBOARD: process.env.ENABLE_EDX_PERSONAL_DASHBOARD === 'true', }; +// This mergeConfig ensures that any variables assigned by process.env are still overwritten if declared in JS config +mergeConfig(envConfig); + const features = {}; export { configuration, features }; diff --git a/src/setupTest.jsx b/src/setupTest.jsx index cb89f95..1218eaa 100755 --- a/src/setupTest.jsx +++ b/src/setupTest.jsx @@ -1,10 +1,6 @@ /* eslint-disable import/no-extraneous-dependencies */ import '@testing-library/jest-dom'; import '@testing-library/jest-dom/extend-expect'; -// import { mergeConfig } from '@edx/frontend-platform'; -// import envConfig from '../env.config'; - -// mergeConfig(envConfig); jest.mock('react', () => ({ ...jest.requireActual('react'), @@ -66,23 +62,6 @@ jest.mock('@edx/frontend-platform/i18n', () => { }; }); -/* -When .env.test is removed, uncomment the env vars below and add any environment variables for testing with Jest - -Context: Snapshot is not currently set up to be able to parse the environment variables in env.config.js -*/ - -jest.mock('@edx/frontend-platform', () => ({ - getConfig: jest.fn(() => ({ - LMS_BASE_URL: 'http://localhost:18000', - LOGOUT_URL: 'http://localhost:18000/logout', - LOGO_URL: 'https://edx-cdn.org/v3/default/logo.svg', - MARKETING_SITE_BASE_URL: 'http://localhost:18000', - SUPPORT_URL: 'http://localhost:18000/support', - OPTIMIZELY_FULL_STACK_SDK_KEY: 'SDK Key', - })), -})); - jest.mock('@openedx/paragon', () => jest.requireActual('testUtils').mockNestedComponents({ Alert: { Heading: 'Alert.Heading',