From 1b6a5e51ccd8aff48666c7f6cbc52bfaa3306a37 Mon Sep 17 00:00:00 2001 From: NarmeenNaveedAhmed <62057644+NarmeenNaveedAhmed@users.noreply.github.com> Date: Wed, 29 Apr 2020 17:33:14 +0100 Subject: [PATCH] feat(one-app): removed tenancy or tenant instances (#69) * feat(one-app): removed tenancy or tenant instances * feat(one-app): implemented pr comments * feat(one-app): updated with PR comments * feat(one-app): ran build successfully * feat(one-app): integeration test pass * feat(one-app): integration test pass * feat(one-app): integration tests pass Co-authored-by: James Singleton Co-authored-by: Nelly Kiboi Co-authored-by: Jonny Adshead --- __tests__/integration/one-app.spec.js | 18 +++++++++--------- .../__snapshots__/onModuleLoad.spec.jsx.snap | 12 ++++++------ .../__snapshots__/safeRequest.spec.js.snap | 4 ++-- .../__snapshots__/stateConfig.spec.js.snap | 4 ++-- .../server/utils/batchModulesToUpdate.spec.js | 2 +- __tests__/server/utils/onModuleLoad.spec.jsx | 18 +++++++++--------- __tests__/universal/routes.spec.jsx | 2 +- .../frank-lloyd-root/0.0.0/README.md | 2 +- .../frank-lloyd-root/0.0.0/package.json | 2 +- .../0.0.0/src/components/FrankLloydRoot.jsx | 2 +- .../frank-lloyd-root/0.0.1/README.md | 2 +- .../frank-lloyd-root/0.0.1/package.json | 2 +- .../0.0.1/src/components/FrankLloydRoot.jsx | 2 +- .../frank-lloyd-root/0.0.2/README.md | 2 +- .../frank-lloyd-root/0.0.2/package.json | 2 +- .../0.0.2/src/components/FrankLloydRoot.jsx | 2 +- src/server/middleware/sendHtml.js | 2 +- src/server/utils/onModuleLoad.js | 6 +++--- src/server/utils/safeRequest.js | 2 +- src/server/utils/stateConfig.js | 2 +- 20 files changed, 45 insertions(+), 45 deletions(-) diff --git a/__tests__/integration/one-app.spec.js b/__tests__/integration/one-app.spec.js index edb2d1760..7e6170c6a 100644 --- a/__tests__/integration/one-app.spec.js +++ b/__tests__/integration/one-app.spec.js @@ -108,7 +108,7 @@ describe('Tests that require Docker setup', () => { expect(rawHeaders).not.toHaveProperty('access-control-allow-credentials'); }); - describe('tenant without corsOrigins set', () => { + describe('root module without corsOrigins set', () => { beforeAll(async () => { await addModuleToModuleMap({ moduleName: 'frank-lloyd-root', @@ -277,7 +277,7 @@ describe('Tests that require Docker setup', () => { }); }); - describe('tenant module config', () => { + describe('root module module config', () => { test('provideStateConfig sets config', async () => { await browser.url(`${appAtTestUrls.browserUrl}/success`); const configPreTag = await browser.$('.value-provided-from-config'); @@ -318,14 +318,14 @@ describe('Tests that require Docker setup', () => { }); describe('child module config', () => { - test('validateStateConfig validates an acceptable tenant module config', async () => { + test('validateStateConfig validates an acceptable module config', async () => { await browser.url(`${appAtTestUrls.browserUrl}/demo/picky-frank`); const versionSelector = await browser.$('.version'); const version = await versionSelector.getText(); expect(version).toEqual('v0.0.0'); }); - describe('child module fails to validate tenant module config', () => { + describe('child module fails to validate the module config', () => { let failedChildModuleSearch; const failedChildModuleValidation = /Error: Failed to pass correct url on client/; @@ -518,7 +518,7 @@ describe('Tests that require Docker setup', () => { expect(JSON.parse(needyFrankModuleState)).toMatchSnapshot(); }); - describe('uses tenant provided fetch', () => { + describe('uses root module provided fetch', () => { test('should timeout on server if request exceeds one second', async () => { await browser.url(`${appAtTestUrls.browserUrl}/demo/needy-frank?api=https://slow.api.frank/posts`); const needyFrankModuleStateTag = await browser.$('.needy-frank-loaded-data'); @@ -735,8 +735,8 @@ describe('Tests that require Docker setup', () => { }); }); - describe('module requires SafeRequest Restricted Attributes not provided by tenant module', () => { - const requestRestrictedAttributesRegex = /Error: Tenant root must extendSafeRequestRestrictedAttributes with cookies: \[macadamia,homebaked\]/; + describe('module requires SafeRequest Restricted Attributes not provided by the root module', () => { + const requestRestrictedAttributesRegex = /Error: Root module must extendSafeRequestRestrictedAttributes with cookies: \[macadamia,homebaked\]/; let requestRestrictedAttributesLogSearch; beforeAll(async () => { @@ -770,7 +770,7 @@ describe('Tests that require Docker setup', () => { }); }); - test('app calls loadModuleData to run async requests using Tenant provided fetchClient', async () => { + test('app calls loadModuleData to run async requests using root module provided fetchClient', async () => { const response = await fetch(`${appAtTestUrls.fetchUrl}/demo/ssr-frank`, { ...defaultFetchOptions, }); @@ -803,7 +803,7 @@ describe('Tests that require Docker setup', () => { await expect(searchForRequerstLog).resolves.toMatch(requestLogRegex); }); - it('log gets updated when Tenancy Root module gets updated', async () => { + it('log gets updated when Root module gets updated', async () => { await addModuleToModuleMap({ moduleName: 'frank-lloyd-root', version: '0.0.2', diff --git a/__tests__/server/utils/__snapshots__/onModuleLoad.spec.jsx.snap b/__tests__/server/utils/__snapshots__/onModuleLoad.spec.jsx.snap index a6c8da4d9..4de504f22 100644 --- a/__tests__/server/utils/__snapshots__/onModuleLoad.spec.jsx.snap +++ b/__tests__/server/utils/__snapshots__/onModuleLoad.spec.jsx.snap @@ -1,15 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`onModuleLoad includes messages about all missing or incompatible externals 1`] = ` -"dep-a@^2.0.0 is required by my-awesome-module, but tenant root module provides 3.2.0 -dep-b@~5.8.0 is required by my-awesome-module, but tenant root module provides 5.9.6 -External 'dep-d' is required by my-awesome-module, but is not provided by tenant root module" +"dep-a@^2.0.0 is required by my-awesome-module, but the root module provides 3.2.0 +dep-b@~5.8.0 is required by my-awesome-module, but the root module provides 5.9.6 +External 'dep-d' is required by my-awesome-module, but is not provided by the root module" `; -exports[`onModuleLoad throws if the tenant root module does not provide the expected external 1`] = `"External 'dep-b' is required by my-awesome-module, but is not provided by tenant root module"`; +exports[`onModuleLoad throws if the root module does not provide the expected external 1`] = `"External 'dep-b' is required by my-awesome-module, but is not provided by the root module"`; -exports[`onModuleLoad throws if the tenant root module provides an incompatible version of a required external 1`] = `"dep-a@^2.1.1 is required by my-awesome-module, but tenant root module provides 2.1.0"`; +exports[`onModuleLoad throws if the root module provides an incompatible version of a required external 1`] = `"dep-a@^2.1.1 is required by my-awesome-module, but the root module provides 2.1.0"`; exports[`onModuleLoad throws when the one app version is incompatible 1`] = `"some-module@1.0.2 is not compatible with this version of one-app (4.43.0-0), it requires ~4.41.0."`; -exports[`onModuleLoad validates csp added to tenant module 1`] = `"Root module must provide a valid content security policy"`; +exports[`onModuleLoad validates csp added to the root module 1`] = `"Root module must provide a valid content security policy"`; diff --git a/__tests__/server/utils/__snapshots__/safeRequest.spec.js.snap b/__tests__/server/utils/__snapshots__/safeRequest.spec.js.snap index c81aca206..0ba0f4362 100644 --- a/__tests__/server/utils/__snapshots__/safeRequest.spec.js.snap +++ b/__tests__/server/utils/__snapshots__/safeRequest.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`safeRequest validateSafeRequestRestrictedAttributes throws error when missing in safeRequest 1`] = ` -"Tenant root must extendSafeRequestRestrictedAttributes with cookies: [jaffa-cake] -Tenant root must extendSafeRequestRestrictedAttributes with headers: [secret-id]" +"Root module must extendSafeRequestRestrictedAttributes with cookies: [jaffa-cake] +Root module must extendSafeRequestRestrictedAttributes with headers: [secret-id]" `; diff --git a/__tests__/server/utils/__snapshots__/stateConfig.spec.js.snap b/__tests__/server/utils/__snapshots__/stateConfig.spec.js.snap index 7f20749df..3ae8deb95 100644 --- a/__tests__/server/utils/__snapshots__/stateConfig.spec.js.snap +++ b/__tests__/server/utils/__snapshots__/stateConfig.spec.js.snap @@ -138,9 +138,9 @@ Object { } `; -exports[`stateConfig methods stateConfig with module config should throw if ONE_CONFIG_ENV is not set on parsing client 1`] = `"Failed to parse an object in the tenant root configuration due to missing ONE_CONFIG_ENV."`; +exports[`stateConfig methods stateConfig with module config should throw if ONE_CONFIG_ENV is not set on parsing client 1`] = `"Failed to parse an object in the root module configuration due to missing ONE_CONFIG_ENV."`; -exports[`stateConfig methods stateConfig with module config should throw if ONE_CONFIG_ENV is not set on parsing server 1`] = `"Failed to parse an object in the tenant root configuration due to missing ONE_CONFIG_ENV."`; +exports[`stateConfig methods stateConfig with module config should throw if ONE_CONFIG_ENV is not set on parsing server 1`] = `"Failed to parse an object in the root module configuration due to missing ONE_CONFIG_ENV."`; exports[`stateConfig methods stateConfig with module config should throw if client variables are supplied without server variables 1`] = ` "Root module attempted to set the following non-overrideable options for the client but not the server: diff --git a/__tests__/server/utils/batchModulesToUpdate.spec.js b/__tests__/server/utils/batchModulesToUpdate.spec.js index a57d9c52f..172f115e1 100644 --- a/__tests__/server/utils/batchModulesToUpdate.spec.js +++ b/__tests__/server/utils/batchModulesToUpdate.spec.js @@ -27,7 +27,7 @@ describe('batchModulesToUpdate', () => { const modulesWithoutRoot = [...modules]; modules.splice(20, 0, 'my-root'); - it('should put the tenant root module first', () => { + it('should put the root module first', () => { const result = batchModulesToUpdate(modules); expect(result[0]).toEqual(['my-root']); }); diff --git a/__tests__/server/utils/onModuleLoad.spec.jsx b/__tests__/server/utils/onModuleLoad.spec.jsx index 92a24ebb1..c918ae5a3 100644 --- a/__tests__/server/utils/onModuleLoad.spec.jsx +++ b/__tests__/server/utils/onModuleLoad.spec.jsx @@ -167,7 +167,7 @@ describe('onModuleLoad', () => { expect(setStateConfig).toHaveBeenCalledWith(provideStateConfig); }); - it('does not throw if the tenant root module provides the expected versions of required externals', () => { + it('does not throw if the root module provides the expected versions of required externals', () => { RootModule[CONFIGURATION_KEY] = { providedExternals: { 'dep-a': { version: '2.1.0', module: () => 0 }, @@ -185,7 +185,7 @@ describe('onModuleLoad', () => { expect(() => onModuleLoad({ module: { [CONFIGURATION_KEY]: configuration, [META_DATA_KEY]: { version: '1.0.7' } }, moduleName: 'my-awesome-module' })).not.toThrow(); }); - it('warns if a module that isn\'t the tenant root module attempts to provide externals', () => { + it('warns if a module that isn\'t the root module attempts to provide externals', () => { const configuration = { providedExternals: { 'dep-b': { @@ -199,7 +199,7 @@ describe('onModuleLoad', () => { expect(consoleWarnSpy).toHaveBeenCalledTimes(1); }); - it('throws if the tenant root module does not provide the expected external', () => { + it('throws if the root module does not provide the expected external', () => { RootModule[CONFIGURATION_KEY] = { providedExternals: { 'dep-a': { version: '2.1.0', module: () => 0 }, @@ -213,7 +213,7 @@ describe('onModuleLoad', () => { expect(() => onModuleLoad({ module: { [CONFIGURATION_KEY]: configuration, [META_DATA_KEY]: { version: '1.0.9' } }, moduleName: 'my-awesome-module' })).toThrowErrorMatchingSnapshot(); }); - it('throws if the tenant root module provides an incompatible version of a required external', () => { + it('throws if the root module provides an incompatible version of a required external', () => { RootModule[CONFIGURATION_KEY].providedExternals = { 'dep-a': { version: '2.1.0', module: () => 0 }, }; @@ -271,7 +271,7 @@ describe('onModuleLoad', () => { expect(getModulesUsingExternals()).toEqual([]); }); - it('validates csp added to tenant module', () => { + it('validates csp added to the root module', () => { const callOnModuleLoad = () => (onModuleLoad({ module: {}, moduleName: 'some-root', @@ -280,7 +280,7 @@ describe('onModuleLoad', () => { expect(callOnModuleLoad).toThrowErrorMatchingSnapshot(); }); - it('updates createSsrFetch when added on tenant module', () => { + it('updates createSsrFetch when added on the root module', () => { const fakeCreateSsrFetch = jest.fn(); onModuleLoad({ module: { @@ -296,7 +296,7 @@ describe('onModuleLoad', () => { expect(setCreateSsrFetch).toHaveBeenCalledWith(fakeCreateSsrFetch); }); - it('sets CORS origins from tenant module', () => { + it('sets CORS origins from the root module', () => { const corsOrigins = ['example.com']; onModuleLoad({ module: { @@ -329,7 +329,7 @@ describe('onModuleLoad', () => { expect(consoleInfoSpy).toHaveBeenCalledWith('Loaded module not-the-root-module@1.0.16'); }); - it('updates allowed safeRequest values from tenant root', () => { + it('updates allowed safeRequest values from the root module', () => { onModuleLoad({ module: { [CONFIGURATION_KEY]: { @@ -361,7 +361,7 @@ describe('onModuleLoad', () => { }); }); - it('sets configureRequestLog when given on tenant root', () => { + it('sets configureRequestLog when given on the root module', () => { const configureRequestLog = jest.fn(); onModuleLoad({ module: { diff --git a/__tests__/universal/routes.spec.jsx b/__tests__/universal/routes.spec.jsx index a83d916c9..9bed012f8 100644 --- a/__tests__/universal/routes.spec.jsx +++ b/__tests__/universal/routes.spec.jsx @@ -44,7 +44,7 @@ describe('routes', () => { beforeEach(() => jest.clearAllMocks()); - it('should set up the tenancy root route first', () => { + it('should set up the root module route first', () => { const RootRoute = createRoutes(store)[0]; expect(ReactTestUtils.isElement(RootRoute)).toBe(true); expect(RootRoute.props).toEqual({ moduleName: 'fakeRootModule', store }); diff --git a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/README.md b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/README.md index 4d791cd5a..364b09c7f 100644 --- a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/README.md +++ b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/README.md @@ -1,3 +1,3 @@ # frank-lloyd-root -Tenancy root module for integration tests. This specific version has a valid configuration. \ No newline at end of file +Root module for integration tests. This specific version has a valid configuration. diff --git a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/package.json b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/package.json index 29e406268..7a356b3dd 100644 --- a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/package.json +++ b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/package.json @@ -1,7 +1,7 @@ { "name": "frank-lloyd-root", "version": "0.0.0", - "description": "Tenancy root module for integration tests", + "description": "Root module for integration tests", "scripts": { "prebuild": "npm run clean", "build": "bundle-module", diff --git a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/components/FrankLloydRoot.jsx b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/components/FrankLloydRoot.jsx index d0feab549..b68d40593 100644 --- a/prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/components/FrankLloydRoot.jsx +++ b/prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/components/FrankLloydRoot.jsx @@ -31,7 +31,7 @@ export function FrankLloydRoot({ children, config }) { return ( diff --git a/src/server/utils/onModuleLoad.js b/src/server/utils/onModuleLoad.js index 484a229d0..49bc31452 100644 --- a/src/server/utils/onModuleLoad.js +++ b/src/server/utils/onModuleLoad.js @@ -66,7 +66,7 @@ export default function onModuleLoad({ }) { const { [CONFIGURATION_KEY]: { - // Tenant Root Specific + // Root Module Specific providedExternals, provideStateConfig, csp, @@ -130,9 +130,9 @@ export default function onModuleLoad({ const providedExternal = RootModule[CONFIGURATION_KEY].providedExternals[externalName]; if (!providedExternal) { - messages.push(`External '${externalName}' is required by ${moduleName}, but is not provided by tenant root module`); + messages.push(`External '${externalName}' is required by ${moduleName}, but is not provided by the root module`); } else if (!semver.satisfies(providedExternal.version, requestedExternalVersion)) { - messages.push(`${externalName}@${requestedExternalVersion} is required by ${moduleName}, but tenant root module provides ${providedExternal.version}`); + messages.push(`${externalName}@${requestedExternalVersion} is required by ${moduleName}, but the root module provides ${providedExternal.version}`); } }); diff --git a/src/server/utils/safeRequest.js b/src/server/utils/safeRequest.js index e865af51f..c03708106 100644 --- a/src/server/utils/safeRequest.js +++ b/src/server/utils/safeRequest.js @@ -114,7 +114,7 @@ export const validateSafeRequestRestrictedAttributes = (requiredAttributes, modu if (!requestItemsIncluded) { missingRequestItemsMessages.push( - `Tenant root must extendSafeRequestRestrictedAttributes with ${key}: [${requiredItems}]` + `Root module must extendSafeRequestRestrictedAttributes with ${key}: [${requiredItems}]` ); } }); diff --git a/src/server/utils/stateConfig.js b/src/server/utils/stateConfig.js index 23192ef42..3f5d4b86e 100644 --- a/src/server/utils/stateConfig.js +++ b/src/server/utils/stateConfig.js @@ -87,7 +87,7 @@ if (process.env.NODE_ENV === 'development' && fs.existsSync(pathToDevEndpoints)) let stateConfigFromModule = { server: {}, client: {} }; const configEnv = process.env.ONE_CONFIG_ENV; -const makeConfigEnvError = () => new Error('Failed to parse an object in the tenant root configuration due to missing ONE_CONFIG_ENV.'); +const makeConfigEnvError = () => new Error('Failed to parse an object in the root module configuration due to missing ONE_CONFIG_ENV.'); // Set initial config state let clientStateConfig = {