-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added functional and unit tests #37
Changes from 23 commits
5c72f0e
77b1d2a
a58cba5
392ff57
1f8a4f3
25a735b
3073826
1acf4cf
152993e
7cb2898
22df9b0
0809c69
f46bc16
4ce400e
d40f64c
569bf40
d53fb1c
0decd18
8663c07
c355979
8c6e0b7
a24bc29
972fca3
073ea03
daf6a3e
1f76faf
83a817f
e0cb66b
3e17741
8a2803c
8826405
8e91a90
835c72b
6881665
4eb6d42
2bb18db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "node" | ||
|
||
services: | ||
- docker | ||
|
||
# so the functional tests will work | ||
addons: | ||
apt: | ||
packages: | ||
- xvfb | ||
install: | ||
- export DISPLAY=':99.0' | ||
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
|
||
before_script: | ||
- cd $TRAVIS_BUILD_DIR | ||
|
||
script: | ||
- ./runtests.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Versions | ||
-------- | ||
These docker images are build with Ubuntu 18.04 (bionic) and Debian 9 (stretch). They use the following repositories to install saltstack: | ||
- https://repo.saltstack.com/apt/debian/9/amd64/latest | ||
- http://repo.saltstack.com/py3/ubuntu/18.04/amd64/latest | ||
|
||
Version of all salt packages installed: *2018.3.2+ds-1* | ||
|
||
Docker images | ||
------------- | ||
Commands used to build these docker images:: | ||
|
||
docker build -f dockerfiles/dockerfile-saltmaster -t maerteijn/saltgui-saltmaster . | ||
docker build -f dockerfiles/dockerfile-saltminion-debian -t maerteijn/saltgui-saltminion-debian . | ||
docker build -f dockerfiles/dockerfile-saltminion-ubuntu -t maerteijn/saltgui-saltminion-ubuntu . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
FROM ubuntu | ||
FROM ubuntu:18.04 | ||
MAINTAINER Martijn Jacobs <martijn@devopsconsulting.nl> | ||
|
||
ENV REFRESHED_ON "7 Mar 2018" | ||
ENV REFRESHED_ON "24 Jul 2018" | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# some handy stuff to have and install gnupg2 | ||
RUN apt-get update && apt-get install curl --yes && apt-get install iproute2 --yes && apt-get install gnupg2 --yes | ||
|
||
# add saltstack key | ||
RUN curl --fail --silent --show-error --location https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - | ||
RUN echo 'deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main' > /etc/apt/sources.list.d/saltstack.list | ||
# add saltstack key and install dependencies | ||
RUN apt-get update && apt-get install curl gnupg2 net-tools --yes | ||
RUN curl --fail --silent --show-error --location https://repo.saltstack.com/py3/ubuntu/18.04/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - | ||
RUN echo 'deb http://repo.saltstack.com/py3/ubuntu/18.04/amd64/latest bionic main' > /etc/apt/sources.list.d/saltstack.list | ||
|
||
# install salt-minion | ||
RUN apt-get update && apt-get install salt-minion --yes | ||
|
||
# copy the minion configuration | ||
ADD ./conf/minion /etc/salt/minion | ||
|
||
# show which versions are installed | ||
RUN dpkg -l | grep salt\- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
{ | ||
"name": "saltgui-linter", | ||
"description": "Simple check for JSHint (Code Linting)", | ||
"name": "saltgui-test", | ||
"description": "Code linting and testing package for SaltGUI", | ||
"author": "Martijn Jacobs", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"jshint": "^2.9.5" | ||
"chai": "^4.1.2", | ||
"jshint": "^2.9.5", | ||
"mocha": "^5.2.0", | ||
"nightmare": "^3.0.1", | ||
"wait-on": "^2.1.0" | ||
}, | ||
"jshintConfig": { | ||
"esversion": 6 | ||
}, | ||
"scripts": { | ||
"test": "jshint saltgui/" | ||
"lint": "jshint saltgui/ tests/", | ||
"wait-for-docker": "node tests/helpers/wait-for-docker.js", | ||
"test": "mocha --bail --trace-warnings --reporter spec tests/unit/ tests/functional/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, maybe not 😄 I removed it |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# always cleanup the docker images when something goes wrong | ||
function cleanupdocker { | ||
docker-compose -f docker/docker-compose.yml rm -f -s | ||
} | ||
trap cleanupdocker EXIT | ||
|
||
set -e | ||
# add testing packages | ||
yarn | ||
|
||
# first see if we write es6 compatible js | ||
yarn lint | ||
|
||
# start a salt master, two salt minions and saltgui to run tests on | ||
docker-compose -f docker/docker-compose.yml up -d | ||
|
||
# wait until all are up | ||
yarn wait-for-docker | ||
|
||
# run the unittests/nightmare.js functional tests | ||
yarn test | ||
|
||
set +e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline at the end of this file 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's bash, not javascript 😳 but I've added the newline. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
window.elapsedToString = function(date) { | ||
var secondsPassed = (new Date().getTime() / 1000) - (date.getTime() / 1000); | ||
if(secondsPassed < 20) return "A few moments ago"; | ||
if(secondsPassed < 120) return "A few minutes ago"; | ||
try { | ||
var secondsPassed = (new Date().getTime() / 1000) - (date.getTime() / 1000); | ||
|
||
if(secondsPassed < 60 * 60) { | ||
var minutes = Math.round(secondsPassed / 60); | ||
return minutes + " minutes ago"; | ||
} | ||
if(secondsPassed < 0) return "Magic happened in the future"; | ||
if(secondsPassed < 20) return "A few moments ago"; | ||
if(secondsPassed < 120) return "A few minutes ago"; | ||
|
||
if(secondsPassed < 60 * 60 * 24) { | ||
var hours = Math.round(secondsPassed / 60 / 60); | ||
return hours + " hours ago"; | ||
} | ||
if(secondsPassed < 60 * 60) { | ||
var minutes = Math.round(secondsPassed / 60); | ||
return minutes + " minutes ago"; | ||
} | ||
|
||
if(secondsPassed < 60 * 60 * 24 * 2) { | ||
return "Yesterday"; | ||
} | ||
if(secondsPassed < 60 * 60 * 24) { | ||
var hours = Math.round(secondsPassed / 60 / 60); | ||
return hours + " hours ago"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we end up with "one hours" here? |
||
} | ||
|
||
if(secondsPassed < 60 * 60 * 24 * 30) { | ||
var days = Math.round(secondsPassed / 60 / 60 / 24); | ||
return days + " days ago"; | ||
} | ||
if(secondsPassed < 60 * 60 * 24 * 2) { | ||
return "Yesterday"; | ||
} | ||
|
||
return "A long time ago, in a galaxy far, far away"; | ||
if(secondsPassed < 60 * 60 * 24 * 30) { | ||
var days = Math.round(secondsPassed / 60 / 60 / 24); | ||
return days + " days ago"; | ||
} | ||
|
||
return "A long time ago, in a galaxy far, far away"; | ||
} | ||
catch(err) { | ||
return "It did happen, when I don't know"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably log this error the console? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I added it. |
||
} | ||
}; | ||
|
||
window.createElement = function(type, className, content) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that would be "8.11 or above" and "1.7 or above"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, small typo