-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose
getRoutes
to share routes with private env.config.js f…
…iles (#1143)
- Loading branch information
1 parent
42c06b0
commit 10362ba
Showing
65 changed files
with
4,888 additions
and
5,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
], | ||
"dependencies": { | ||
"@edx/brand": "npm:@openedx/[email protected]", | ||
"@edx/frontend-component-footer": "13.0.2", | ||
"@edx/frontend-component-footer": "13.0.3", | ||
"@edx/frontend-enterprise-catalog-search": "10.6.0", | ||
"@edx/frontend-enterprise-hotjar": "6.0.0", | ||
"@edx/frontend-enterprise-logistration": "8.0.0", | ||
|
@@ -18,6 +18,7 @@ | |
"@edx/reactifex": "2.2.0", | ||
"@loadable/component": "5.16.3", | ||
"@lukemorales/query-key-factory": "1.3.4", | ||
"@openedx/frontend-slot-footer": "1.0.3", | ||
"@openedx/paragon": "21.13.1", | ||
"@tanstack/react-query": "4.28.0", | ||
"@tanstack/react-query-devtools": "4.29.0", | ||
|
@@ -46,8 +47,8 @@ | |
"react-instantsearch-dom": "6.38.1", | ||
"react-parallax": "3.3.0", | ||
"react-redux": "7.2.2", | ||
"react-router": "6.16.0", | ||
"react-router-dom": "6.16.0", | ||
"react-router": "6.18.0", | ||
"react-router-dom": "6.18.0", | ||
"react-router-hash-link": "2.3.1", | ||
"react-scroll": "1.8.4", | ||
"react-string-replace": "1.1.1", | ||
|
@@ -61,8 +62,9 @@ | |
}, | ||
"devDependencies": { | ||
"@edx/browserslist-config": "1.1.1", | ||
"@edx/typescript-config": "1.1.0", | ||
"@faker-js/faker": "8.4.1", | ||
"@openedx/frontend-build": "13.0.28", | ||
"@openedx/frontend-build": "14.0.14", | ||
"@tanstack/eslint-plugin-query": "4.29.9", | ||
"@testing-library/jest-dom": "5.11.9", | ||
"@testing-library/react": "12.1.5", | ||
|
@@ -81,16 +83,17 @@ | |
"react-test-renderer": "17.0.2", | ||
"reactifex": "1.1.1", | ||
"resize-observer-polyfill": "1.5.1", | ||
"rosie": "2.1.1" | ||
"rosie": "2.1.1", | ||
"ts-loader": "9.5.1" | ||
}, | ||
"keywords": [], | ||
"license": "AGPL-3.0", | ||
"scripts": { | ||
"build": "fedx-scripts webpack", | ||
"build:with-theme": "THEME=npm:@edx/brand-edx.org@latest npm run install-theme && npm run build", | ||
"i18n_extract": "fedx-scripts formatjs extract --throws", | ||
"lint": "fedx-scripts eslint --ext .js --ext .jsx .", | ||
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .", | ||
"lint": "fedx-scripts eslint --ext .js --ext .jsx --ext .ts --ext .tsx .", | ||
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx --ext .ts --ext .tsx .", | ||
"precommit": "npm run lint", | ||
"snapshot": "fedx-scripts jest --updateSnapshot", | ||
"install-theme": "npm install \"@edx/brand@${THEME}\" --no-save", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default as makeAcademiesLoader } from './academiesLoader'; | ||
export { default as makeAcademiesLoader } from './academyLoader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/components/app/data/queries/extractEnterpriseCustomer.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { when, resetAllWhenMocks } from 'jest-when'; | ||
import { authenticatedUserFactory, enterpriseCustomerFactory, enterpriseCustomerUserFactory } from '../services/data/__factories__'; | ||
import extractEnterpriseCustomer from './extractEnterpriseCustomer'; | ||
import { queryEnterpriseLearner } from './queries'; | ||
|
||
const mockEnsureQueryData = jest.fn(); | ||
const mockQueryClient = { | ||
ensureQueryData: mockEnsureQueryData, | ||
}; | ||
const mockAuthenticatedUser = authenticatedUserFactory(); | ||
const mockEnterpriseCustomer = enterpriseCustomerFactory(); | ||
const mockEnterpriseCustomerUser = enterpriseCustomerUserFactory({ | ||
enterprise_customer: mockEnterpriseCustomer, | ||
}); | ||
|
||
const getQueryEnterpriseLearner = ({ hasEnterpriseSlug = true } = {}) => queryEnterpriseLearner( | ||
mockAuthenticatedUser.username, | ||
hasEnterpriseSlug ? mockEnterpriseCustomer.slug : undefined, | ||
); | ||
|
||
describe('extractEnterpriseCustomer', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
resetAllWhenMocks(); | ||
}); | ||
|
||
it.each([ | ||
{ | ||
routeEnterpriseSlug: mockEnterpriseCustomer.slug, | ||
enterpriseCustomerUser: mockEnterpriseCustomerUser, | ||
staffEnterpriseCustomer: undefined, | ||
expectedEnterpriseCustomer: mockEnterpriseCustomer, | ||
}, | ||
{ | ||
routeEnterpriseSlug: mockEnterpriseCustomer.slug, | ||
enterpriseCustomerUser: undefined, | ||
staffEnterpriseCustomer: mockEnterpriseCustomer, | ||
expectedEnterpriseCustomer: mockEnterpriseCustomer, | ||
}, | ||
{ | ||
routeEnterpriseSlug: mockEnterpriseCustomer.slug, | ||
enterpriseCustomerUser: mockEnterpriseCustomerUser, | ||
staffEnterpriseCustomer: mockEnterpriseCustomer, | ||
expectedEnterpriseCustomer: mockEnterpriseCustomer, | ||
}, | ||
{ | ||
routeEnterpriseSlug: undefined, | ||
enterpriseCustomerUser: mockEnterpriseCustomerUser, | ||
staffEnterpriseCustomer: undefined, | ||
expectedEnterpriseCustomer: mockEnterpriseCustomer, | ||
}, | ||
{ | ||
routeEnterpriseSlug: undefined, | ||
enterpriseCustomerUser: undefined, | ||
staffEnterpriseCustomer: mockEnterpriseCustomer, | ||
expectedEnterpriseCustomer: undefined, | ||
}, | ||
{ | ||
routeEnterpriseSlug: undefined, | ||
enterpriseCustomerUser: mockEnterpriseCustomerUser, | ||
staffEnterpriseCustomer: mockEnterpriseCustomer, | ||
expectedEnterpriseCustomer: mockEnterpriseCustomer, | ||
}, | ||
{ | ||
routeEnterpriseSlug: mockEnterpriseCustomer.slug, | ||
enterpriseCustomerUser: undefined, | ||
staffEnterpriseCustomer: undefined, | ||
expectedEnterpriseCustomer: undefined, | ||
}, | ||
])('should return or throw error as expected (%s)', async ({ | ||
routeEnterpriseSlug, | ||
enterpriseCustomerUser, | ||
staffEnterpriseCustomer, | ||
expectedEnterpriseCustomer, | ||
}) => { | ||
const args = { | ||
queryClient: mockQueryClient, | ||
authenticatedUser: mockAuthenticatedUser, | ||
enterpriseSlug: routeEnterpriseSlug, | ||
}; | ||
const queryEnterpriseLearnerResult = { | ||
activeEnterpriseCustomer: enterpriseCustomerUser?.enterpriseCustomer, | ||
allLinkedEnterpriseCustomerUsers: enterpriseCustomerUser ? [enterpriseCustomerUser] : [], | ||
staffEnterpriseCustomer, | ||
}; | ||
const queryEnterpriseLearnerQueryKey = getQueryEnterpriseLearner({ | ||
hasEnterpriseSlug: !!routeEnterpriseSlug, | ||
}).queryKey; | ||
when(mockEnsureQueryData) | ||
.calledWith( | ||
expect.objectContaining({ | ||
queryKey: queryEnterpriseLearnerQueryKey, | ||
}), | ||
) | ||
.mockResolvedValue(queryEnterpriseLearnerResult); | ||
try { | ||
const enterpriseCustomer = await extractEnterpriseCustomer(args); | ||
expect(enterpriseCustomer).toEqual(expectedEnterpriseCustomer); | ||
} catch (error) { | ||
expect(error.message).toBe(`Could not find enterprise customer for slug ${routeEnterpriseSlug}`); | ||
} | ||
}); | ||
}); |
17 changes: 10 additions & 7 deletions
17
...data/queries/extractEnterpriseCustomer.js → ...data/queries/extractEnterpriseCustomer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.