Commit graph

5226 commits

Author SHA1 Message Date
3200c18e7d
Bug 32351: Fix t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:20 -03:00
8455c0b83d
Bug 32351: Fix t/db_dependent/api/v1/patrons.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:19 -03:00
11ac81782f
Bug 32351: Fix Koha/Patrons.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:19 -03:00
ca77a59a9b
Bug 32351: Fix TemplateToolkit.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:18 -03:00
cd49ab5c28
Bug 32351: Fix CourseItems.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:18 -03:00
5f07e7afff
Bug 32351: Fix Circulation.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:17 -03:00
4824bbf195
Bug 32351: Fix Reserves.t
itemtypes.notforloan already defaults to 0

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:17 -03:00
a471e6d5bc
Bug 32351: Fix Members.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:16 -03:00
ade52182c4
Bug 32351: Fix Illrequests.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:16 -03:00
d077aa2e7d
Bug 32351: Fix Budgets.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:15 -03:00
eecad982ee
Bug 32351: Fix Acquisition.t
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:15 -03:00
ad3d34bfd1
Bug 32351: Holds.t - remove wrong column reference
Found by bug 32350.
The test does not need this value at all..

Test plan:
Run test.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:14 -03:00
f1d2ec4aa8
Bug 31381: Add tests
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 15:58:13 -03:00
46aa87c600
Bug 32350: Add subtest for bad columns
Test plan:
Run t/db_dependent/TestBuilder.t
And now run the whole test suite :)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 12:40:33 -03:00
9b9b8f1920
Bug 32350: Use array_minus and ignore nesting
Note: Test will be extended in follow-up. This fixes the
module_bit hash to follow the FK path from user_permissions
to permissions to userflags. One step was missed in the
existing test, although it did not fail. The change here
revealed that now.

Test plan:
Run t/db_dependent/TestBuilder.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-30 12:40:28 -03:00
404c88fe87 Bug 31969: Use filter_by_last_update
This script has a pattern to delete rows depending on a given
date/number of days, we should use the filter_by_last_update
Koha::Objects method.
No need for another method and tests, everything is already tested
there.

This patch also suggests to rename the reference to "background" and
"bg" with "jobs", which seems more appropriate and not an abbreviation

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-25 09:40:09 -03:00
11918dcb72
Bug 32304: BackgroundJobs.t: Fix subtest purge
Instead of deleting, I added a count :)
Note that one of the purges eventually deletes my
older jobs..

Test plan:
Run t/db_dependent/Koha/BackgroundJobs.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-25 09:38:17 -03:00
0a1d7aa520
Bug 32304: Fix subtest search_limited
Jenkins reported:
    not ok 1 - No jobs found without userenv

We need to check if there are jobs without borrowernumber.

Test plan:
Run test again.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-25 09:38:13 -03:00
509ff8f05c
Bug 32343: Prevent Koha/Patron.t to fail randomly
Highlighted by Bug 32030: fix test builder for boolean

The attribute is named "unique_id", not "unique"

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-25 09:27:45 -03:00
1672bd3ed2
Bug 32269: Prevent Circulation.t to fail randomly
Highlighted by Bug 32030: fix test builder for boolean

    #   Failed test 'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'
    #   at t/db_dependent/Circulation.t line 343.
    #          got: '2022-11-18T14:16:12'
    #     expected: '2022-12-02T00:00:00'

    #   Failed test 'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore'
    #   at t/db_dependent/Circulation.t line 349.
    #          got: '2022-11-18T14:16:12'
    #     expected: '2022-12-02T23:59:00'
    # Looks like you failed 2 tests of 5

We were reaching return $now

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-23 09:29:45 -03:00
c6e5467e5f
Bug 31378: Tests shouldn't remove all patrons
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-22 18:23:07 -03:00
158ddef999
Bug 31080: Unit tests
Unit tests for add_to_bundle functionality that prevents bundle nesting.

Test plan
1) Run t/db_dependent/Koha/Item.t
2) The test should fail
3) Apply the second patch
4) Re-run the test and watch it pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-22 16:28:11 -03:00
7c7db3eb6b
Bug 24606: (QA follow-up) Fix Template.t
The test cases here still assumed UTF-8 enocding in the middle
of the process. Can be much simpler.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-22 13:33:39 -03:00
527f8fadcc
Bug 32010: 2AF selenium tests - Alert can appear when we are waiting for ajax
If we are waiting for ajax (there is a sleep 1s) and the alert pops up
at the same time, Selenium is raising "unexpected alert open"

We should not wait for the ajax request, but better wait for the
alert actually.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-22 08:55:09 -03:00
d8d03c8efa
Bug 32178: Adapt tests to new auth.session params
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-18 12:04:30 -03:00
cb7b9b37c9
Bug 32268: Prevent XSLT.t to fail randomly
Can't call method "itemnumber" on an undefined value at /kohadevbox/koha/Koha/Recall.pm line 343.

We should set item_level and not let TestBuilder pick a value.

This may have been caught (make it more obvious) by the recent change to
TestBuilder for boolean (Bug 32030: fix test builder for boolean)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-18 12:04:28 -03:00
3d8ff90a8f
Bug 32010: Make sure the alert will be displayed after the ajax call
There is a missing wait_for_ajax call at after we click but wait_for_ajax
is waiting for the return of success, and the alert is there.

22:01:57 koha_1       | STRACE:	/usr/share/perl5/Try/Tiny.pm:123 in Selenium::Remote::Driver::catch {...}
22:01:57 koha_1       | 	/usr/share/perl5/Selenium/Remote/Driver.pm:361 in Try::Tiny::try
22:01:57 koha_1       | 	(eval 541):1 in Selenium::Remote::Driver::__ANON__
22:01:57 koha_1       | 	(eval 543):2 in Selenium::Remote::Driver::__ANON__
22:01:57 koha_1       | 	/usr/share/perl5/Selenium/Remote/Driver.pm:654 in Selenium::Remote::Driver::_execute_command
22:01:57 koha_1       | 	t/db_dependent/selenium/authentication_2fa.t:282 in Selenium::Remote::Driver::get_alert_text
22:01:57 koha_1       | 	/usr/share/perl/5.32/Test/Builder.pm:334 in main::__ANON__
22:01:57 koha_1       | 	/usr/share/perl/5.32/Test/Builder.pm:334 in (eval)
22:01:57 koha_1       | 	/usr/share/perl/5.32/Test/More.pm:809 in Test::Builder::subtest
22:01:57 koha_1       | 	t/db_dependent/selenium/authentication_2fa.t:291 in Test::More::subtest
22:01:57 koha_1       |
22:01:57 koha_1       |     # Looks like you planned 7 tests but ran 4.
22:01:57 koha_1       |
22:01:57 koha_1       | #   Failed test 'Enforce 2FA setup on first login'
22:01:57 koha_1       | #   at t/db_dependent/selenium/authentication_2fa.t line 291.
22:01:57 koha_1       | Error while executing command: no such alert at /usr/share/perl5/Selenium/Remote/Driver.pm line 411.
22:01:57 koha_1       |  at /usr/share/perl5/Selenium/Remote/Driver.pm line 356.
22:01:57 koha_1       | # Looks like your test exited with 255 just after 4.
22:01:57 koha_1       | [20:59:37] t/db_dependent/selenium/authentication_2fa.t

Test plan:
Confirm that the test pass (execute it in a loop, hundreds of times)
Confirm that the behaviour of 2FA "enforced" (see bug 30588) is still
working as expected.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-18 12:04:28 -03:00
ac041571c3
Bug 24606: (QA follow-up) Add test for encoding/decoding
NOTE: I have the impression that this unit test is quite
rudimentary. I do not see the apply function tested?

Test plan:
Run t/db_dependent/Koha/Item/Templates.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
tcohen amended: stray deps
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-18 12:04:27 -03:00
923609f42e
Bug 32267: (bug 32154 follow-up) Fix Agreements.t
#   Failed test at t/db_dependent/Koha/ERM/Agreements.t line 111.
    #     Structures begin differing at:
    #          $got->[0]{user_role_id} = '2'
    #     $expected->[0]{user_role_id} = Does not exist
    # Looks like you failed 1 test of 4.

Another fix may be better, please suggest if you disagree

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-18 12:04:25 -03:00
a922c8cc96
Bug 32242: Add selenium tests
This is not testing the thing at the correct level, but at least we test
the whole workflow.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-17 14:16:12 -03:00
32aceb32d4
Bug 32240: Prevent erm_users.t to fail if checkout exist
We should not (never) remove all patrons before tests

Test plan:
0. Don't apply the patch
1. Check an item out
2. Run the tests
=> Fail
3. Apply the patch
4. Create a patron with the erm permission
5. Run the tests
=> Must return green

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-17 13:39:44 -03:00
1736fe2335
Bug 31543: Use query string, rather than query, to build link
This patch returns the query string from build_query_compat
Under Zebra, either works for the link, for ES we need the simple string

I expand the test for get_components_query to test both engines

To test:
1.0) Set search engine to Elasticsearch
1.1) Go to Tools > Stage MARC records for import
1.2) Upload the example file
1.3) In the form, choose the format 'MARCXML'
1.4) Click 'Stage for import'
1.5) Click 'Manage staged records'
1.6) Click 'Import this batch into the catalog'

2) Change MaxComponentRecords to 10
3) In the staff interface, search the catalog for 'easy piano'
4) Click on the record 'Easy piano pieces for children'
5) Click on the 'show all component parts' link at the bottom of the Components tab
--> it searches for HASH(...) - returns no results
6) Try the same in OPAC
--> it searches for HASH(...) - returns no results
7) Apply patch and restart all
8) repeat 3-6
9) Results returned!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-16 15:57:28 -03:00
Agustin Moyano
937b7114d0
Bug 32178: (follow-up) Transform 'staff' interface to 'intranet'
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-15 18:43:50 -03:00
Agustin Moyano
ca57674700
Bug 32178: Remove security breach introduced in bug 31378
This patch removes a security breach in C4::Auth::check_api_auth introduced by bug 31378, where when someone called an api with the parameters userid and auth_client_login, check_api_auth would automatically asume the user calling was that userid.

This patch also introduces C4::Auth::create_basic_session(), a function that creates a session and adds the minimum basic parameters.

Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-15 18:43:45 -03:00
Emmi Takkinen
c7a995d28f
Bug 31447: Add unit tests
To test prove t/db_dependent/Circulation.t

Sponsored-by: Koha-Suomi Oy

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-14 09:25:10 -03:00
1d65a71cf6
Bug 24606: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-11 15:38:08 -03:00
2a79e3a00c
Bug 24606: (QA follow-up) borrowernumber => patron_id
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-10 14:39:35 -03:00
c5a3b14bf8
Bug 24606: Add Koha Object(s) with unit tests
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-10 14:25:11 -03:00
e4e453d5df
Bug 27920: Add ability to update patron expiration dates when importing patrons
Some libraries need to recalculate a patron's expiration date any time they are updated via a patron import from file.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Koha/Patrons/Import.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:37:07 -03:00
883b57b0dd
Bug 31896: (QA follow-up) Fix rollback
Yes, it should be the last statement.
Actually the preceding delete is unneeded.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:34:59 -03:00
0fb57fa56a
Bug 31896: (QA follow-up) Fix modules
Triggered by seeing Koha::Account. Copy and paste ;)
But a bunch of other modules should (at least formally) be there.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:34:54 -03:00
Stefan Berndtsson
2f6b597b08
Bug 31896: New after_recall_action hook
Hooks added:
after_recall_action with new action add

How to test:
Run tests in t/db_dependent/Koha/Plugins/Recall_hooks.t

Sponsored by: Gothenburg University Library

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT} Adding get_from_storage ;) For current consistency.
See further bug 32107.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:34:41 -03:00
296c84e0e8
Bug 26635: (follow-up) Rename av_expand to strings
This patch updates the `av_expand` occurences to `strings` to match the
change of the return structure of `_strings`.

We replace `+av_expand` in the headers with `+strings`, the expected
object method name from `api_av_mapping` to `api_strings_mapping` and
the internal hash key from `av_expand` to `strings`.

Test plan
1) Run the included unit tests.. all should still pass.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:01:02 -03:00
2a620f5f63
Bug 26635: (QA follow-up) Rename key _str to _strings
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:58 -03:00
35f8011088
Bug 26635: (QA follow-up) Remove test for x-koha-av-expand header
This patch updates the last remaining test that mentioned the now defunkt
x-koha-av-expand header.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:55 -03:00
7e3ab9fe08
Bug 26635: Move expand syntax to x-koha-embed
Instead of a global av-expand flag (through a header) this patch
proposes to allow specifying +av_expand at the x-koha-embed header
level. This allows a more fine-grained control on what objects get avs
expanded. e.g.:

GET /patrons/123
x-koha-expand: +av_expand,checkouts.item+av_expand
=>
{
    "_str": {
        "city": { "str": "Córdoba", ... }
    },
    ...
    "checkouts": [
        {
            ...,
            "item": {
                "_str": {
                    "not_for_loan_status": { "str": "Reference material", ... },
                    ...
                },
                ...
            }
        }
    ]
}

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Object.t \
           t/Koha/REST/Plugin/Query.t \
           t/db_dependent/Koha/REST/Plugin/Objects.t
=> SUCCESS: Tests pass!
2. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:51 -03:00
8dd24dab22
Bug 26635: Refined data structure and methods
This patch makes the returned data structure be simpler:

_str => {
    attribute_1 => {
        category => 'some_category_name',
        str      => 'description',
        type     => 'av'
    },
    ...
}

The description is sensible to context, so if public => 1 is passed,
then lib_opac is passed, and lib is returned otherwise. Whenever we add
language to the combo, we will add it to the implementation.

Tests are adjusted accordingly, also to reflect the public => 1 use
case.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Object.t \
           t/db_dependent/Koha/REST/Plugin/Objects.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:47 -03:00
15ee7885a3
Bug 26635: Add tests for av-expand => 0
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:39 -03:00
Agustin Moyano
3ce20d47b0
Bug 26635: Add tests
Add tests in t/db_dependent/Koha/Object.t and
t/db_dependent/Koha/REST/Plugin/Objects.t

Sponsored-by: Virginia Polytechnic Institute and State University
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 14:00:31 -03:00
4bdba2bdb6
Bug 31894: (QA follow-up) Move rollbacks to the end
Obvious fix. This test removed my method records.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-11-09 10:05:37 -03:00