Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
feat(one-app): removed tenancy or tenant instances (#69)
Browse files Browse the repository at this point in the history
* 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 <james.singleton1@aexp.com>
Co-authored-by: Nelly Kiboi <nelly.j.kiboi@aexp.com>
Co-authored-by: Jonny Adshead <JAdshead@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 29, 2020
1 parent bbbefaf commit 1b6a5e5
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 45 deletions.
18 changes: 9 additions & 9 deletions __tests__/integration/one-app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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/;

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions __tests__/server/utils/__snapshots__/onModuleLoad.spec.jsx.snap
Original file line number Diff line number Diff line change
@@ -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"`;
4 changes: 2 additions & 2 deletions __tests__/server/utils/__snapshots__/safeRequest.spec.js.snap
Original file line number Diff line number Diff line change
@@ -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]"
`;
4 changes: 2 additions & 2 deletions __tests__/server/utils/__snapshots__/stateConfig.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion __tests__/server/utils/batchModulesToUpdate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
Expand Down
18 changes: 9 additions & 9 deletions __tests__/server/utils/onModuleLoad.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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': {
Expand All @@ -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 },
Expand All @@ -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 },
};
Expand Down Expand Up @@ -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',
Expand All @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/universal/routes.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frank-lloyd-root

Tenancy root module for integration tests. This specific version has a valid configuration.
Root module for integration tests. This specific version has a valid configuration.
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function FrankLloydRoot({ children, config }) {
return (
<React.Fragment>
<Helmet
title="Sample Tenancy"
title="Sample Root Module"
link={[
{ rel: 'icon', href: 'https://sample-cdn.frank/favicon.ico' },
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frank-lloyd-root

Tenancy root module for integration tests. This specific version has an invalid configuration.
Root module for integration tests. This specific version has an invalid configuration.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frank-lloyd-root",
"version": "0.0.1",
"description": "Tenancy root module for integration tests",
"description": "Root module for integration tests",
"scripts": {
"prebuild": "npm run clean",
"build": "bundle-module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function FrankLloydRoot({ children, config }) {
return (
<React.Fragment>
<Helmet
title="Sample Tenancy"
title="Sample Root Module"
link={[
{ rel: 'icon', href: 'https://sample-cdn.frank/favicon.ico' },
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frank-lloyd-root

Tenancy root module for integration tests. This specific version has a alternate valid configuration.
Root module for integration tests. This specific version has a alternate valid configuration.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frank-lloyd-root",
"version": "0.0.2",
"description": "Tenancy root module for integration tests",
"description": "Root module for integration tests",
"scripts": {
"prebuild": "npm run clean",
"build": "bundle-module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function FrankLloydRoot({ children, config }) {
return (
<React.Fragment>
<Helmet
title="Sample Tenancy"
title="Sample Root Module"
link={[
{ rel: 'icon', href: 'https://sample-cdn.frank/favicon.ico' },
]}
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/sendHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function renderStaticErrorPage(res) {
message = 'Sorry, we are unable to load this page at this time.';
}

// TODO: allow tenant to provide custom error message and override default html
// TODO: allow root module to provide custom error message and override default html
safeSend(res,
`<!DOCTYPE html>
<html>
Expand Down
6 changes: 3 additions & 3 deletions src/server/utils/onModuleLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function onModuleLoad({
}) {
const {
[CONFIGURATION_KEY]: {
// Tenant Root Specific
// Root Module Specific
providedExternals,
provideStateConfig,
csp,
Expand Down Expand Up @@ -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}`);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/server/utils/safeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}]`
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/server/utils/stateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 1b6a5e5

Please sign in to comment.