Skip to content

Commit

Permalink
Staging (#234)
Browse files Browse the repository at this point in the history
* automated testing

* chrome headless

* remove test output

* fix navigation on refresh

* finish about us content

* Delete tests_output/nightwatch-html-report directory

Signed-off-by: usiiasirrush <[email protected]>

* Update docker-image.yml

Signed-off-by: usiiasirrush <[email protected]>

* use reporter

---------

Signed-off-by: usiiasirrush <[email protected]>
Co-authored-by: Usi Diamond <[email protected]>
  • Loading branch information
UsiDiamond and UsiDiamond authored Jul 13, 2023
1 parent e8e38e4 commit 518d761
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .env

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Docker Image CI

on:
push:
branches: ["development"]
pull_request:
branches: ["development"]
branches: ["staging"]

jobs:
build:
Expand All @@ -21,4 +19,5 @@ jobs:
npm install
npm run-script build
docker build -f Dockerfile -t neurodiversity-main .
docker run --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --workdir=/ -p 8080:8080 --runtime=runc -d neurodiversity-main:latest
npm e2e
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/tmp
/out-tsc
/bazel-out
/tests_output
/integration-testing/tests_output
.env

# Node
/node_modules
Expand Down
File renamed without changes.
149 changes: 149 additions & 0 deletions integration-testing/html-reporter.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<!DOCTYPE html>
<html>
<head>
<title>Test Results - {{browser}}</title>

<style>
html, body {
font-family: Arial,sans-serif;
margin: 0;
padding: 0;
}
body { padding: 10px 40px; }
table { width: 100%; margin-bottom: 20px; }
td {
padding: 7px;
border-top: none;
border-left: 1px black solid;
border-bottom: 1px black solid;
border-right: none;
}
td.pass { color: #003b07; background: #86e191; }
td.skip { color: #7d3a00; background: #ffd24a; }
td.fail { color: #5e0e00; background: #ff9c8a; }
tr:last-child { border-top: 1px black solid; }
tr:last-child td { border-top: 1px black solid; }
tr:first-child td { border-top: 1px black solid; }
td:last-child { border-right: 1px black solid; }
tr.overview td { padding-bottom: 0px; border-bottom: none; }
tr.overview.last td { padding-bottom: 3px; }
ul.assertions { list-style-type: none; }
span.error { color: #AD2B2B; }
span.success { color: #53891E; }
.stacktrace { display: inline; }
.stacktrace code { display: none; }
#nightwatch-logo {
position: absolute;
top: 20px;
right: 33px;
width: 70px;
height: 75px;
background: transparent url('http://nightwatchjs.org/img/logo-nightwatch.png') no-repeat;
background-size: 70px 75px;
}
</style>
</head>

<body>
<h1>Test Results</h1>

<table border="0" cellpadding="0" cellspacing="0">
<tr class="overview">
<td colspan="3" title="{{browser}}"><strong>Browser:</strong> {{browser}}</td>
</tr>
<tr class="overview">
<td colspan="3"><strong>Timestamp:</strong> {{timestamp}}</td>
</tr>
<tr class="overview last">
<td colspan="3"><strong>Tests:</strong> {{results.tests}}<br></td>
</tr>
<tr>
<td class="pass"><strong>{{results.passed}}</strong> passed</td>
<td class="skip"><strong>{{results.errors}}</strong> errors</td>
<td class="fail"><strong>{{results.failed}}</strong> failures</td>
</tr>
</table>

{{#each results.modules}}
<h2>{{@key}}</h2>

{{#each this.completed}}
<h3>{{@key}}</h3>
<ul class="assertions">
{{#each this.assertions}}
<li>
{{#if failure}}
<span class="error">&#10006;</span>
{{else}}
<span class="success">&#10004;</span>
{{/if}}

{{this.message}}

{{#if this.failure}}
{{this.failure}}
{{/if}}

{{#if this.stacktrace}}
<div class="stacktrace">
<a href="#">view stacktrace</a>
<code><pre>{{this.stacktrace}}</pre></code>
</div>
{{/if}}
</li>
{{/each}}
</ul>

<p>
{{#if this.failed}}
<span class="error"><strong>FAILED:</strong></span>
<span class="error"><strong>{{this.failed}}</strong></span> assertions failed and
<span class="success"><strong>{{this.passed}}</span></strong> passed. ({{this.time}}s)
{{else}}
<span class="success"><strong>OK.</strong></span>
<span class="success"><strong>{{this.passed}}</strong></span> assertions passed. ({{this.time}}s)
{{/if}}
</p>
{{/each}}

{{#if this.skipped}}
<h4>skipped</h4>
<ul>
{{#each this.skipped}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/if}}

<hr>
{{/each}}

<div id="nightwatch-logo"></div>

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
$(function() {
$('div.stacktrace').on('click', 'a', function(evt) {
evt.preventDefault();
var $link = $(this);
var $code = $link.parent().find('code');
$code.is(':visible') ? $link.text('hide stacktrace'):
$link.text('view stacktrace');
$code.toggle();
});
});
</script>
</body>
</html>
34 changes: 34 additions & 0 deletions integration-testing/html-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var fs = require('fs');
var path = require('path');
var handlebars = require('handlebars');

module.exports = {
write: function (results, options, done) {

var reportFilename = options.filename_prefix + (Math.floor(Date.now() / 1000)) + '.html';
var reportFilePath = path.join(__dirname, options.output_folder, reportFilename);

// read the html template
fs.readFile('integration-testing/html-reporter.hbs', function (err, data) {
if (err) throw err;

var template = data.toString();

// merge the template with the test results data
var html = handlebars.compile(template)({
results: results,
options: options,
timestamp: new Date().toString(),
browser: options.filename_prefix.split('_').join(' '),
totalTests: results.passed + results.failed + results.errors
});

// write the html to a file
fs.writeFile(reportFilePath, html, function (err) {
if (err) throw err;
console.log('Report generated: ' + reportFilePath);
done();
});
});
}
};
File renamed without changes.
8 changes: 4 additions & 4 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ["integraton-testing"],
src_folders: ["integration-testing"],

// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: ["integraton-testing/pages"],
page_objects_path: ["integration-testing/pages"],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: [],
Expand Down Expand Up @@ -68,11 +68,11 @@ module.exports = {
// For more info on using CucumberJS with Nightwatch, visit:
// https://nightwatchjs.org/guide/writing-tests/using-cucumberjs.html
type: "cucumber",
src_folders: ["integraton-testing/step_definitions"],
src_folders: ["integration-testing/step_definitions"],
// define cucumber specific options
options: {
//set the feature path
feature_path: "integraton-testing/features",
feature_path: "integration-testing/features",

// start the webdriver session automatically (enabled by default)
// auto_start_session: true
Expand Down
83 changes: 83 additions & 0 deletions package-lock.json

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

Loading

0 comments on commit 518d761

Please sign in to comment.