Skip to content
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

Google Summer of Code 2016 JavaScript Testing project #11420

Merged
merged 60 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
66bb966
Initial test environment setup with Jasmine, Karma and RequireJS
Ruchiranga May 7, 2016
ad3a5ad
Seperated test setup code from test logic
Ruchiranga May 8, 2016
7406d41
Configured .travis.yml to run Karma
Ruchiranga May 8, 2016
c018571
Fixed typo in .travis.yml
Ruchiranga May 8, 2016
fee4e17
changes to .travis.yml
Ruchiranga May 8, 2016
b8a4141
Added karma requirejs module
Ruchiranga May 8, 2016
cf79a3a
Removed unnecessary code in travis.yml
Ruchiranga May 8, 2016
efe9184
Fixed missing code is travis.yml
Ruchiranga May 8, 2016
a379b2c
Removed 2 unused image files
Ruchiranga May 8, 2016
443a24c
Improved code standards
Ruchiranga May 11, 2016
bee021d
Modified travis.yml
Ruchiranga May 11, 2016
bcb4369
Issue 1 Cleaned the mess with changes bunch of to unrelated files
Ruchiranga May 12, 2016
95efc33
Issue 1 Added newline at end of file
Ruchiranga May 12, 2016
4a44581
Issue 4 Improved JCaption JavaScript tests
Ruchiranga May 13, 2016
26a5537
New coeverage reporter plugin test with Travis
Ruchiranga May 16, 2016
c7ef18c
Issue 1 Added karma-coerage reporter and configured it to display cov…
Ruchiranga May 17, 2016
a197a39
Issue 1 Added and configured karma-verbose-reporter plugin
Ruchiranga May 17, 2016
be722df
Issue 1 Fixing verbose reporter config for travis
Ruchiranga May 17, 2016
80c7319
Issue 1 removed redundant javascript dir and added requirejs/text plu…
Ruchiranga May 18, 2016
35f946b
Issue 4 Improved code with suggestions made in the code review
Ruchiranga May 18, 2016
f4f95fc
Issue 1 Added version for requirejs text plugin
Ruchiranga May 18, 2016
3f1e919
Issue 1 converted space indentations to tabs
Ruchiranga May 18, 2016
57b1cdb
Issue 1 Fixed indentation in package.json
Ruchiranga May 18, 2016
203b8e1
Issue 1 Fixed version issue in require text
Ruchiranga May 18, 2016
5c2173d
Issue 1 Fixed version issue in require text
Ruchiranga May 18, 2016
b735d3b
Issue 1 Fixed version issue in require text
Ruchiranga May 18, 2016
204487e
Issue 4 Improved code standards and jquer selector efficiency
Ruchiranga May 19, 2016
e628662
Issue 1 Tersting version issue with text plugin on travis
Ruchiranga May 19, 2016
b634891
Issue 1 Tersting version issue with text plugin on travis
Ruchiranga May 19, 2016
fda4cdb
Issue 1 Tersting version issue with text plugin on travis
Ruchiranga May 19, 2016
2778be1
Issue 1 Removed spec folder
Ruchiranga May 28, 2016
6a7b519
Initial test environment setup with Jasmine, Karma and RequireJS and …
Ruchiranga Apr 29, 2016
1f38598
Pulled remote dev and fixed conflicts
Ruchiranga Jun 26, 2016
cbdc7fb
Merge branch 'staging' into develop
yvesh Jun 26, 2016
839aacd
Corejs tests (#15)
Ruchiranga Jun 26, 2016
4ad9c2a
Tests for permissions.js (#13)
Ruchiranga Jun 26, 2016
6490fd4
Added a container div for fixtures representing library name (#11)
Ruchiranga Jun 26, 2016
2517488
CS - Removed an extra new line
Ruchiranga Jun 26, 2016
9c119ce
Permissions.js tests
Ruchiranga Jun 26, 2016
4151107
Repeatable.js test suite
Ruchiranga Jul 1, 2016
e4eeaf8
Improvements to JCaption tests
Ruchiranga Jul 5, 2016
29a67fc
README.md update
Ruchiranga Jul 10, 2016
4a2e743
Core js Improvements
Ruchiranga Jul 12, 2016
f1e4425
Demo video on Youtube
Ruchiranga Jul 18, 2016
ea7e52d
Merge remote-tracking branch 'joomla/staging' into develop
yvesh Jul 27, 2016
4bd2191
Issue 5 Added spies and made code improvements (#31)
Ruchiranga Jul 30, 2016
7c4d470
Issue 12 Improved code (#34)
Ruchiranga Jul 30, 2016
b5aaf53
Repeatable.js Improvements (#35)
Ruchiranga Jul 30, 2016
b15b5bc
Run Travis JavaScript tests on separated Matrix Build (#39)
yvesh Aug 1, 2016
ff79a55
Reverted README.md
Ruchiranga Aug 3, 2016
2540229
Merge remote-tracking branch 'joomlacms/staging' into cleancore
Ruchiranga Aug 3, 2016
80ba272
Synced README.md to the new version
Ruchiranga Aug 3, 2016
1c4bbfd
Synced README.md with new version
Ruchiranga Aug 3, 2016
46d9e83
Fixed indentations
Ruchiranga Aug 3, 2016
835a383
Merge remote-tracking branch 'ruchi/develop' into gsoc-js-tests
Ruchiranga Aug 3, 2016
f1bfe52
Synced README.md with 3.6 version
Ruchiranga Aug 3, 2016
9927733
Fixed indentations
Ruchiranga Aug 3, 2016
fe4563e
Merge remote-tracking branch 'upstream/develop' into cleancore
Ruchiranga Aug 3, 2016
81148ec
Merge remote-tracking branch 'gsocrepo/cleancore' into gsoc-js-tests
Ruchiranga Aug 3, 2016
d85ac35
Added missing sudo:false in .travis.yml
Ruchiranga Aug 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ tests/codeception/tests/acceptance/*Tester.php
tests/codeception/tests/functional/*Tester.php
tests/codeception/tests/unit/*Tester.php

# Node modules #
node_modules/

# phpDocumentor Logs #
phpdoc-*

Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ language: php
env:
global:
- RUN_PHPCS="no"
- RUN_JAVASCRIPT_TESTS="no"
- INSTALL_MEMCACHE="yes"
- INSTALL_MEMCACHED="yes"
- INSTALL_REDIS="yes"

matrix:
fast_finish: true
include:
- node_js: 6.1
sudo: true
env: RUN_JAVASCRIPT_TESTS="yes"
- php: 5.3
env: INSTALL_APC="yes"
- php: 5.4
Expand Down Expand Up @@ -50,6 +54,8 @@ services:
- redis-server

before_script:
# JavaScript tests
- if [[ $RUN_JAVASCRIPT_TESTS == "yes" ]]; then export DISPLAY=:99.0; bash tests/javascript/travis-tests.sh $PWD; fi
# Make sure all dev dependencies are installed
- composer install
# Set up databases for testing
Expand All @@ -74,6 +80,7 @@ before_script:
script:
- libraries/vendor/bin/phpunit --configuration travisci-phpunit.xml
- if [[ $RUN_PHPCS == "yes" ]]; then libraries/vendor/bin/phpcs --report=full --extensions=php -p --standard=build/phpcs/Joomla .; fi
- if [[ $RUN_JAVASCRIPT_TESTS == "yes" ]]; then tests/javascript/node_modules/karma/bin/karma start karma.conf.js --single-run ; fi

branches:
except:
Expand Down
84 changes: 84 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Karma configuration

module.exports = function (config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine-ajax', 'jasmine', 'requirejs'],

// list of files / patterns to load in the browser
files: [
{pattern: 'tests/javascript/node_modules/jquery/dist/jquery.min.js', included: false},
{pattern: 'tests/javascript/node_modules/jasmine-jquery/lib/jasmine-jquery.js', included: false},
{pattern: 'tests/javascript/node_modules/text/text.js', included: false},
{pattern: 'media/jui/js/bootstrap.min.js', included: false},
{pattern: 'media/system/js/*.js', included: false},
{pattern: 'tests/javascript/**/fixture.html', included: false},
{pattern: 'tests/javascript/**/spec.js', included: false},
{pattern: 'tests/javascript/**/spec-setup.js', included: false},
{pattern: 'images/*.png', included: false},

'tests/javascript/test-main.js'
],

// list of files to exclude
exclude: [
'media/system/js/*uncompressed.js'
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/system/js/*!(uncompressed).js': ['coverage']
},

// coverage reporter configuration
coverageReporter: {
type : 'text'
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['verbose', 'coverage'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Firefox'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// list of plugins
plugins: [
'karma-jasmine',
'karma-jasmine-ajax',
'karma-firefox-launcher',
'karma-coverage',
'karma-requirejs',
'karma-verbose-reporter'
],

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
22 changes: 22 additions & 0 deletions tests/javascript/caption/fixtures/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div id="captionjs">
<div id="single">
<img src="base/images/joomla_black.png" class="test" title="Joomla Title 1" />
</div>
<hr/>
<div id="multiple">
<img src="base/images/joomla_black.png" class="test" title="Joomla Title 1" />
<img src="base/images/powered_by.png" class="test" title="Joomla Title 2" align="right" width="100"/>
</div>
<hr/>
<div id="empty">
<img id="empty-title" src="base/images/joomla_black.png" class="test" title="" />
</div>
<hr/>
<div id="options">
<img id="no-options" src="base/images/joomla_black.png" class="test" title="Joomla Title 1"/>
<img id="width-attr" src="base/images/joomla_black.png" class="test" title="Joomla Title 2" width="100"/>
<img id="width-style" src="base/images/joomla_black.png" class="test" title="Joomla Title 3" style="width: 90px"/>
<img id="align-attr" src="base/images/joomla_black.png" class="test" title="Joomla Title 4" align="right"/>
<img id="align-style" src="base/images/joomla_black.png" class="test" title="Joomla Title 5" style="float: right"/>
</div>
</div>
17 changes: 17 additions & 0 deletions tests/javascript/caption/spec-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'text!testsRoot/caption/fixtures/fixture.html', 'libs/caption'], function ($, fixture) {
$('body').append(fixture);

new JCaption('#single img.test');
new JCaption('#multiple img.test');
new JCaption('#empty img.test');
new JCaption('#options img.test');
});
68 changes: 68 additions & 0 deletions tests/javascript/caption/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'testsRoot/caption/spec-setup', 'jasmineJquery'], function ($) {

describe('JCaption applied to single image', function () {
it('Should have caption as "Joomla Title 1" under image', function () {
expect($('#single').find('p')).toHaveText('Joomla Title 1');
});
});

describe('JCaption applied for multiple images', function () {
it('Should have caption "Joomla Title 1" under image 1', function () {
expect($('#multiple').find('p').first()).toHaveText('Joomla Title 1');
});

it('Should have caption as "Joomla Title 2" under image 2', function() {
expect($('#multiple').find('p').last()).toHaveText('Joomla Title 2');
});
});

describe('JCaption with empty title attribute value', function () {
it('Should not have a <p> element inside the image container', function () {
expect($('#empty')).not.toContainElement('p');
});
});

describe('JCaption with no additional options', function () {
var $element = $('img#no-options');
it('Should have container CSS {float: none}', function () {
expect($element.parent()).toHaveCss({
float: 'none'
});
});
});

describe('JCaption with additional options', function () {
it('Should have 2 elements with class right', function () {
expect($('#options').find('.right').length).toEqual(2);
});

it('Should have container width as 100 when element width attribute is set to 100', function () {
expect($('img#width-attr').parent().width()).toEqual(100);
});

it('Should have container width as 90 when element style is set to width: 90px', function () {
expect($('img#width-style').parent().width()).toEqual(90);
});

it('Should have float: right in container CSS when element attribute align is set to right', function () {
expect($('img#align-attr').parent()).toHaveCss({
float: 'right'
});
});

it('Should have float: right in container CSS when element style is set to float: right', function () {
expect($('img#align-style').parent()).toHaveCss({
float: 'right'
});
});
});
});
39 changes: 39 additions & 0 deletions tests/javascript/core/fixtures/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div id="corejs">
<div id="submitform">
<form id="adminForm" onsubmit="return false"></form>
</div>
<div id="replace-tokens">
<input class="replace-tokens-input" type="hidden" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" type="hidden" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-type" type="submit" value="1" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-value" type="hidden" value="0" name="123456789123456789123456789EDBCA">
<input class="replace-tokens-input" id="invalid-name" type="hidden" value="1" name="123">
</div>
<div id="check-all">
<input type="checkbox" id="cb-no-form" checked>
<form id="check-all-form">
<input type="checkbox" class="checked" id="cb0" checked>
<input type="checkbox" class="unchecked" id="cb1">
<input type="checkbox" class="unchecked" id="cb2">
<input type="checkbox" class="unchecked" id="no-cb3">
</form>
<form id="check-all-stub-form">
<input type="checkbox" id="stub-check-test-1" checked>
<input type="checkbox" id="stub-check-test-2">
</form>
</div>
<div id="render-messages-remove-messages">
<div id="system-message-container">
</div>
</div>
<div id="ischecked">
<form id="ischecked-test-form">
<input type="checkbox" id="check-all-box" name="checkall-toggle">
<input type="checkbox">
</form>
</div>
<div id="table-ordering">
<form id="table-ordering-test-form">
</form>
</div>
</div>
12 changes: 12 additions & 0 deletions tests/javascript/core/spec-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla
* @subpackage JavaScript Tests
* @since 3.6
* @version 1.0.0
*/

define(['jquery', 'text!testsRoot/core/fixtures/fixture.html', 'libs/core'], function ($, fixture) {
$('body').append(fixture);
});
Loading