Commit graph

63 commits

Author SHA1 Message Date
Aurimas Vinckevicius
87d5625bac Add Chai-as-Promised 2015-09-18 03:34:03 -05:00
Dan Stillman
b53892fe54 Fix various collection-dragging UI bugs
Fixes #823, hopefully
2015-08-08 17:26:42 -04:00
Dan Stillman
0aecaad761 Update conflict resolution for API syncing
This will appear much less frequently, since non-conflicting field changes on
both sides can be resolved automatically, but genuine field conflicts still
require manual conflict resolution.

The merge pane is no longer editable, since the itembox code to do that is
async and can't run in a modal window, but it's not really necessary,
particularly with conflicts happening less frequently.

TODO:

- Remote item deletions
- File conflicts
- Maybe handle some edge cases where the conflicted items fail to save
2015-08-06 04:14:49 -04:00
Dan Stillman
4600318ad7 Support 'successful' property in upload response
Save uploaded data to cache, and update local object if necessary (which
it mostly shouldn't be except for invalid characters and HTML filtering
in notes)

Also add some upload and JSON tests
2015-08-01 05:28:42 -04:00
Dan Stillman
984789d304 API syncing megacommit
There's a lot more to do, and this isn't ready for actual usage, but the
basic functionality is mostly in place and has decent test coverage. It
can successfully upgrade a library last used with classic syncing and
pull down changes via the API. Uploading mostly works but is currently
disabled for safety until it has better test coverage.

Downloaded JSON is first saved to a cache table, which is then used to
populate other tables and later for generating PATCH requests and
automatically resolving conflicts (since it shows what was changed
locally and what was changed remotely). Objects with unmet dependencies
or unknown fields are skipped for now but don't block the rest of the
sync.

Some of the bigger remaining to-dos:

- Tests for uploading
- Re-do the preferences to get an API key
- File sync integration
- Full-text syncing integration
- Manual conflict resolution (though this already includes much smarter
  conflict handling that automatically resolves many conflicts)
2015-07-20 18:16:57 -04:00
Dan Stillman
02cd71ebb5 Allow overriding startup options in Zotero.reinit()
And use it in resetDB() test support function, mainly to allow
skipBundledFiles for resetDB calls. Translator installation and
initialization can take a long time, but tests that need a clean DB
don't necessarily rely on translators. Without this, running resetDB()
in beforeEach() for many tests is prohibitively slow.
2015-07-20 02:12:14 -04:00
Dan Stillman
5c523d8694 Merge branch '4.0' 2015-07-18 07:09:53 -04:00
Aurimas Vinckevicius
e3ab3ab03e Add institutional author to sample test data 2015-06-29 23:22:09 -05:00
Dan Stillman
b602cc4bd2 waitForWindow()/waitForDialog() test function tweaks
- Give any window onload functions time to run before running
  waitForWindow()
- Allow custom dialog URI in waitForDialog
2015-06-23 05:20:50 -04:00
Dan Stillman
79f0e4761f Handle delays for all non-cancel buttons in waitForDialog() in tests
When the button delay is enabled, all buttons other than Cancel are
delayed.
2015-06-16 19:51:21 -04:00
Simon Kornblith
900a957318 Put a Z at the end of the accessDates in generateAllTypesAndFieldsData
Doesn't actually make a difference to the tests, but it's more correct
2015-06-07 18:52:31 -04:00
Simon Kornblith
70f021f945 Use ISO 8601 accessDates everywhere
This uses ISO 8601 dates for generateAllTypesAndFieldsData (and
changes populateDBWithSampleData to use Item#fromJSON), and makes
translators expect ISO 8601 accessDates, although SQL accessDates are
still supported with a deprecation warning. Canonicalization happens in
Zotero.Translate, so I need to remember to update connectors as well.
2015-06-07 18:50:57 -04:00
Dan Stillman
a22c4969e6 Move editable and filesEditable props to libraries table [DB reupgrade]
And add group.fromJSON(json, userID), which sets editable and
filesEditable properties based on the group JSON (libraryReading, role
lists, etc.) and the given user
2015-06-07 15:50:07 -04:00
Dan Stillman
da627e137a Add waitForDialog(onOpen, button) support function
Waits for an alert or confirmation dialog to open and closes it
automatically, optionally after running onOpen(dialog) to check its
contents (e.g., with dialog.document.documentElement.textContent) and
optionally clicking a button other than 'accept' (e.g., 'cancel',
extra1').

Supports delayed accept buttons
2015-06-04 20:31:48 -04:00
Dan Stillman
ffff044ce6 Add stack traces to Chai assertion failures 2015-06-02 16:31:33 -04:00
Aurimas Vinckevicius
294f01bb3a Check if attempting to use a legacy generator function in Mocha tests 2015-06-02 13:34:51 -05:00
Dan Stillman
ef3bf8d596 Fix a few test failures/warnings
And simplify tree view load event handling, which may or may not have
been contributing to intermittent test failures, but is cleaner this way
regardless.
2015-06-02 03:51:09 -04:00
Simon Kornblith
26673a30c5 See if sorting the test files is enough to get alpha order on Travis 2015-06-01 23:42:38 -04:00
Simon Kornblith
a4e5478957 Run tests in order (I think) 2015-06-01 23:32:57 -04:00
Dan Stillman
a740658452 Relations overhaul (requires new DB upgrade from 4.0)
Relations are now properties of collections and items rather than
first-class objects, stored in separate collectionRelations and
itemRelations tables with ids for subjects, with foreign keys to the
associated data objects.

Related items now use dc:relation relations rather than a separate table
(among other reasons, because API syncing won't necessarily sync both
items at the same time, so they can't be stored by id).

The UI assigns related-item relations bidirectionally, and checks for
related-item and linked-object relations are done unidirectionally by
default.

dc:isReplacedBy is now dc:replaces, so that the subject is an existing
object, and the predicate is now named
Zotero.Attachments.replacedItemPredicate.

Some additional work is still needed, notably around following
replaced-item relations, and migration needs to be tested more fully,
but this seems to mostly work.
2015-06-01 20:28:30 -04:00
Dan Stillman
67663497ec Allow library and item titles to be set in create(Unsaved)DataObject() 2015-06-01 20:23:20 -04:00
Dan Stillman
c1cb832b0b Add getGroup() and createGroup() test support functions
getGroup() can be used to access a default group library for general
group tests. createGroup() can be used to create one for a particular
test or set of tests.
2015-06-01 20:23:20 -04:00
Simon Kornblith
9bb01d737c Merge branch '4.0' into sjk/659 2015-06-01 00:03:20 -04:00
Dan Stillman
5ba344516e Update PDF tool handling in tests
The test runner now downloads and caches the PDF tools for the current
platform within the test data directory and only redownloads them when
out of date, and it updates the download URL so that the full-text code
pulls from the cache directory via a file:// URL.

The installPDFTools() support function now installs the files directly
instead of going through the prefs, and a new uninstallPDFTools()
function removes the tools. Since the presence of the PDF tools can
affect other tests, tests that need the tools should install them in a
before() and uninstall them in an after(), leaving most tests to run
without PDF indexing.

This also adds a callback to the waitForWindow() support function. If a
modal dialog is opened, it blocks the next promise handler from running,
so a callback has to be used to interact with and close the dialog
immediately.
2015-05-31 23:50:26 -04:00
Erik Hetzner
aac1255d3d Add basic tests for full-text search
- also add importFileAttachment support function
2015-05-31 14:39:37 -07:00
Simon Kornblith
ca0af1abd6 Missed a UTC adjustment in 673168ea7b 2015-05-31 17:13:32 -04:00
Dan Stillman
8ff108cbdf Merge pull request #745 from Juris-M/simpler-stable-stringify
Simplification of stableStringify()
2015-05-31 17:10:42 -04:00
Simon Kornblith
673168ea7b Don't adjust accessDate for UTC and set version to 0 in Item#toJSON
Ref discussions:
https://github.com/zotero/zotero/pull/746/files#r31394225
https://github.com/zotero/zotero/pull/746#commitcomment-11445605
2015-05-31 17:02:20 -04:00
Frank Bennett
ff1d4fa602 Simplification of stableStringify() 2015-05-31 19:46:11 +09:00
Dan Stillman
fd45032210 Add -g flag to run only tests matching a pattern (grep)
(Actually, it's only matching strings for me, not patterns, but according to
Mocha it's supposed to compile the patterns using RegExp.)
2015-05-31 03:37:45 -04:00
Dan Stillman
f3a6b41c1c Add -f test flag to stop after first test failure
(Mocha has a 'bail' config flag that's supposed to do this, but it doesn't seem
to work when passed to mocha.setup() (maybe because we're setting a custom fail
handler?), so this just calls abort() on the runner manually.)
2015-05-29 04:01:40 -04:00
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