Commit graph

81 commits

Author SHA1 Message Date
Dan Stillman
20ece48a57 Fix saving of single files to library root via save button 2016-03-21 01:30:16 -04:00
Dan Stillman
b9444892a0 Ring bell on test error if interactive shell 2016-03-15 01:18:55 -04:00
Dan Stillman
6b509820b3 Fixes #918, Enabling "Show Unfiled Items" or "Show Duplicates" breaks UI 2016-03-13 20:31:15 -04:00
Dan Stillman
daf4a8fe4d Deasyncification 🔙 😢
While trying to get translation and citing working with asynchronously
generated data, we realized that drag-and-drop support was going to
be...problematic. Firefox only supports synchronous methods for
providing drag data (unlike, it seems, the DataTransferItem interface
supported by Chrome), which means that we'd need to preload all relevant
data on item selection (bounded by export.quickCopy.dragLimit) and keep
the translate/cite methods synchronous (or maintain two separate
versions).

What we're trying instead is doing what I said in #518 we weren't going
to do: loading most object data on startup and leaving many more
functions synchronous. Essentially, this takes the various load*()
methods described in #518, moves them to startup, and makes them operate
on entire libraries rather than individual objects.

The obvious downside here (other than undoing much of the work of the
last many months) is that it increases startup time, potentially quite a
lot for larger libraries. On my laptop, with a 3,000-item library, this
adds about 3 seconds to startup time. I haven't yet tested with larger
libraries. But I'm hoping that we can optimize this further to reduce
that delay. Among other things, this is loading data for all libraries,
when it should be able to load data only for the library being viewed.
But this is also fundamentally just doing some SELECT queries and
storing the results, so it really shouldn't need to be that slow (though
performance may be bounded a bit here by XPCOM overhead).

If we can make this fast enough, it means that third-party plugins
should be able to remain much closer to their current designs. (Some
things, including saving, will still need to be made asynchronous.)
2016-03-07 17:03:58 -05:00
Dan Stillman
e119e5bf0d Extra logging for waitForWindow() support function 2016-02-03 01:20:11 -05:00
Dan Stillman
e873617890 Fix trashing of descendant items when deleting a collection
Also allows 'collections' property to be passed to
createDataObject()/createUnsavedDataObject() in tests.
2016-01-18 13:50:46 -05:00
Dan Stillman
07fbda2b72 Add "[FAIL]" to test failures, for easier searching of output 2016-01-07 16:49:12 -05:00
Dan Stillman
c5a9987f37 WebDAV file sync overhaul for 5.0
Also:

- Remove last-sync-time mechanism for both WebDAV and ZFS, since it can
  be determined by storage properties (mtime/md5) in data sync
- Add option to include synced storage properties in item toJSON()
  instead of local file properties
- Set "Fake-Server-Match" header in setHTTPResponse() test support
  function, which can be used for request count assertions -- see
  resetRequestCount() and assertRequestCount() in webdavTest.js
- Allow string (e.g., 'to_download') instead of constant in
  Zotero.Sync.Data.Local.setSyncState()
- Misc storage tweaks
2015-12-30 05:14:50 -05:00
Dan Stillman
cfee7ea9d2 Merge pull request #879 from adomasven/feature/transparent-api-keygen
Restores the functionality of 4.0 for sync settings
2015-12-14 19:28:56 -05:00
Adomas Venčkauskas
ffd9a07164 Restores sync credential functionality of 4.0.
Improves UX of sync authentication.
The account is now linked and unlinked and an API key related to
the client is generated transparently in the background.
The API key is deleted on unlinking.
No sync options are allowed before linking an account.
2015-12-14 23:55:28 +00:00
Dan Stillman
177dac3fd2 Closes #805, Translation shouldn't create new item in My Publications
And in download overlay, save and switch to My Library if My
Publications is selected.
2015-12-10 01:11:41 -05:00
Dan Stillman
18349b2232 Restore certificate checking for API syncing errors
Closes #864

This adds a 'channel' property to Zotero.HTTP.UnexpectedStatusException,
because the 'channel' property of the XHR can be garbage-collected
before handling, and the channel's 'securityInfo' property is necessary
to detect certificate errors.
2015-12-09 04:11:27 -05:00
Dan Stillman
57dfd1885d Allowing passing window to loadZoteroPane() support function 2015-11-15 17:49:31 -05:00
Dan Stillman
ae277391b6 Miscellaneous tweaks 2015-11-12 02:48:41 -05:00
Dan Stillman
7633c7de30 Set test timeout in resetDB() instead of separate this.timeout() calls
'thisArg: this' should be passed to resetDB to have it adjust the
timeout
2015-09-29 04:42:12 -04:00
Aurimas Vinckevicius
d122323dbf Fix fullText tests on Windows 2015-09-21 17:08:22 -05:00
Aurimas Vinckevicius
88ab129ffb Add Feed and FeedItem
Also:
* _finalizeErase in Zotero.DataObject is now inheritable
* Call _initErase before starting a DB transaction
* removes Zotero.Libraries.add and Zotero.Libraries.remove (doesn't seem like this is used any more)
2015-09-21 17:08:21 -05:00
Aurimas Vinckevicius
76511eca08 Fix stack formatting in unit testing output 2015-09-21 02:28:10 -05:00
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