Skip to content

Commit

Permalink
Merge pull request spekt8#4 from spekt8/testing
Browse files Browse the repository at this point in the history
testing completed using jest and supertest on the back-end
  • Loading branch information
elliotxkim authored Nov 17, 2018
2 parents e2b0fc5 + 555e716 commit c530511
Show file tree
Hide file tree
Showing 21 changed files with 843 additions and 108 deletions.
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
16 changes: 16 additions & 0 deletions cypress/integration/spekt8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

// describe('spekt8', () => {


// it('visits the site',()=>{
// cy.visit('http://localhost:3000');
// })


// it('clicks a filter', ()=>{
// cy.get(':nth-child(2) > .jss154 > .jss155 > .jss67 > .jss66 > .jss167').click()
// })


// })

17 changes: 17 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Binary file added images/k8slogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production",
"test": "jest --verbose --coverage --coverageReporters=text-summary",
"cypress": "cypress open"
"server": "nodemon src/server/server.js"
},
"author": "",
Expand All @@ -31,22 +33,51 @@
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"redux": "^4.0.1",
"sinon": "^7.1.1",
"url-loader": "^1.1.2"
},
"jest": {
"transform": {
".*": "<rootDir>/node_modules/babel-jest"
},
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/react-dom",
"<rootDir>/node_modules/react-addons-test-utils",
"<rootDir>/node_modules/fbjs",
"node_modules/react/",
"node_modules/enzyme/"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"chai": "^4.2.0",
"css-loader": "^1.0.0",
"cypress": "^3.1.1",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.7.0",
"enzyme-to-json": "^3.3.4",
"html-webpack-plugin": "^3.2.0",
"jest": "^23.6.0",
"jest-cli": "^23.6.0",
"jest-enzyme": "^7.0.1",
"node-sass": "^4.9.4",
"nodemon": "^1.18.5",
"react-addons-test-utils": "^15.6.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"superagent": "^4.0.0-beta.5",
"supertest": "^3.3.0",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
Expand Down
11 changes: 8 additions & 3 deletions src/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class App extends React.Component {
[classes[`appBarShift-${anchor}`]]: open,
})}
>


<Toolbar disableGutters={!open}>
<IconButton
Expand All @@ -313,6 +314,7 @@ class App extends React.Component {
alignItems="center"
color="primary"
>

<Typography variant="h6" color="inherit" noWrap>
SPEKT8
</Typography>
Expand Down Expand Up @@ -368,9 +370,12 @@ class App extends React.Component {
{/* end header section */}

{/* right side should go over here */}
<div className="rightSide">
{viewStyle}
{type}
<div className="rightSide" >
<div id='k8sContainer'>
<div id='k8simage'></div>
{viewStyle}
{type}
</div>
</div>
{/* end right side */}
</main>
Expand Down
19 changes: 10 additions & 9 deletions src/client/components/leftPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ import Typography from '@material-ui/core/Typography';
const LeftPanel = (props) => {
return (
<Drawer
variant="persistent"
anchor={props.anchor}
open={props.open}
classes={{
paper: props.classes.drawerPaper,
}}
>

variant="persistent"
anchor={props.anchor}
open={props.open}
classes={{
paper: props.classes.drawerPaper,
}}
>
<div className='leftheader'>
<div className={props.classes.drawerHeader}>
<Typography variant="h6">K8s Visualization</Typography>
<Typography id="paneltitle" variant="h6" >SPEKT8</Typography>

<IconButton onClick={props.handleDrawerClose}>
{props.theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</IconButton>
</div>
</div>

{/* this is where you write for the inside of the drawer */}
{/* Legend */}
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Legend extends React.Component {
<div className={classes.root}>
<List>
{/* Title */}
<Typography variant="h6" className={classes.typo}>Legend</Typography>
<Typography id="legendtitle" variant="h6" className={classes.typo}>Legend</Typography>

{/* 1st Item */}
<ListItem>
Expand Down
51 changes: 43 additions & 8 deletions src/client/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ body {
border-bottom: 1px solid black;
}

// -------------------------------------------
// DRAWER ITEMS
.leftheader {
background-color: rgb(2, 3, 59);
}

#paneltitle {
color: white;
position: center;

}

.viewMenu {
margin-right: 10%;
}
Expand All @@ -65,16 +77,39 @@ body {
overflow-y: scroll;
}


.tableRight {
margin-bottom: 10%;
}

.monitoring {
height: 25%;
padding: 0 15px;
}
.monitoring {
height: 25%;
padding: 0 15px;
}

.directions {
padding: 0 25px;
text-align: center;
}

.rightSide {
height: 100%;

}

#k8sContainer {
position: relative;
height: 872px;
}
#k8sContainer #k8simage {
width: 1033px;
height: 872px; /* or whatever, equal to the image you want 'watermarked' */
// width: 400px; /* as above */
background-image: url(../../../images/k8slogo.png);
opacity: 0.1;
position: absolute;
background-position: center;
background-repeat: no-repeat;
background-position: relative;
}

.directions {
padding: 0 25px;
text-align: center;
}
5 changes: 2 additions & 3 deletions src/client/supplement/fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const fetchData = (nodes, edges, graph, that) => {
const p1 = fetch('http://localhost:3000/pod');
const p2 = fetch('http://localhost:3000/service');
Expand Down Expand Up @@ -88,7 +87,6 @@ const fetchData = (nodes, edges, graph, that) => {
podArray.push(newPodObject);
}


/* INGRESS */
// this loops through the ingress object and saves to another array
for (let i = 0; i < ingressObject.items.length; i+=1) {
Expand All @@ -115,7 +113,6 @@ const fetchData = (nodes, edges, graph, that) => {
ingressArray.push(newIngressObject);
}


/* DAEMONSET */
// for (let i = 0; i < daemonsetObject.items.length; i += 1) {
// const newDaemonSetObject = {};
Expand Down Expand Up @@ -164,6 +161,7 @@ const fetchData = (nodes, edges, graph, that) => {

/* INGRESS - SERVICE CONNECTIONS */
// this checks whether the service is listed in an ingress object

if (ingressArray[0]) {
for (let j = 0; j < ingressArray[0].services.length; j+=1) {
for (let k = 0; k < serviceArray.length; k+=1) {
Expand Down Expand Up @@ -194,3 +192,4 @@ const fetchData = (nodes, edges, graph, that) => {
}

export default fetchData;

Loading

0 comments on commit c530511

Please sign in to comment.