Skip to content

Commit

Permalink
Added defaultComponents to search config, implemented test
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus committed Jan 26, 2024
1 parent 0f70ecc commit bba9407
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
6 changes: 5 additions & 1 deletion oarepo_ui/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ def search(self):
search_options = dict(
api_config=self.api_service.config,
identity=g.identity,
overrides={"ui_endpoint": self.config.url_prefix, "ui_links": ui_links},
overrides={
"ui_endpoint": self.config.url_prefix,
"ui_links": ui_links,
"defaultComponents": {},
},
)

extra_context = dict()
Expand Down
4 changes: 1 addition & 3 deletions oarepo_ui/theme/webpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
"oarepo_ui_components": "./js/oarepo_ui/custom-components.js",
},
dependencies=dependencies,
devDependencies={
"eslint-plugin-i18next":"^6.0.3"
},
devDependencies={"eslint-plugin-i18next": "^6.0.3"},
aliases={
**aliases,
"@translations/oarepo_ui": "translations/oarepo_ui",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-ui
version = 5.0.100
version = 5.0.101
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
5 changes: 3 additions & 2 deletions tests/templates/TestSearch.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{#def extra_context, ui_links #}
{#def extra_context, ui_links, search_app_config #}
{
"ui_links": {{ ui_links|tojson|safe }},
"permissions": {{ extra_context.permissions|tojson|safe }},
"dummy_filter": {{ 1|dummy|tojson|safe }}
"dummy_filter": {{ 1|dummy|tojson|safe }},
"search_config": {{ search_app_config|tojson|safe }}
}


55 changes: 55 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json


def test_search(
app, record_ui_resource, simple_record, client_with_credentials, fake_manifest
):
with client_with_credentials.get(f"/simple-model/") as c:
txt = json.loads(c.text)
search_config = txt["search_config"]
assert search_config == {
"aggs": [],
"appId": None,
"defaultComponents": {},
"defaultSortingOnEmptyQueryString": {"sortBy": "newest"},
"initialQueryState": {
"filters": [],
"hiddenParams": None,
"layout": "list",
"page": 1,
"size": 10,
"sortBy": "bestmatch",
},
"layoutOptions": {"gridView": False, "listView": True},
"paginationOptions": {
"defaultValue": 10,
"maxTotalResults": 10000,
"resultsPerPage": [
{"text": "10", "value": 10},
{"text": "20", "value": 20},
{"text": "50", "value": 50},
],
},
"searchApi": {
"axios": {
"headers": {"Accept": "application/vnd.inveniordm.v1+json"},
"url": "/api/simple-model",
"withCredentials": True,
},
"invenio": {
"requestSerializer": "InvenioRecordsResourcesRequestSerializer"
},
},
"sortOptions": [
{"sortBy": "bestmatch", "text": "Best match"},
{"sortBy": "newest", "text": "Newest"},
{"sortBy": "oldest", "text": "Oldest"},
],
"sortOrderDisabled": True,
"ui_endpoint": "/simple-model",
"ui_links": {
"create": "https://127.0.0.1:5000/simple-model/_new",
"next": "https://127.0.0.1:5000/simple-model?page=2",
"self": "https://127.0.0.1:5000/simple-model",
},
}

0 comments on commit bba9407

Please sign in to comment.