This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display Configuration Name and Instance Type on Workspace detai…
…ls card (#669) feat: display Configuration Name and Instance Type on Workspace details card and when selecting configuration to create a new workspace
- Loading branch information
1 parent
2c5bb1a
commit f0fa819
Showing
10 changed files
with
282 additions
and
4 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
95 changes: 95 additions & 0 deletions
95
...as-ui/packages/base-raas-ui/src/parts/environments-sc/__tests__/ScEnvironmentCard.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,95 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
// Mock buttons to avoid error | ||
jest.mock('../parts/ScEnvironmentButtons', () => ({ | ||
__ScEnvironmentButtons: true, | ||
})); | ||
// eslint-disable-next-line import/first | ||
import {} from '../parts/ScEnvironmentButtons'; | ||
|
||
// const ScEnvironmentCard = require('../ScEnvironmentCard'); | ||
// eslint-disable-next-line import/first | ||
import ScEnvironmentCard from '../ScEnvironmentCard'; | ||
|
||
jest.mock('@aws-ee/base-ui/dist/helpers/notification'); | ||
const displayErrorMock = require('@aws-ee/base-ui/dist/helpers/notification'); | ||
|
||
const scEnvironment = { | ||
id: 'id', | ||
rev: 2, | ||
status: 'active', | ||
description: 'sample description', | ||
envTypeConfigId: 'env type config id', | ||
name: 'name', | ||
projectId: 'project id', | ||
envTypeId: 'env type id', | ||
createdAt: '01-01-1900', | ||
createdBy: 'anonymous', | ||
updatedAt: '01-02-1900', | ||
updatedBy: 'anonymous', | ||
error: 'error', | ||
connections: [], | ||
hasConnections: false, | ||
studyIds: [], | ||
cidr: [], | ||
outputs: [], | ||
}; | ||
|
||
const envTypesStore = { | ||
getEnvTypeConfigsStore: jest.fn(() => envTypesStore), | ||
load: jest.fn(), | ||
getEnvTypeConfig: jest.fn(), | ||
}; | ||
|
||
describe('ScEnvironmentCard', () => { | ||
let component = null; | ||
let wrapper = null; | ||
beforeEach(() => { | ||
// render component | ||
wrapper = shallow( | ||
<ScEnvironmentCard.WrappedComponent scEnvironment={scEnvironment} envTypesStore={envTypesStore} />, | ||
); | ||
|
||
// get instance of component | ||
component = wrapper.instance(); | ||
|
||
// mock error function because it doesn't function properly in enzyme | ||
displayErrorMock.displayError = jest.fn(x => x); | ||
}); | ||
|
||
it('should get env type configs store', async () => { | ||
// BUILD, OPERATE | ||
component.getEnvTypeConfigsStore(); | ||
|
||
// CHECK | ||
expect(envTypesStore.getEnvTypeConfigsStore).toHaveBeenCalledWith(scEnvironment.envTypeId); | ||
}); | ||
|
||
it('should get configuration', async () => { | ||
// BUILD | ||
const spyOnConfigsStore = jest.spyOn(component, 'getEnvTypeConfigsStore'); | ||
|
||
// OPERATE | ||
component.getConfiguration(scEnvironment.envTypeConfigId); | ||
|
||
// CHECK | ||
expect(spyOnConfigsStore).toHaveBeenCalled(); | ||
expect(envTypesStore.getEnvTypeConfig).toHaveBeenCalledWith(scEnvironment.envTypeConfigId); | ||
}); | ||
}); |
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
74 changes: 74 additions & 0 deletions
74
...ges/environment-type-mgmt-ui/src/models/environment-types/__tests__/EnvTypeConfig.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,74 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
// require('../EnvTypeConfig'); | ||
import EnvTypeConfig from '../EnvTypeConfig'; | ||
|
||
describe('EnvTypeConfig', () => { | ||
it('should get the instance type', async () => { | ||
// BUILD | ||
const config = { | ||
id: 'envtypeconfigid', | ||
name: 'Name', | ||
desc: 'some desc', | ||
estimatedCostInfo: 'money', | ||
params: [{ key: 'InstanceType', value: 't3.large' }], | ||
}; | ||
const envTypeConfig = EnvTypeConfig.create(config); // Initialize the whole object | ||
|
||
// OPERATE | ||
const instanceType = envTypeConfig.instanceType; | ||
|
||
// CHECK | ||
expect(instanceType).not.toBe('Not available'); | ||
expect(instanceType).toBe('t3.large'); | ||
}); | ||
|
||
it('should get master instance type from config params for EMR', async () => { | ||
// BUILD | ||
const config = { | ||
id: 'envtypeconfigid', | ||
name: 'Name', | ||
desc: 'some desc', | ||
estimatedCostInfo: 'money', | ||
params: [{ key: 'MasterInstanceType', value: 't3.large' }], | ||
}; | ||
const envTypeConfig = EnvTypeConfig.create(config); // Initialize the whole object | ||
|
||
// OPERATE | ||
const instanceType = envTypeConfig.instanceType; | ||
|
||
// CHECK | ||
expect(instanceType).not.toBe('Not available'); | ||
expect(instanceType).toBe('t3.large'); | ||
}); | ||
|
||
it('should display something graceful when no InstanceType param in config params', async () => { | ||
// BUILD | ||
const config = { | ||
id: 'envtypeconfigid', | ||
name: 'Name', | ||
desc: 'some desc', | ||
estimatedCostInfo: 'money', | ||
params: [{ key: 'name', value: 'name' }], | ||
}; | ||
const envTypeConfig = EnvTypeConfig.create(config); // Initialize the whole object | ||
|
||
// OPERATE | ||
const instanceType = envTypeConfig.instanceType; | ||
|
||
// CHECK | ||
expect(instanceType).toBe('Not available'); | ||
}); | ||
}); |
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
Oops, something went wrong.