Friday 11 July 2014

Re-structuring privly-applications

Privly-Applications repo has different applications in it. Like ZeroBin, PlainPost etc.

All the apps have new.html and a show.html files that do app specific tasks.

These new.html and show.html files are generated by a script 'build.py' that takes a template file "new.html.template" and "show.html.template" from the templates directory and "new.html.subtemplate" and "show.html.subtemplate" from the app directory to finally build the new.html and show.html file.

So change the structure of privly-applications I had to makes changes to the .template and .subtemplate files so that they don't use the meta_loader.js to load the spec files from the <meta> tags. The new structure instead requires all the app specific specs to be already included in the html as javascript files.

So I made changes to the .template file wherein I removed the use of meta_loader.js and added shared javascript files that are common to all the privly-applications. The jasmine library and the console-runner are also included in the .template file only. Then I made changes to specific .subtemplate files of each app wherein I added app specific spec files.

Then I ran the `build.py` script (make sure all the dependencies are installed) which generated the new.html and show.html files for all the apps depending upon the new .template and .subtemplate files.

Getting started...

Initially(Link):
- Content Server was integrated with Travis.
- Next step was to add JavaScript tests to the CIS(Issue).

Existing implementation of JavaScript testing(Link):

After going through the implementation and documentation some main points:

1. For consistency across all the JavaScript projects, Privly is using the Jasmine testing library for running tests
2. Use of console reporter which sends test results directly to the JavaScript console.
3. And also the use of the meta_loader.js which finds the PrivlySpec meta tag and uses it to inject the appropriate testing scripts and specs.

This implementation allows to test the privly-applications by running the `runTests()' command in the JavaScript console which loads the Spec files and runs the tests. It then shows the output in the console itself.


Problem: For this to be integrated with Travis we need to print this output to the terminal.

Solution: Repo

This repo gives details about how to run jasmine tests with phantomjs and selenium-webdriver and get the results to the terminal.


After discussing we finally decided to go with selenium-webdriver for running tests.

Reasons: Link #2 and #5 being the main reasons.

This implementation requires the Source files and the Spec files to be present in the HTML itself.


Thus the system requires the need of changing the structure of privly-applications that currently uses meta_loader.js to load Spec files from the meta tags.