<LocationMatch /eg/staff/>
Options -MultiViews
PerlSetVar OILSWebStopAtIndex "true"
-
- # map /eg/staff to /eg/staff/index
- RewriteEngine On
- RewriteCond %{PATH_INFO} =/staff/
- RewriteRule (.*) /eg/staff/index [L,DPI]
+ # ...
</LocationMatch>
-----------------------------------------------------------------------------
is best in this context. (See "Why create the AngularJS Popup Dialog
Service?"). More on Angular directives later.
+2013-12-13 Unit Tests with AngularJS/Karma/Jasmine
+--------------------------------------------------
+
+We now have 4 unit tests in the repository! For now, the files live
+under Open-ILS/tests/staffweb/.
+
+Running Unit Tests
+~~~~~~~~~~~~~~~~~~~
+
+These instructions replace my earlier instructions at
+link:web-staff-log.html#_2013_11_26_getting_started_with_testing[2013-11-26 Getting Started with Testing].
+
+[source,sh]
+-----------------------------------------------------------------------------
+# install node.js
+% sudo apt-get install nodejs npm
+
+# node.js is installed at 'nodejs' -- npm, etc. assume 'node'
+% sudo ln -s /usr/bin/nodejs /usr/bin/node
+
+# install karma test engine node plugin
+% sudo npm install -g karma
+
+# fetch a copy of angular / angular-ui-bootstrap
+% sudo apt-get install curl # if needed
+% cd Open-ILS/tests/staffweb/
+% ./update-angular.sh 1.2.4 0.7.0
+
+# run the tests
+% CHROME_BIN=chromium-browser scripts/test.sh
+-----------------------------------------------------------------------------
+
+The output...
+
+[source,sh]
+-----------------------------------------------------------------------------
+Starting Karma Server (http://karma-runner.github.io)
+\-------------------------------------------------------------------
+INFO [karma]: Karma v0.10.5 server started at http://localhost:9876/
+INFO [launcher]: Starting browser Chrome
+INFO [Chromium 30.0.1599 (Ubuntu)]: Connected on socket XmJAj4CwHlta3NuSQwC9
+Chromium 30.0.1599 (Ubuntu): Executed 4 of 4 SUCCESS (0.623 secs / 0.073 secs)
+\-----------------------------------------------------------------------------
+-----------------------------------------------------------------------------
+
+Sample Tests
+~~~~~~~~~~~~
+
+[source,js]
+-----------------------------------------------------------------------------
+/** patronSvc tests **/
+describe('patronSvcTests', function() {
+
+ it('patronSvc should start with empty lists', inject(function(patronSvc) {
+ expect(patronSvc.patrons.count()).toEqual(0);
+ }));
+
+ it('patronSvc reset should clear data', inject(function(patronSvc) {
+ patronSvc.checkout_overrides.a = 1;
+ expect(Object.keys(patronSvc.checkout_overrides).length).toBe(1);
+ patronSvc.resetPatronLists();
+ expect(Object.keys(patronSvc.checkout_overrides).length).toBe(0);
+ expect(patronSvc.holds.items.length).toBe(0);
+ }));
+})
+-----------------------------------------------------------------------------
+
+These tests are very basic. They ensure that the patronSvc service
+(defined in circ/patron/app.js) is properly initialized and that the
+resetPatronLists() function behaves as expected.
+
+Initial Reactions
+~~~~~~~~~~~~~~~~~
+
+These types of tests can be very useful for testing complex, client-side
+code. However, just like with Evergreen Perl/C unit tests, JS unit
+tests are not meant to be executed in a live environment. You can test
+code that does not require network IO (as above) and you have the
+option of creating mock data which is used in place of network-retrieved
+data.
+
+I believe the best long-term approach, however, will be full coverage
+testing with the live, end-to-end test structure, also supported by Angular.
+It requires more setup and I hope to have time
+to research it more fully soon. I say this because Evergreen has fairly
+complex data requirements (IDL required, data fetched through opensrf
+instead of bare XHR) and practically all of the prototype code uses
+network IO or assumes the presence of a variety of network-fetched data,
+which will be non-trivial to mock up and will only grow over time.
+Fingers crossed that it's not a beast to get running. More on this as
+the story develops....
+
+2013-12-13 #2 - Brief Update
+----------------------------
+
+ * Last week the prototype acquired a locale selector. It uses the
+ existing locale bits from EGWeb.pm, so it was easy to add.
+
+ * The prototype is nearing completion!
+
+ * Beware testing on small screens, as the CSS causes the screen to
+ break and flow (e.g. for mobile devices) a little too aggressively
+ right now. TODO.
Future Topics...
----------------
* My (currently) preferred parent scope, child scope, service pattern
- * Deep Linking / Managing the _first load_ problem
* Displaying bib records in the prototype
- * More testing
////