Skip to content

Commit

Permalink
Merge branch 'GPII-3053'
Browse files Browse the repository at this point in the history
* GPII-3053:
  GPII-3053: Updating dependencies.
  GPII-3053: Updated dependencies
  GPII-3053: Fixing testing up so that it works on Windows.
  GPII-3053: Updated dependencies. Linting.
  GPII-3053: Added default task
  GPII-3053: Adding captionsEnactor tests to all-tests.html
  Updated to latest gpii-testem and fixed coverage reporting.
  GPII-3053: Adding a build step to the pre-test.
  GPII-3503: tests running, but coverage reports not working properly.
  GPII-3053: Further work to combine node and browser test coverage/report
  GPII-3053: In progress work to add testem workflow.
  GPII-3053: adding nyc_output to gitignore
  GPII-3053: Using infusion-all.js for tests.
  GPII-3053: Beginning to add testem test infrastructure.
  GPII-3053: Fixed tests to work with latest sinon-chrome.
  • Loading branch information
amb26 committed Sep 16, 2018
2 parents 8315457 + 98e3bd4 commit 6aea644
Show file tree
Hide file tree
Showing 19 changed files with 235 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"env": {
"node": true
},
"extends": "eslint-config-fluid"
"env": {
"node": true
},
"extends": "eslint-config-fluid"
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
*.crx
package-lock.json
/node_modules/
/.vagrant/
report.tap
coverage
reports
instrumented
.nyc_output
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module.exports = function (grunt) {
sources: {
md: [ "./*.md"],
js: ["./tests/**/*.js", "./extension/**/*.js", "./*.js"],
json: ["./extension/**/*.json", "./*.json"],
json: ["./extension/**/*.json", "./*.json", "./.*.json"],
other: ["./.*"]
}
},
Expand Down Expand Up @@ -361,4 +361,6 @@ module.exports = function (grunt) {
grunt.config.set("uglify.options.sourceMap.includeSources", true);
grunt.task.run("build");
});

grunt.registerTask("default", ["build"]);
};
77 changes: 77 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'yaml'

ansible_vars = YAML.load_file("provisioning/vars.yml")

app_name = ansible_vars["nodejs_app_name"]

app_directory = ansible_vars["nodejs_app_install_dir"]

app_start_script = ansible_vars["nodejs_app_start_script"]

# Check for the existence of the 'VM_HOST_TCP_PORT' environment variable. If it
# doesn't exist and 'nodejs_app_tcp_port' is defined in vars.yml then use that
# port. Failing that use defaults provided in this file.
host_tcp_port = ENV["VM_HOST_TCP_PORT"] || ansible_vars["nodejs_app_tcp_port"] || 8081
guest_tcp_port = ansible_vars["nodejs_app_tcp_port"] || 8081

# By default this VM will use 2 processor cores and 2GB of RAM. The 'VM_CPUS' and
# "VM_RAM" environment variables can be used to change that behaviour.
cpus = ENV["VM_CPUS"] || 2
ram = ENV["VM_RAM"] || 2048

Vagrant.configure(2) do |config|

config.vm.box = "inclusivedesign/fedora27"

# Your working directory will be synced to /home/vagrant/sync in the VM.
config.vm.synced_folder ".", "#{app_directory}"

# Mounts node_modules in /var/tmp to work around issues in the VirtualBox shared folders
config.vm.provision "shell", run: "always", inline: <<-SHELL
sudo mkdir -p /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
sudo chown vagrant:vagrant -R /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
sudo mount -o bind /var/tmp/#{app_name}/node_modules #{app_directory}/node_modules
SHELL

# List additional directories to sync to the VM in your "Vagrantfile.local" file
# using the following format:
# config.vm.synced_folder "../path/on/your/host/os/your-project", "/home/vagrant/sync/your-project"

if File.exist? "Vagrantfile.local"
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local"
end

# Port forwarding takes place here. The 'guest' port is used inside the VM
# whereas the 'host' port is used by your host operating system.
config.vm.network "forwarded_port", guest: guest_tcp_port, host: host_tcp_port, protocol: "tcp",
auto_correct: true

config.vm.hostname = app_name

config.vm.provider :virtualbox do |vm|
vm.customize ["modifyvm", :id, "--memory", ram]
vm.customize ["modifyvm", :id, "--cpus", cpus]
vm.customize ["modifyvm", :id, "--vram", "256"]
vm.customize ["modifyvm", :id, "--accelerate3d", "off"]
vm.customize ["modifyvm", :id, "--audio", "null", "--audiocontroller", "ac97"]
vm.customize ["modifyvm", :id, "--ioapic", "on"]
vm.customize ["setextradata", "global", "GUI/SuppressMessages", "all"]
end

config.vm.provision "shell", inline: <<-SHELL
sudo dnf -y upgrade firefox google-chrome-stable
sudo ansible-galaxy install -fr /home/vagrant/sync/provisioning/requirements.yml
sudo PYTHONUNBUFFERED=1 ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook /home/vagrant/sync/provisioning/playbook.yml --tags="install,configure" --inventory="localhost ansible_connection=local,"
SHELL

# Using config.vm.hostname to set the hostname on Fedora VMs seems to remove the string
# "localhost" from the first line of /etc/hosts. This script reinserts it if it's missing.
# https://github.com/mitchellh/vagrant/pull/6203
config.vm.provision "shell",
inline: "/usr/local/bin/edit-hosts.sh",
run: "always"

end
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
As this is a browser component, this file is only meant to make it easier to refer to our code and fixtures using
the standard `%package-name/path/to/content` notation.
*/
/* eslint-env node */
"use strict";
var fluid = require("infusion");
fluid.module.register("ui-options-chrome", __dirname, require);
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,36 @@
},
"homepage": "https://github.com/GPII/gpii-chrome-extension#README.md",
"scripts": {
"test": "node tests/node/all-tests.js",
"postinstall": "grunt build"
"pretest": "node node_modules/rimraf/rimraf.js reports/* coverage/* && grunt build",
"test": "npm run test:node && npm run test:browser",
"test:node": "node node_modules/nyc/bin/nyc.js --temp-directory coverage --reporter none node tests/node/all-tests.js",
"test:browser": "node node_modules/testem/testem.js ci --file tests/browser/testem.js",
"test:vagrant": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm test'",
"test:vagrantBrowser": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm run test:browser'",
"test:vagrantNode": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm run test:node'",
"posttest": "node node_modules/nyc/bin/nyc.js report --temp-directory coverage --reporter text-summary --reporter html"
},
"dependencies": {
"infusion": "3.0.0-dev.20180801T212157Z.09bf3d438",
"ws": "6.0.0"
},
"devDependencies": {
"eslint-config-fluid": "1.3.0",
"gpii-grunt-lint-all": "1.0.2",
"gpii-grunt-lint-all": "1.0.4",
"grunt": "1.0.3",
"grunt-contrib-clean": "1.1.0",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-uglify": "3.4.0",
"grunt-contrib-uglify": "4.0.0",
"grunt-contrib-stylus": "1.2.0",
"grunt-crx": "1.0.5",
"grunt-shell": "2.1.0",
"node-jqunit": "1.1.8",
"sinon-chrome": "2.3.2",
"sinon": "6.1.4"
"sinon": "6.3.3",
"gpii-testem": "2.1.5",
"ncp": "2.0.0",
"nyc": "13.0.1",
"rimraf": "2.6.2",
"testem": "2.10.0"
}
}
1 change: 1 addition & 0 deletions provisioning/playbook.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
11 changes: 11 additions & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- hosts: localhost
user: root

vars_files:
- vars.yml

roles:
- facts
- nodejs

6 changes: 6 additions & 0 deletions provisioning/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- src: https://github.com/idi-ops/ansible-facts
name: facts

- src: https://github.com/idi-ops/ansible-nodejs
name: nodejs

21 changes: 21 additions & 0 deletions provisioning/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Please refer to https://github.com/idi-ops/ansible-nodejs/blob/master/defaults/main.yml
# for documentation related to these variables

nodejs_app_name: uioPlus

nodejs_branch: lts

nodejs_npm_version: 3.10.10

nodejs_app_npm_packages:
- testem
- istanbul

nodejs_app_commands:
- npm install
- grunt

nodejs_app_install_dir: /home/vagrant/sync

nodejs_app_git_clone: false
29 changes: 19 additions & 10 deletions tests/browser/all-tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,32 @@
<link rel="stylesheet" media="screen" href="../../node_modules/infusion/tests/lib/qunit/css/qunit.css" />
<link rel="stylesheet" href="../../node_modules/infusion/tests/lib/qunit/addons/composite/qunit-composite.css">

<script src="../../dist/ui-options-chrome-all.min.js"></script>
<script src="../../node_modules/infusion/dist/infusion-all.js"></script>
<script src="../../node_modules/infusion/tests/lib/qunit/js/qunit.js"></script>

<script src="/testem.js"></script>

<script src="../../node_modules/infusion/tests/lib/qunit/addons/composite/qunit-composite.js"></script>

The static "safe rollup" function provided by gpii-testem
<script src="../../node_modules/gpii-testem/src/js/client/safeRollup.js"></script>

<script>
// command line search:
// find . -name "*Tests.html" | awk '{print "\""$1"\","}'

QUnit.testSuites("Adaptation/Enactor Tests", [
"html/portBindingTests.html",
"html/prefsEditorTests.html",
"html/utilsTests.html",
"html/simplificationTests.html",
"html/domEnactorTests.html",
"html/zoomTests.html",
"html/captionsEnactorTests.html"
]);
gpii.testem.safeRollup(
[
"/tests/browser/html/captionsEnactorTests.html",
"/tests/browser/html/portBindingTests.html",
"/tests/browser/html/prefsEditorTests.html",
"/tests/browser/html/utilsTests.html",
"/tests/browser/html/simplificationTests.html",
"/tests/browser/html/domEnactorTests.html",
"/tests/browser/html/zoomTests.html"
],
"../.."
);
</script>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions tests/browser/html/captionsEnactorTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<script src="../../../node_modules/infusion/tests/test-core/utils/js/IoCTestUtils.js"></script>
<script src="../../../node_modules/sinon/pkg/sinon.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/captionsEnactorTests.js"></script>
</head>
Expand Down
4 changes: 4 additions & 0 deletions tests/browser/html/domEnactorTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<script src="../../../node_modules/sinon-chrome/bundle/sinon-chrome.min.js"></script>
<script src="../../../node_modules/sinon/pkg/sinon.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/portTestUtils.js"></script>
<script src="../js/domEnactorTests.js"></script>
</head>
Expand Down
4 changes: 4 additions & 0 deletions tests/browser/html/portBindingTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<script src="../../../node_modules/sinon/pkg/sinon.js"></script>
<script src="../../../extension/src/lib/portBinding.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/portTestUtils.js"></script>
<script src="../js/portBindingTestUtils.js"></script>
<script src="../js/portBindingTests.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions tests/browser/html/prefsEditorTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<script src="../../../extension/src/lib/portBinding.js"></script>
<script src="../../../extension/src/lib/PrefsEditor.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/portTestUtils.js"></script>
<script src="../js/portBindingTestUtils.js"></script>
<script src="../js/PanelTestUtils.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions tests/browser/html/simplificationTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<script src="../../../node_modules/infusion/tests/test-core/utils/js/IoCTestUtils.js"></script>
<script src="../../../node_modules/sinon-chrome/bundle/sinon-chrome.min.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/simplificationTests.js"></script>
</head>

Expand Down
5 changes: 4 additions & 1 deletion tests/browser/html/utilsTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
<script src="../../../node_modules/infusion/dist/infusion-all.js"></script>
<script src="../../../extension/src/content_scripts/utils.js"></script>

<script src="../../../node_modules/infusion/src/framework/enhancement/js/ContextAwareness.js"></script>
<script src="../../../node_modules/infusion/tests/lib/qunit/js/qunit.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit-browser.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/utils/js/IoCTestUtils.js"></script>
<script src="../../../node_modules/sinon-chrome/bundle/sinon-chrome.min.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../js/utilsTests.js"></script>
</head>

Expand Down
5 changes: 4 additions & 1 deletion tests/browser/html/zoomTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
<script src="../../../extension/src/lib/chromeEvented.js"></script>
<script src="../../../extension/src/lib/zoom.js"></script>

<script src="../../../node_modules/infusion/src/framework/enhancement/js/ContextAwareness.js"></script>
<script src="../../../node_modules/infusion/tests/lib/qunit/js/qunit.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit-browser.js"></script>
<script src="../../../node_modules/infusion/tests/test-core/utils/js/IoCTestUtils.js"></script>
<script src="../../../node_modules/sinon-chrome/bundle/sinon-chrome.min.js"></script>

<!-- Required to send coverage data at the end of the test run on this page -->
<script src="/testem.js"></script>
<script src="/coverage/client/coverageSender.js"></script>

<script src="../../shared/zoomTestDefs.js"></script>
</head>

Expand Down
33 changes: 33 additions & 0 deletions tests/browser/testem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";
var fluid = require("infusion");
fluid.setLogging(true);

fluid.require("%ui-options-chrome");
require("gpii-testem");

fluid.defaults("fluid.tests.testem", {
gradeNames: ["gpii.testem.instrumentation"],
coverageDir: "%ui-options-chrome/coverage",
reportsDir: "%ui-options-chrome/reports",
testPages: ["tests/browser/all-tests.html"],
instrumentedSourceDir: "%ui-options-chrome/instrumented",
instrumentationOptions: {
nonSources: [
"./**/*.!(js)",
"./Gruntfile.js"
]
},
sourceDirs: {
extension: "%ui-options-chrome/extension"
},
contentDirs: {
tests: "%ui-options-chrome/tests"
},
testemOptions: {
skip: "PhantomJS,Opera,Safari,Firefox,IE",
disable_watching: true,
tap_quiet_logs: true
}
});

module.exports = fluid.tests.testem().getTestemOptions();

0 comments on commit 6aea644

Please sign in to comment.