Commit graph

1582 commits

Author SHA1 Message Date
abaevbog
2d3375e9f6
Revised logic of trashed collections in item cache (#4358)
- revert change from 2401a34031
that only loads un-trashed collections in _loadCollections.
If an item only belongs to deleted collections, item._loaded.collections = true
from _loadCollections will never run, so an exception
will be thrown in item.toJSON() when syncing happens.
Instead, to address the problem of item.getCollections()
having stale data #4307, add 'includeTrashed' parameter to
item.getCollections() based on which item._collections
will be filtered. Fixes: #4346
- revert earlier, no more necessary, changes from a532cfb475
to not alter item._collections cache when collections are being trashed or restored.
Collection is removed from item._collections only when it is permanently
erased.
- removed unnecessary test checking for consistent item._collections
value before and after reload, since item._collections is no longer
modified
- fix encountered bug where a trashed child collection is not
unloaded if a parent collection is erased without being trashed first.
- tweaked Zotero.Search sql construction to count items
that only belong to trashed collections into 'unfiled'. Fixes: #4347

---------

Co-authored-by: Dan Stillman
2024-07-09 03:34:12 -04:00
abaevbog
2401a34031
Fix updating of deleted collections in Libraries & Collections (#4324)
- listen to 'collection' notifier events and re-render
the section if a relevant collection is moved to trash or
modified. That way, a deleted collection will be removed,
a restored collection will be added back, and renaming a
collection will update the name.
- fixed a bug where a restored collection would not
be added into item._collections cache. Fixed false-positive
test for it.
- do not add deleted collections into items. _collections cache in
Zotero.Items._loadCollections. Otherwise, deleted collections will
appear in librariesCollectionsBox after the app is restarted.
2024-07-04 22:07:37 -04:00
Abe Jellinek
d8eae4cd3b Enable Undo Retrieve Metadata when translator added note (#4267)
Closes #2977
2024-07-01 03:31:45 -04:00
Dan Stillman
29fa2f7073 LABD: Add test for ignoring a file that already exists under new path 2024-07-01 01:48:22 -04:00
Dan Stillman
6942506eba Rework object type checking in items list
a532cfb475 added `isCollection()`, `isSearch()`, and `isItem()` methods
to data objects to handle collections and searches in the trash, with
`isItem()` checking whether `._ObjectType` was `Item`. That left out
feed items (`._ObjectType` == `FeedItem`), and when c384fef867 made
`getSelectedItems()` return only items, it used `isItem()`, so feed
items were excluded, which broke feed-item toggling between read and
unread [1] and possibly some other things.

The simple fix would be to make `isItem` match feed items as well (which
could potentially fix other bugs related to feed items), but there was
actually no need to add new methods (which can get confused with
`CollectionTreeRow` methods) when we can just check the object type with
`obj instanceof Zotero.Item`, which gets the benefit of inheritance and
matches `Zotero.FeedItem` instances as well.

[1] https://forums.zotero.org/discussion/115571/cannot-change-the-status-of-title-in-subscribtion
2024-06-28 02:09:49 -04:00
Dan Stillman
7f372fdd42 Add recursiveCollections test for items in deleted subcollections
Addresses #4271
2024-06-27 05:10:59 -04:00
Dan Stillman
a2dc0f7e37 Sort related items by title
Closes #4281
2024-06-26 01:02:07 -04:00
Dan Stillman
38b0b3a69a Fix bug in #_setHighlightedRowsCallback() test 2024-06-24 04:42:59 -04:00
Dan Stillman
4ca92adb89 Tests: Use select() instead of selectCollection()/selectSearch() 2024-06-24 04:40:12 -04:00
Dan Stillman
ca5ea08e2b Fix failing test from 173f4c491e 2024-06-24 03:01:57 -04:00
Dan Stillman
cd43e95b85 Fix build failure from 42d4064bac 2024-06-24 02:53:48 -04:00
Dan Stillman
a9c5c1bfa5 Tests: Remove some unnecessary waitForItemsLoad() calls 2024-06-24 02:45:20 -04:00
Dan Stillman
621435be68 Tests: Rework collection/search-in-trash tests
- Update for auto-`skipSelect` on collections and searches
- Remove interdependencies that prevented independent runs
- Remove unnecessary manual object names
- Remove unnecessary delay
- Switch to new convenience selection functions
- Switch to customary object naming
2024-06-24 02:45:20 -04:00
Dan Stillman
173f4c491e Tests: Don't auto-select collections and searches after creation
This changes `createDataObject()` to pass `skipSelect: true` for objects
other than items. If a test is creating a bunch of collections, there's
no reason for each one to be selected and for an items list to start to
load. If a test does need a new collection or search to be selected, it
can call the new convenience function `await select(win, obj)`, which
will select the passed object in the collection tree and wait for its
items list to load. I'm hoping this reduces random test failures due to
items list churn.
2024-06-24 02:45:20 -04:00
Dan Stillman
09aad7b075 Tests: Make some ZoteroPane tests more reliable 2024-06-24 02:45:20 -04:00
Dan Stillman
6dfd8965f1 Fix hanging tests after c384fef867 2024-06-24 02:45:20 -04:00
Dan Stillman
aaac18ced6 Tests: Add convenience function to pause execution without timing out
`await pause(this)` can be used to disable the test timeout and pause
execution so the UI state can be manually inspected
2024-06-24 02:45:20 -04:00
Dan Stillman
42d4064bac Tests: Add additional convenience functions for object selection
Objects can now be selected in the UI with just `await select(win, obj)`
2024-06-24 02:45:19 -04:00
Dan Stillman
764e75a39a Fix typo in test title 2024-06-23 05:09:32 -04:00
Dan Stillman
c384fef867 Add getSelectedObjects() and limit getSelectedItems() to items
This adds an explicit function on ZoteroPane and the item tree for
getting objects -- including collections and searches in the trash --
and limits `getSelectedItems()` to returning actual items from the
selection. We shim various item properties on the collections and
searches in the trash, but code that's getting the selection should be
explicit about what it wants. Outside of the trash, they're equivalent,
except `getSelectedObjects()` does have an `asIDs` mode.

This switches to using getSelectedObjects() in various places and fixes
collections in the trash appearing as belonging to My Publications when
using the collections-containing-an-item highlight [1].

This also adds support for highlighting the parent collections of
collections in the trash.

[1] https://forums.zotero.org/discussion/115449/zotero-7-beta-deleted-collection-appears-as-belonging-to-my-publications
2024-06-23 05:09:31 -04:00
Dan Stillman
a612c1227e Fix collections in trash showing up in menus
New Collection menu and Add to Collection menu

https://forums.zotero.org/discussion/115447/zotero-7-beta-deleted-collections-still-appear-in-the-ui
2024-06-22 16:33:11 -04:00
Abe Jellinek
310e741a01
Fix duplicate attachment row from attachments-box notify() (#4250) 2024-06-19 02:23:46 -04:00
Dan Stillman
fad3e25278 Local API: Return 404 for unknown group library 2024-06-19 00:40:13 -04:00
Bogdan Abaev
a532cfb475 trash functionality for collections and searches (#3307)
When a collection or a saved search is deleted, it appears in
trash among other trashed items. From there, it can be restored
or permanently deleted.

Items of trashed collections are not affected my the trashing/permanent
deletion of a collection and need to be deleted separately like before.

Subcollections of a trashed collection do not appear in the trash and
are restored or permanently deleted with the top-most trashed parent.
2024-06-17 23:14:21 -04:00
Adomas Venčkauskas
338afc2b80 Add tests for HTTP integration endpoints 2024-06-17 12:45:28 +03:00
Dan Stillman
137a1ddcc0 Missing file for 639b4b5623 2024-06-15 00:45:28 -04:00
Dan Stillman
639b4b5623 Use local HTTP server for Zotero.BrowserDownload test 2024-06-15 00:40:03 -04:00
Abe Jellinek
50e2250fe0
Add pref to enable local API (#4236)
And keep enabled in tests
2024-06-14 06:25:39 -04:00
Dan Stillman
17539404b2 Fix test failure calling item.toResponseJSON() with no library set
After #4270
2024-06-12 05:50:36 -04:00
Abe Jellinek
5d197e4b12 Mostly complete (read-only) compatibility with web library (#4270)
- Add pagination, limits, and Link header
- Add schema endpoints and dummy /settings endpoint
- Add /file endpoints
  - Browser security restrictions prevent the web library from actually loading
    the file: URIs that the local API returns, but out-of-browser use will work
    fine
- Add toResponseJSONAsync() DataObject function: delegates to toResponseJSON()
  by default, adds information that requires awaiting promises
  - Best attachment (links.attachment) and file size (links.enclosure.length)
    for items, meta.numItems for groups
  - Separate function for compatibility with the existing test code that uses
    toResponseJSON(), but we could consider unifying

This commit does not add the Access-Control headers that allow webpages to make
requests to the local API, since I don't think we actually want that.
2024-06-12 05:45:48 -04:00
Abe Jellinek
44d9530ecf Add local implementation of Zotero web API (#4270)
This required some tweaks to other parts of Zotero infrastructure:
- Search:
  - Add 'includeDeleted' condition to match behavior of 'includeTrashed' API
    parameter in a single search
- Data objects:
  - Improve toResponseJSON() implementations so output better matches the web
    API
    - Add toResponseJSON() to Zotero.Tags - has to be async so it can query the
      database and generally works differently from other toResponseJSON()
      functions, but accomplishes the same task
  - Remove unused getAPIData() and apiDataGenerator() DataObject functions. They
    aren't functional and wouldn't really make implementing the local server
    easier, so now seemed like a decent time to remove them
- Server:
  - Support resolving routes using pathparser.jsm
    - Add allowMissingParams option to PathParser#add(): prevents /route from
      matching /route/:param
  - Replace the query property of the data object sent to endpoint init()s with
    searchParams, an instance of URLSearchParams - supports #getAll() for
    repeatable parameters
- URIs:
  - Make getObjectURI() public, add utilities for converting URIs to API
    endpoints and web library URLs
2024-06-12 05:45:38 -04:00
windingwind
a6076ce76c
Fix item pane header (#4159)
* Improve feed item pane header (fixes #4141)
* Show item pane custom head when headerMode is none (fixes #4116)
* fx115: Fix button style on windows (fixes #4120)
* Move split-menu-button styles to SCSS
2024-06-04 02:14:20 -04:00
abaevbog
e7c7367509
zp tab focus tests pass if run on their own (#4183)
Make sure that more than one tab is opened before tab navigation
tests are run so that the tabs menu is always focusable.

Fixes: #4180
2024-05-31 05:54:26 -04:00
windingwind
5ebd6c4141 Try to fix unstable attachments pane test 2024-05-29 21:27:13 +08:00
Martynas Bagdonas
e96426d18c Adjust fulltext test 2024-05-28 17:32:03 +03:00
Martynas Bagdonas
97c37de7f7 Update reader and pdf-worker submodules and partially disable one test 2024-05-28 17:18:56 +03:00
windingwind
fe3dae2d15
Refactor AttachmentPreview render and discard (#4161) 2024-05-28 00:05:29 -04:00
Abe Jellinek
3176516b79 Feeds: Fix error parsing items with rights information
- 59afef6 added a duplicate assignment to item.rights that was putting
  a TextConstruct(!!!!) in the item JSON field instead of a string
- info.rights was being set to a TextConstruct (preexisting issue!)
2024-05-23 14:20:44 -04:00
Abe Jellinek
92bb96ac49 Feeds: De-prioritize prism:copyright
Seems to be more used for copyright owner names than license
information, which is probably what we want in that field when it's
available.
2024-05-23 14:16:38 -04:00
abaevbog
9325f773cc
fix tagsbox enter glitch (#4160)
The 'blur' event needs to be dispatched by editable-text
before its state is reset (not after) because tagsbox uses
.initialValue in the 'blur' handler.

followup to 101e6d55d5

Fixes: #3575
2024-05-23 00:16:36 -04:00
Dan Stillman
721f54fe49 Disable tagsbox test again due to CI failures (#3575) 2024-05-22 23:22:05 -04:00
Dan Stillman
debe5590f2 Temporarily disable intermittently failing tests (#4139) 2024-05-22 23:02:56 -04:00
Abe Jellinek
59afef6c2e
Feeds: Refactor to move field extraction to FeedProcessor (#4158)
And support more PRISM fields.
2024-05-22 18:29:58 -04:00
Dan Stillman
14c6d26f20 Clarify comment for numDistinctFileAttachmentsForLabel() test 2024-05-19 00:54:13 -04:00
Dan Stillman
47bf4de08a Add test for numDistinctFileAttachmentsForLabel() filter function 2024-05-19 00:52:36 -04:00
windingwind
bc47ee46c8 Fix item pane buttons after CEification
Fixes #4115
2024-05-15 06:45:10 -04:00
windingwind
9a23031c12 Rename ItemPaneHeader CE localName to item-pane-header
Closes #4114
2024-05-15 06:45:09 -04:00
windingwind
91c0c28b5d Fix attachments & annotation box refresh bugs and add tests (#4031)
Fixes #3993
Fixes #3995
Closes #4082
2024-05-15 06:45:01 -04:00
Dan Stillman
07e8f0a01d Try to make numDistinctFileAttachmentsForLabel() test more reliable 2024-05-15 06:09:40 -04:00
Dan Stillman
0c8d3f0829 Improve counting of file attachments for Show File and Export PDFs
If a parent item and its primary attachment are selected, it should
still say "Show File" rather than "Show Files". This adds the
questionably named `Zotero.Items.numDistinctFileAttachmentsForLabel()`
to try to figure out if we're operating on 0, 1, or >1 items.

Follow-up to #4124
2024-05-15 05:50:47 -04:00