Commit Graph

37 Commits

Author SHA1 Message Date
Tatiana Ovchinnikova f044c4b0a3 Migrate to AngularJS v1.8.2
This patch aligns current code with AngularJS v1.8.2 requirements.

Change-Id: Ifdad18e805953957bfaa1b42908dfbbe8976dbcb
2022-06-08 15:43:13 -05:00
Tatiana Ovchinnikova 5c45c8825e Add expectations to identity specs
The last bunch of "spec has ho expectations" warnings is fixed
for the latest Jasmine. The option failSpecWithNoExpectations
is set to true now.

Related-Bug: #1894127

Change-Id: I87d6a3e0a21eb8f3e5a548d7fdd0ae01bbda54e1
2020-12-18 10:22:57 -06:00
Tatiana Ovchinnikova b532943a31 Update devDependencies in package.json
This patch updates outdated JavaScript dev dependencies.

The latest Jasmine version makes nested beforeEach and unhandled
promise rejection fail, this was fixed.

Also, the latest Jasmine version runs tests in random order by default,
random is set to false for now to prevent tests failures.

Finally, the latest Jasmine version supports a new configuration option
failSpecWithNoExpectations. By default, this option is set to false and
Jasmine reports specs that have no expectations as passed. Setting this
option to true tells Jasmine to report specs without as expectations as
failed. For now, it is set to false for openstack-dashboard tests, this
should be changed in future.

Change-Id: I04d5c3ce7f7e0a9a38251e975b68bfa1998e556f
2020-12-17 12:21:31 -06:00
Ivan Kolodyazhny 6f0200032d Update lower constraints and change browser to Firefox to unblock gate
Pip 20.x requires ensure_str method from six which was introduced
in v.1.12.0 and wrapt v.1.11 is required by astroid v.2.4.0 with
the pylint dependency. So this patch update six and wrapt version
in lower-constraints.txt to fix the gate.

It also updates the browser to Firefox in karma.conf.js and adds
'karma-firefox-launchers' in package.json because nodejs-job
fail with chromium-browser due to not able to access some URL.
It also removes 'karma-chrome-launcher' enteries from all files
as it is no longer used.  So let's switch to Firefox browser to
unblock the gate then we can investigate later how to fix it with
chromium-browser.

Depends-On: https://review.opendev.org/c/zuul/zuul-jobs/+/766744

Co-Authored-By: Vishal Manchanda <manchandavishal143@gmail.com>
Change-Id: I13e68d89f55407b1b3c64219969912700feef500
2020-12-14 13:31:45 +00:00
Pascal Boutin 0dc5a8230e Makes the xstatic files lookup dynamic in the tests
This change makes it so the tests will look for the actual
python folder where the xstatic files are located instead
of looking only for a python2.7/ folder.

Change-Id: Ib2a56475b79b002085922ab752038239635fb9a5
Closes-bug: #1706980
2017-07-27 10:01:33 -04:00
Diana Whitten c219a3efc6 Horizon Spinner/Loader should inherit from theme
The Horizon spinner was using a spinner generated and animated
entirely out of JavaScript. Since CSS3 provides animates and we have
access to icon fonts, doing everything with JavaScript is not
necessary and actually taxing on the browser. Plus, all of the
spinner options were being passed in and around with JavaScript,
including the colors.  This makes it supremely difficult to use the
theme to style the spinner.

The new spinner is just defined by a handful of templates now. There
are two clientside templates to support Legacy Horizon, and one
template in the Angular to support spinners going forward.  Legacy
Horizon had two forms of spinners, so it was broken up. Angular as
not yet made use of the inline spinner, but should follow the same
markup when it is made.

There are two types of spinners, inline spinners (those shown when a
dynamic tab content is loading) and modal spinners (various other
places).  These are consistent with each other for the 'default'
experience, but their experience can be entirely customized separate
from each other.  'material' has been augmented with loaders defined
within their design spec to show the power of this new feature.

horizon.templates.js was augmented with this refactor to support only
having to compile one tempalte at a time (instead of all of them) and
caching that template so that all of them can be recompiled later.
Also, horizon.loader.js was added to house template compilation code
that was repeated in several locations.

To test overwriting page modal spinner and inline-modal spinner
examples, please follow the instructions in _loading_inline_exmaple.html,
_loading_modal_example.html under
openstack_dashboard/themes/material/templates/horizon/client_side

Change-Id: I92bc786160e070d30691eeabd4f2a50d6e2bb395
Partially-implements: blueprint horizon-theme-css-reorg
Partially-Implements: blueprint bootstrap-html-standards
Closes-bug: #1570485
2017-04-21 11:15:52 -07:00
Rob Cresswell 36d1d1ac68 Refactor tox & update docs
- Updated tox envlist, so just running `tox` from the CLI will now run all
voting gate tests

- Reduce duplicated definitions and commands

- Remove any reliance on run_tests within tox

- Removes all doc references to run_tests.sh, and replaces them
with their tox equivalent. Where necessary, language around the tox
commands has been altered or extended so that it makes sense and is
consistent with other parts of the docs. Also adds a new "Test Environment"
list to the docs, so that newcomers do not have to piece together CLI
commands and their cryptic extensions from tox.ini

- Move the inline shell scripting to its own file. Also fixes a bug when
passing args, since the logic assumed you were attempting a subset test
run (try `tox -e py27 -- --pdb` on master to compare)

- Moved translation tooling from run_tests to manage.py, w/ help text
and arg restrictions. This is much more flexible so that plugins can use
it without having to copy commands, but still defaults to exactly the
same parameters/behaviour from run_tests. Docs updated appropriately.

- Removed npm/karma strange reliance on either .venv or tox/py27. Now
it only uses tox/npm.

Change-Id: I883f885bd424955d39ddcfde5ba396a88cfc041e
Implements: blueprint enhance-tox
Closes-Bug: 1638672
2016-11-30 20:38:59 +00:00
Rob Cresswell 0e957dd41a Add Angular Schema Form
This patch adds Angular Schema Form[1] and its requirements to Horizon.
There are a number of advantages to this over the current methods of
defining forms and workflows:

- All fields have an individual template, making theming improvements,
  bug fixes, and bootstrap conformity easier.
- The file and line count, especially for workflows, is dramatically
  reduced. The Create Net workflow, for example, goes from 12+ files to
  2, with a big reduction in boilerplate HTML.
- All field validation messages are standardised, so we can match them
  across Horizon and plugins

What this patch contains:
- Many common form fields, including things like the themable checkboxes
  and selects.
- A basic modal template that can be passed with ui-bootstraps $modal
  service to take advantage of schema-form

Next steps:
- Remove the other modal templates so we can standardise. A single
  template opened from the $modal service is fine, and we shouldn't need
  several directives. In this case, we should deprecate them, as the
  modal forms will be used elsewhere.
- Map commonly used form items, like transfer tables, to a schema form
  type like array (they serve similar purposes, so maybe thats what
  should be replaced)
- Use themable selects instead of regular ones

1. http://schemaform.io/

Co-Authored-By: Tyr Johanson <tyr@hpe.com>
Implements: blueprint angular-schema-form
Change-Id: Ib22b2d0db2c4d4775fdef62a180cc994e8ae6280
2016-08-04 16:53:41 +00:00
Matt Borland bf7c5908fb Output JS Karma test coverage reports to ./cover/
Per CTI direction (see bug filing), this patch moves the JS Karma test coverage
reports to ./cover/ so they may be collected in the gate for archiving.

The two runs each have their own directory so they don't overlap/conflict.

Change-Id: I0b1536c115a516f4b6ab80b5ebab5337b308c210
Closes-Bug: 1588389
2016-06-02 14:35:39 +00:00
Timur Sufiev 193756fa6c Add module ngFileUpload as a dependency to main horizon.app module
Change-Id: I8ca6379ff6aad32ce934720f234d955dd99204dd
2016-05-19 13:46:55 +03:00
Rob Cresswell dbd4731048 Use Chrome for JS unit tests
PhantomJS has setup issues and is slowing down the gate with false
failures. We should change to Chrome until Phantom is more
reliable, at which point this patch can be reverted.

Change-Id: I4bf1c1e8e26ac708bd35145aff98562f30b3a050
Closes-Bug: 1568325
2016-04-12 15:19:56 +00:00
Matt Borland 47f7f54437 Updating JS unit test coverage threshold
This patch updates the JS unit test coverage threshold.  As we've added
code we've increased the coverage.  To keep new code well-covered, we
should increase the threshold so new code doesn't decrease the overall
coverage.  The rule of thumb is to keep it at the highest whole percentage
point that greater than .5% of a difference from the current coverage.

Change-Id: I89e18841b4e9ba4a2cbd49ee222d3234e9d26c88
2016-02-05 07:44:44 -07:00
cbeasley 0bd3863faf Add unit tests for load-edit directive
Write unit tests for the directive to increase test coverage
Split file read into a separate service for easier testing.

Co-Authored-By: Matt Borland <matt.borland@hpe.com>
Co-Authored-By: Shaoquan Chen <sean.chen2@hp.com>
Co-Authored-By: Rajat Vig<rajatv@thoughtworks.com>

Change-Id: Ie886c374b19d24351766bb48023ddfb7426b7a06
Partial-Bug: #1506891
2016-02-04 15:17:37 -08:00
Matt Borland 316aab1c3b Raise JS unit test coverage threshold
As people have been raising the unit test coverage, we should make sure
we're raising the thresholds as well.  This keeps the new code from
being lax in coverage.

The metric used here was to set whole number percentage points that were
more than one-half of a percentage point below the actual coverage.

Change-Id: I348d4b8cafcf6c7d0dc8e770b66609984e89c20b
Partial-Bug: 1506891
2015-12-14 08:17:12 -07:00
Matt Borland 06e0335560 Add ngroute libraries to appropriate paths
This patch adds ngroute libraries to appropriate paths and creates an
ng_route_base block in the Django base so templates can insert routing
blocks, such as establishing a base path.

Implements: blueprint add-ngroute
Change-Id: I11dd3890d336f288e93bf884197e3f22dcd1da93
2015-11-19 07:25:13 -07:00
Jenkins f4c4f33a74 Merge "Adding tests for untested areas" 2015-11-13 23:56:07 +00:00
Rob Cresswell 248281406e Don't hide Karma coverage reports
This patch updates the file names of the coverage reports so they are
visible by default on most systems. Also updates the .gitignore, so the
new files are not pushed to the Horizon repo.

DocImpact

Closes-Bug: 1508526
Change-Id: I3c1c8f4c88819e2f49b60722ea8cc37bdc711b8c
2015-11-04 10:21:46 +09:00
Matt Borland 282f59d6ba Adding tests for untested areas
Adding JS tests where appropriate to raise coverage.

Added a little safety into the original code.

Closes-Bug: 1506942
Change-Id: I57cbc0250d30e2fc3eb27863858f60f96dea1171
2015-11-03 11:03:03 -07:00
Matt Borland 859617fa32 Correct the Karma conf to search correct dirs
Changes the basepath and other paths to allow for correct specification
of template dirs, etc.

Change-Id: I6a5d155382dd2ff942d7738e67296a09d85b354b
Closes-Bug: 1507703
2015-10-22 14:17:42 +00:00
Matt Borland 08fb123f8b Improving JS unit test branch coverage
This patch is testing untested branches.

There is a bug in the Launch Instance model where it is supposed to
remove null properties from the top level of the model.  It is not doing
that properly.  So that bug is also fixed.

This patch currently raises the branch coverage in openstack_dashboard
from ~84% to ~89%.

Closes-bug: 1506891
Change-Id: I7434126246b15209b62daeff75744e0a3b435494
2015-10-19 15:15:58 +00:00
Rajat Vig 8a9329c5fe Add tests for controllers in tech-debt
Controllers image-form and hz-namespace-resource-type-form
do not have any tests.
This patch simply adds unit tests.

Change-Id: I537b7bdf6b778c333f84491891afeb8dbc45eb53
Closes-Bug: #1501513
2015-10-01 00:18:30 -07:00
Rajat Vig b9805efd99 Include JS from openstack_dashboard/**/static for code coverage
Code coverage metrics in Horizon for openstack_dashboard do not include
metrics from JS files in openstack_dashboard/**/static.

Change-Id: I24c5914e723e20ed4406635dfdeb8579c8e57840
Closes-Bug: #1498788
2015-09-23 00:45:36 -07:00
Michael Krotscheck c50acff6d8 Added karma threshold reporting & failure
This patch adds unit test coverage threshold reporting, adding
statement, branch, function, and line coverage to the console
output in infra, and failing the build if the threshold has not
been met.

The threshold values have been set to the current observed
coverage values - future patches should update this up as
coverage improves.

Closes-Bug: 1487109
Change-Id: Ie83ebf5d976b3538e3528787b05de3e83df18af8
2015-08-20 17:07:08 +01:00
Thai Tran 1ecb5ce8b9 Inconsistent karma conf for xstatic files
The xstatic files in dashboard/karma.conf is missing the smart-table
reference causing tests that rely on smart-table to fail. This patch fixes this.

Change-Id: I60ca60819f3a6ad525615dfdd6f6e6428c62d728
Closes-Bug: #1485746
2015-08-18 11:57:05 -07:00
Thai Tran df355d9553 Adding Angular-gettext to requirements
The makemessages side of translation is now angular compatible via babel.
Now we need the directives and filters that angular-gettext provides.
This patch also configures angular-gettext to use the django catalog.

Partially-Implements: blueprint angular-translate-makemessages
Change-Id: Ib180953d7bd77170092293247543398d964e7305
Depends-On: Ica8d73752093f2e5d30f70fc37ba87610f6823b1
2015-07-21 13:11:05 -07:00
Thai Tran b55df4fff0 Dashboard karma is missing framework files
We currently have two Karma files: one for horizon and one for
dashboard. Because dashboard code relies horizon, the karma conf in
dashboard should include the needed files from framework.

Change-Id: I06f2ebe1da845f559a6562156e8ad9e6a7ffb128
Closes-Bug: #1473176
2015-07-09 18:51:19 +00:00
Shaoquan Chen cb8077db69 Extending Karma config
This patch extends karma's config to cover code in
/openstack_dashboard/dashboards/
where plugins should reside.

Co-Authored-By: Tyr Johanson <tyr@hp.com>

Change-Id: I82d7463f64b26bb36c2182488e20d41f1b2d87dd
Partially-Implements: blueprint angularize-instances-table
2015-07-02 20:13:42 -07:00
Shaoquan Chen c0f4ee6e07 JSCS cleanup - launch-instance.js
This patch breaks up launc-instance.js into small pieces according to
Horizon code style.

Change-Id: I852943a5223289391b1b8a315be80a48dcd39fb6
Partially-Implements: blueprint jscs-cleanup
2015-07-01 10:17:47 -07:00
Shaoquan Chen bd6fec1400 JSCS cleanup - openstack_dashboard/static/dashboard/workflow
This patch breaks up workflow.js into small pieces according to
Horizon code style.

Change-Id: I2358020f29de4a235dd35553621b007da70d47fa
Partially-Implements: blueprint jscs-cleanup
2015-06-26 15:40:40 -07:00
Shaoquan Chen 7033531790 JSCS cleanup - style guide cleanup for karma.config.js files
karma.config.js files are wirtten in node.js and therefore should
be compliant to the JavaScript code style applyed in Horizon. Also
some formatting inconsistency should be fixed.

Change-Id: I98978ddb271af9dc3cf18c73d2bd83948d723de7
Partially-Implements: blueprint jscs-cleanup
2015-06-24 10:18:28 -07:00
Shaoquan Chen 595d9cf546 Normalizing Karma configuration
This cleans up the karma configuration to use auto-discovery
in place of explicitly listing files.

Change-Id: I7b05f7d6921af3a577270638a02717d04e7b20cd
Closes-Bug: #1467684
2015-06-23 11:07:30 +10:00
Richard Jones 2270e9139b ngReorg - move dashboard-app to dashboard
Move the angular app module from the framework to
openstack_dashboard at the top level as "horizon.app".

This edit also removes the old hzUtils.log function: it
exists in the framework, but is configured in the application,
thus causing dependency issues. It is only used in one place
(hz.tables.js), and for debugging. I contend that if debugging
is needed then $log can be asked for as needed.

The hzConfig.debug flag was only used by that one function,
so it is also removed in this edit.

Change-Id: Ie538940cd8d1b0eabe677790bad979cc146bfbd1
Closes-Bug: #1458697
Closes-Bug: #1465885
2015-06-18 14:43:35 +10:00
Ryan Peters 14eb8040da ngReorg - Move API files to openstack_dashboard
This commit moves the Angular-based API services to the
openstack_dashboard directory.

It also simplifies the naming scheme for the Angular-based
API modules.

Fixes all JSCS issues in files that were modified by this patch.

This is one step in a larger effort to restructure the Angular
source. See https://review.openstack.org/#/c/176152/ for the
full set of planned changes.

Change-Id: I4200336508761fb0155be422ebcecd4bf2907035
Closes-Bug: #1446886
2015-06-15 15:50:16 -05:00
Rob Cresswell de11d158aa JSCS Cleanup - karma.conf
JSCS cleanup for:
- openstack_dashboard/karma.conf.js
- horizon/karma.conf.js

Change-Id: I0c74187c86404b8b332eba6d1f7820f292bfa788
Partially-Implements: blueprint jscs-cleanup
2015-06-10 12:44:30 +01:00
Richard Jones 742cb8a679 ngReorg - move dashboard controllers from horizon
This change moves the controller ImageFormCtrl and
hzNamespaceResourceTypeFormController from horizon (the framework)
to openstack_dashboard (the application) where they belong.

Co-Authored-By: Tyr Johanson <tyr@hp.com>
Change-Id: I2309f0867c2f657a6065003475dcb10448f907bc
Partial-Bug: #1458697
2015-06-06 04:31:34 +00:00
Michael Krotscheck 76ea1f1837 Trigger tox from package.json, if necessary.
This patch adds several fixes to improve karma test handling.

* A postinstall hook was added to package.json, which tests for
  the existence of .venv. If it is not found, it will invoke
  tox -e py27 --notest.
* Both karma.conf files were taught to automatically detect the
  directories in which the xstatic dependencies might live, and
  pick the appropriate directory.

postinstall was chosen, because setting up a virtual environment
is likely to be useful for more than one type of npm job.

Change-Id: I822cb020bd8b2ca8d4f994b9734af5636e4bd144
2015-06-05 08:16:22 -07:00
Matt Borland 241c2cf432 Get unit tests working with Karma
Establish features for running Karma tests.  Separate karma configurations
are used due to current overlap of template file structure.

You can run the karma tests via:
  ./run_tests.sh --karma

The Karma framework allows for many features like unit test coverage and
provides a common configuration for different test runners.

Change-Id: I79680ef6369383c148da68e6677945886a48df81
Implements: blueprint karma
2015-06-01 14:14:58 +00:00