Skip to content

Commit

Permalink
Fixed e2e test runs after the default socket connection was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-millward-tessella committed Jun 18, 2018
1 parent 2e0b4dd commit 3b3a377
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 29 deletions.
68 changes: 49 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,52 @@ cache:
install:
- npm install -g codecov
- npm install
script:
- npm run lint:css
- npm run lint:js
- npm run build
- npm run test
- codecov
- npm run e2e
before_deploy:
- npm run config:prod
- chmod +x $TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh
- "$TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh $TRAVIS_BUILD_DIR"
deploy:
provider: releases
api_key:
secure: ltKb5HFDyBSWpfzCddFnv69f4ERGyGFLYWwVKzqwEEFOsZtYDL2BHHAROGLuskidW6mRplZbT658LaIWJ8j6ssIpWmSFyUBHZ6EfsjtiVB1HkkZxeo37Z5RlqJnvSHOYnZHzP9lymKR+TiCmVwaINp6P1k8Mp/Gz3kpAhMxwn5optNPiN/hh7FYlo/bZpHRgDAtILCHcW8//Q9UpXvJH9lcYR8aX6wUjcPklO8CgN9Hhhb5eBFZa97UfJq9k5VcRMiQtLUGlf0xk5puMEV3YVb79eoWqIMnMOS4xbpXyo8jhWWi3EYKBHIR86rw8CnyT0FbKQj+QT6FnaqaNUf3otXyAlNZ917TnTH2bL8ETXG6E90XA2zCz/tJ0+nEEXZGxwSO3j1o3as/trvD6pz+vdT8PBKmyraHEwMOFbBgU5rWAbj5QVcDnMS8Pndc/c1d8lNQTa0mQ+t91N0nNn52rZpqULVJ2kBW9jnbWmrYdpzENg/oIoG3iDWnBisFbQOnPJMD0giNwg3Mjw4/QAkGL8mXUCh1B9O8PYG3Y9wwVtr3rn/IjLTAzHJadx5nPwI4M1AfX2287EO1Hjykwg3U0WjVV25ka+klVmNxCasMr34EfGlEqaVKesQO8T+dpSlaCsoAznRhFnTF2PVUChucUfJM8FCtDCM2F6cL8VTutHYA=
file: "${TRAVIS_BUILD_DIR}/artifacts/*"
on:
all_branches: true
tags: true
jobs:
include:
- stage: Linting
script: npm run lint:css
- stage: Linting
script: npm run lint:js
- stage: Build and Test
script: npm run build
- stage: Build and Test
script:
- npm run test
- codecov
- stage: Build and Test
script:
- npm run e2e
- stage: Deploy
script:
-npm run build
before_deploy:
- chmod +x $TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh
- "$TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh $TRAVIS_BUILD_DIR"
deploy:
provider: releases
api_key:
secure: ltKb5HFDyBSWpfzCddFnv69f4ERGyGFLYWwVKzqwEEFOsZtYDL2BHHAROGLuskidW6mRplZbT658LaIWJ8j6ssIpWmSFyUBHZ6EfsjtiVB1HkkZxeo37Z5RlqJnvSHOYnZHzP9lymKR+TiCmVwaINp6P1k8Mp/Gz3kpAhMxwn5optNPiN/hh7FYlo/bZpHRgDAtILCHcW8//Q9UpXvJH9lcYR8aX6wUjcPklO8CgN9Hhhb5eBFZa97UfJq9k5VcRMiQtLUGlf0xk5puMEV3YVb79eoWqIMnMOS4xbpXyo8jhWWi3EYKBHIR86rw8CnyT0FbKQj+QT6FnaqaNUf3otXyAlNZ917TnTH2bL8ETXG6E90XA2zCz/tJ0+nEEXZGxwSO3j1o3as/trvD6pz+vdT8PBKmyraHEwMOFbBgU5rWAbj5QVcDnMS8Pndc/c1d8lNQTa0mQ+t91N0nNn52rZpqULVJ2kBW9jnbWmrYdpzENg/oIoG3iDWnBisFbQOnPJMD0giNwg3Mjw4/QAkGL8mXUCh1B9O8PYG3Y9wwVtr3rn/IjLTAzHJadx5nPwI4M1AfX2287EO1Hjykwg3U0WjVV25ka+klVmNxCasMr34EfGlEqaVKesQO8T+dpSlaCsoAznRhFnTF2PVUChucUfJM8FCtDCM2F6cL8VTutHYA=
file: "${TRAVIS_BUILD_DIR}/artifacts/*"
on:
all_branches: true
tags: true

# script:
# - npm run lint:css
# - npm run lint:js
# - npm run build
# - npm run test
# - codecov
# - npm run e2e
# - npm run build
# before_deploy:
# - chmod +x $TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh
# - "$TRAVIS_BUILD_DIR/continuous_integration/package_artifacts.sh $TRAVIS_BUILD_DIR"
# deploy:
# provider: releases
# api_key:
# secure: ltKb5HFDyBSWpfzCddFnv69f4ERGyGFLYWwVKzqwEEFOsZtYDL2BHHAROGLuskidW6mRplZbT658LaIWJ8j6ssIpWmSFyUBHZ6EfsjtiVB1HkkZxeo37Z5RlqJnvSHOYnZHzP9lymKR+TiCmVwaINp6P1k8Mp/Gz3kpAhMxwn5optNPiN/hh7FYlo/bZpHRgDAtILCHcW8//Q9UpXvJH9lcYR8aX6wUjcPklO8CgN9Hhhb5eBFZa97UfJq9k5VcRMiQtLUGlf0xk5puMEV3YVb79eoWqIMnMOS4xbpXyo8jhWWi3EYKBHIR86rw8CnyT0FbKQj+QT6FnaqaNUf3otXyAlNZ917TnTH2bL8ETXG6E90XA2zCz/tJ0+nEEXZGxwSO3j1o3as/trvD6pz+vdT8PBKmyraHEwMOFbBgU5rWAbj5QVcDnMS8Pndc/c1d8lNQTa0mQ+t91N0nNn52rZpqULVJ2kBW9jnbWmrYdpzENg/oIoG3iDWnBisFbQOnPJMD0giNwg3Mjw4/QAkGL8mXUCh1B9O8PYG3Y9wwVtr3rn/IjLTAzHJadx5nPwI4M1AfX2287EO1Hjykwg3U0WjVV25ka+klVmNxCasMr34EfGlEqaVKesQO8T+dpSlaCsoAznRhFnTF2PVUChucUfJM8FCtDCM2F6cL8VTutHYA=
# file: "${TRAVIS_BUILD_DIR}/artifacts/*"
# on:
# all_branches: true
# tags: true
4 changes: 2 additions & 2 deletions cypress/integration/malcolmjs_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('MalcolmJS', () => {
it('.should() - load correctly', () => {
cy.visit('/gui/?block=PANDA:TTLIN1');
cy.title().should('equal', 'MalcolmJS');
cy.visit('/gui/');
cy.title().should('equal', 'MalcolmJS 1.0.0');
});
});
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
"server": "node ./server/test-malcolm-server.js",
"server:dev": "nodemon ./server/test-malcolm-server.js",
"start": "npm run config:dev & concurrently \"npm run server:dev\" \"react-scripts start\"",
"build": "npm run config:dev & react-scripts build",
"build:prod": "npm run build & npm run config:prod",
"build:e2e": "npm run config:dev & cross-env REACT_APP_E2E=true react-scripts build",
"build": "react-scripts build & npm run config:prod",
"test": "react-scripts test --env=jsdom --coverage",
"test:watch": "react-scripts test --env=jsdom --watch",
"eject": "react-scripts eject",
"cy:open": "cypress open",
"cy:run": "cypress run",
"e2e:serve": "npm run build & node ./server/e2e-test-server.js",
"e2e:serve": "npm run build:e2e & node ./server/e2e-test-server.js",
"e2e:interactive": "start-server-and-test e2e:serve http://localhost:3030 cy:open",
"e2e": "start-server-and-test e2e:serve http://localhost:3030 cy:run",
"lint:js": "eslint --ext=js --ext=jsx --fix ./src",
Expand All @@ -86,6 +86,7 @@
"babel-core": "^6.26.0",
"concurrently": "^3.5.1",
"coveralls": "^3.0.0",
"cross-env": "^5.2.0",
"cypress": "^2.1.0",
"enzyme-to-json": "^3.3.3",
"eslint-config-airbnb": "^16.1.0",
Expand Down
6 changes: 6 additions & 0 deletions server/e2e-test-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ var app = express()

app.use(serveStatic(path.resolve('./build'), {'index': ['index.html', 'index.htm']}))



app.get('/settings.json', function (req, res) {
res.sendFile(path.resolve('./build/settings.json'));
});

app.get('/*', function (req, res) {
res.sendFile(path.resolve('./build/index.html'));
});
Expand Down
5 changes: 2 additions & 3 deletions server/test-malcolm-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ let pathIndexedMessages = dataLoader.loadDatabyPath('./server/canned_data/');
let subscriptions = [];
let subscribedPaths = {};

const io = new WebSocket.Server({port: 8000});
const port = 8000
const io = new WebSocket.Server({port});

io.on('connection', function (socket) {
socket.on('message', message => {
Expand All @@ -32,8 +33,6 @@ io.on('connection', function (socket) {
});



const port = 8000;
console.log('listening on port ', port);

function handleMessage(socket, message) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ const store = createStore(
);

configureMalcolmSocketHandlers(socketContainer, store);

if (process.env.NODE_ENV !== 'development') {
if (process.env.NODE_ENV === 'production' && !process.env.REACT_APP_E2E) {
// if production connect directly to ws://{{host}}/ws
store.dispatch(
registerSocketAndConnect(socketContainer, `ws://${window.location.host}/ws`)
);
}

store.dispatch(configureSocket(socketContainer));

const theme = createMuiTheme({
Expand Down

0 comments on commit 3b3a377

Please sign in to comment.