Commit graph

82 commits

Author SHA1 Message Date
Dan Stillman
5051b938ae Increase default timeout to 5 seconds from 2
This is arbitrary, and we could increase it more or make it configurable via
the command line if Travis continue to time out, but this allows all tests to
complete for me in a VM.
2015-05-29 01:34:20 -04:00
Dan Stillman
025411f9b4 Wait 250ms before quitting after tests, to avoid DB errors
Not crazy about this, but (at least on my system) it's an easy way to
avoid DB errors due to interrupted transaction or query errors after the
DB connection was cleaned up. (I can reproduce those pretty reliably
right now by running collectionTreeView tests alone.)
2015-05-29 01:15:04 -04:00
Aurimas Vinckevicius
ec786bf15c For now, use Zotero item DB ids when passing items to citeproc
citeproc-js relies on this in several locations. Seems that Zotero passes these IDs to citeproc from the item picker. We also need to consider existing embedded items in Word/LO documents, but they do have embedded URIs, so it shouldn't be a problem.
CC @fbennett
2015-05-26 16:11:44 -05:00
Aurimas Vinckevicius
f6083068cd Fix display of pending tests 2015-05-26 16:11:43 -05:00
Aurimas Vinckevicius
409553da2e Add getTempDirectory (async) method to support.js
Returns a promise for a path to a new temporary directory
2015-05-26 16:11:42 -05:00
Aurimas Vinckevicius
2ebce91ecf Add -g flag to runtests.sh to generate test data
Add functions to generate sample data for various formats
* Zotero Web API JSON (Zotero.Item::toJSON)
* CiteProc-JS JSON
* Export translator JSON
* Direct serialization of Zotero.Item fields
Add a way to load sample data into DB from JSON
Add tests for loading sample data into DB
Add tests for automatically generated data
This will help us make sure that field mappings and data formats don't change
2015-05-26 16:04:55 -05:00
Dan Stillman
cbbdebc5b7 Fix hang in collectionsTreeView::selectWait() if row is already selected 2015-05-25 01:43:07 -04:00
Dan Stillman
43762248a4 Fix trash emptying, and do it in batches of 50 2015-05-25 00:14:49 -04:00
Dan Stillman
ff7919553c Collections data layer cleanup
Get rid of data_access.js, at long last. Existing calls to
Zotero.getCollections() will need to be replaced with
Zotero.Collections.getByLibrary() or .getByParent().

Also removes Zotero.Collection::getCollections(), which is redundant
with Zotero.Collections.getByLibrary(), and Zotero.Collections.add().
The latter didn't didn't include a libraryID anyway, so code might as
well just use 'new Zotero.Collection' instead.
2015-05-24 04:37:34 -04:00
Dan Stillman
ada657fcb8 Functions to modify 'version'/'synced' efficiently, plus some other fixes 2015-05-21 23:44:10 -04:00
Dan Stillman
4792b7cd48 Data layer fixes
- Fixes some saving and erasing issues with collections and searches
- Adds Zotero.DataObject::eraseTx() to automatically start transaction,
  and have .erase() log a warning like .save()
- Adds createUnsavedDataObject() and createDataObject() helper functions
  for tests
2015-05-20 23:16:18 -04:00
Dan Stillman
d67e615b73 Allow foo, fooTest, fooTest.js, and tests/fooTest.js when running tests 2015-05-12 19:42:54 -04:00
Dan Stillman
a64282118b Fix items-count updating in right-hand pane
And some other tweaks to ZoteroPane.itemSelected()
2015-05-10 18:30:05 -04:00
Dan Stillman
84ff141edd Make the '✖' for test errors red
This makes it much easier to find the errors in a long list of tests.
2015-05-10 03:30:25 -04:00
Dan Stillman
94f968ae57 Add Sinon mock framework for tests 2015-05-07 15:09:41 -04:00
Dan Stillman
c19a597766 Create 1000x400 browser windows for tests 2015-05-07 15:09:41 -04:00
Dan Stillman
c18f31aeab Show Firefox UI when using loadBrowserWindow() in tests
The window created by loadWindow() is still empty, but this removes the
'chrome' flag for loadBrowserWindow(), which causes the Firefox UI to be
shown.

I think openDialog calls are always chrome, but providing just the
chrome flag disables all other options (e.g., navbar).
2015-05-05 02:53:08 -04:00
Dan Stillman
8fec5ace3a Fix post-save textbox focusing bugs in right-hand pane
Fix a couple cases of lost text field focus after an edit, including
focusing of the Title field after using New Item when a field is already
being edited and has a changed value.

Also, in tests, select My Library and wait for items to load when using
the loadZoteroPane() support function. We could add a parameter to skip
that or move it to a separate function, but the code to detect it is a
bit convoluted and it's a prerequisite for many tests, so it's handy to
have a function for it.
2015-05-04 02:45:55 -04:00
Dan Stillman
b241d3ec52 Add loadBrowserWindow() test support function 2015-04-26 18:08:25 -04:00
Dan Stillman
f78b18c692 Fix ES6 warning calling UInt8Array without 'new' 2015-04-25 03:17:40 -04:00
Dan Stillman
d9c32a8e90 Fix search saving, and add some unit tests
Also:

- Return an object from `Zotero.Search.prototype.getConditions()`
  instead of an array.
- Add support function `getPromiseError(promise)` to return the error
  thrown from a chain of promises, or false if none. (We could make an
  `assert.throwsAsync()`, but this allows testing of various properties
  such as `.name`, which even the built-in `assert.throws()` can't
  test.)
- Clarify some search save errors
2015-04-17 00:25:09 -04:00
Dan Stillman
973e602cfc Enable Bluebird generator support in Mocha
Promise-yielding ES6 generator functions can now be used for test
functions, and they'll automatically be wrapped with Bluebird's
coroutine().
2015-04-15 01:35:53 -04:00
Dan Stillman
6dfdae870e Q -> Bluebird in tests 2015-04-13 03:44:59 -04:00
Dan Stillman
7519287fa8 Fix JS version declaration for test support scripts 2015-03-24 02:27:33 -04:00
Simon Kornblith
3583793571 Wait for bundled file updates to complete before running tests 2015-03-11 13:32:25 -04:00
Simon Kornblith
8253b98134 Remove index.js and just enumerate the files in the test directory 2015-03-09 17:41:49 -04:00
Simon Kornblith
4a4073652f updateBundledFiles before using translators and wait for completion 2015-03-09 17:17:53 -04:00
Simon Kornblith
c7c58f8343 Add support function to reset the DB and a test that it works. 2015-03-09 14:25:49 -04:00
Simon Kornblith
299009dcd5 Add unit tests for add item by identifier and some support refactoring
Also adds EventUtils from MozMill to simplify UI automation.
2015-03-08 19:28:27 -04:00
Simon Kornblith
3f0f7af71a Add unit test for PDF recognition with DOI
Also some support code that was useful here and will probably be
useful for other tests. This is a pretty complicated thing to test, but
it seems to work.
2015-03-08 16:02:10 -04:00
Simon Kornblith
50cd396918 Make debugging tests a bit easier
- Add command-line argument to enable debug logging
- Add command-line argument to open (and leave open) jsconsole
- Try to print error stack traces (although Mocha doesn't seem to like
  them?)
2015-03-07 22:17:44 -05:00
Simon Kornblith
1c32db68da Unit testing infrastructure
Implements the beginnings of unit testing infrastructure using
mocha/chai. The unit tests can be run locally using test/runtests.sh,
although this will need tweaks to run on Windows. They should also run
on commit using Travis-CI.

The unit tests themselves live in test/tests. The index.js file
specifies separate test sets, which can be run individually by calling
test/runtests.sh <testsets>. Right now there is only a single unit
test, but hopefully we'll have more soon...
2015-03-07 16:34:55 -05:00