Koha-clms/t/db_dependent
Julian Maurice ca5db9ffb7
Bug 38630: Make the REST API respect KohaOpacLanguage cookie
The REST API can return translated strings to the opac or staff
interface, so it should respect the KohaOpacLanguage cookie and return
translations in the same language than the interface.

Test plan:
1. Do not apply patch yet
2. Log in to koha staff interface
3. Use the browser's devtools to get the value of CGISESSID cookie
4. Make sure you have at least 2 languages installed ('en' + another
   one - I'll use 'fr-FR' as an example in this test plan)
5. Find an item and note its itemnumber and itemtype
6. Go translate this itemtype's description (admin » item types » edit
   item type » translate). Add a translation for 'en' and another one
   for your language.
7. Close your browser tab (do not logout) and restart Koha to flush the
   memory cache.
8. Execute the following commands (replace variables by the correct
   value):

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=en; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   If you do not have jq, it can be found in most distributions
   packages. Or you could inspect the JSON manually at the path
   /_strings/item_type_id/str

   Restart Koha again, and execute the same command but with your
   language set in KohaOpacLanguage cookie:

    curl -sSL "$KOHA_URL/api/v1/items/$ITEMNUMBER" \
        -H 'x-koha-embed: +strings' \
        -H "Cookie: KohaOpacLanguage=fr-FR; CGISESSID=$CGISESSID" \
        | jq -r '._strings.item_type_id.str'

   Depending on how Koha sort the languages (not sure how it's done),
   you should get either the 'en' one or the 'fr-FR' one, but the
   important thing is you should get the same translation, no matter
   what the value of KohaOpacLanguage is, which is the issue this patch
   is trying to fix.
9. Apply the patch and restart Koha
10. Repeat step 8. This time you should get the translation
    corresponding to the language set in KohaOpacLanguage cookie

Side note:
* The need to restart Koha before each request is due to a bug (see bug
  38454). If already pushed when you're testing this one, you don't have
  to restart.

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

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-30 18:05:24 +01:00
..
Acquisition Bug 38343: (QA follow-up) Improve tests and tidy 2024-11-22 10:22:40 +01:00
Auth Bug 36056: Clarify subpermissions AND behavior 2024-03-07 17:35:40 +01:00
AuthoritiesMarc
…
Authority Bug 36917: (follow-up) Add FIXME for marcflavour 2024-05-24 15:36:43 +02:00
Biblio Bug 33268: Add tests for context module priority 2025-01-10 17:59:42 +01:00
Budgets
…
Circulation Bug 33641: (follow-up) Fix unit tests 2024-11-15 14:02:20 +01:00
CourseReserves
…
Creators Bug 37720: (follow-up) Adjust tests 2024-10-18 12:07:52 +02:00
Exporter Bug 25503: Add failing test for _get_biblio_for_export 2023-05-10 15:26:19 -03:00
Holds Bug 36923: Remove warnings from Holds/LocalHoldsPriority.t 2024-05-24 15:36:46 +02:00
HoldsQueue Bug 35826: Add unit tests. 2024-04-26 18:06:18 +02:00
Items Bug 36010: Fix Items/AutomaticItemModificationByAge.t failing since Bug 32029 2024-03-07 16:36:46 +01:00
Koha Bug 38744: Add more missing txn 2025-01-24 12:02:17 +01:00
LDAP
…
Labels Bug 37898: Wrap labels tests inside transactions 2024-09-19 12:50:19 +01:00
Letters Bug 17976: Update test to include fines 2024-11-08 12:42:11 +01:00
Members Bug 33947: Remove GetAllIssues 2023-10-20 11:03:03 -03:00
OAI Bug 31224: Expand coded values using metadata_record in Server.pm 2024-11-07 16:29:24 +01:00
Patron Bug 37392: (follow-up) Limit a borrower not in a group and fix tests 2024-11-01 09:34:39 -03:00
Record Bug 33339: Prevent Formula Injection (CSV Injection) in CSV files 2024-11-14 10:46:31 +01:00
Reports Bug 37508: (QA follow-up) Use ->check_columns 2024-08-16 16:22:26 +02:00
Reserves Bug 35959: Add missing use statements in tests 2024-07-08 17:49:19 +02:00
SIP Bug 38486: Fix unit tests 2024-12-20 18:33:21 +01:00
Search
…
Serials Bug 38011: Fix ReNewSubscription.t 2024-11-14 10:46:40 +01:00
Template/Plugin Bug 37684: Direct link to expired news are broken 2024-11-07 17:32:38 +01:00
Utils Bug 34913: Adjust C4::Utils::DataTables::VirtualShelves 2024-01-26 15:13:42 +01:00
api/v1 Bug 38630: Make the REST API respect KohaOpacLanguage cookie 2025-01-30 18:05:24 +01:00
cronjobs
…
data Bug 35418: Add TR_B2 tests 2023-11-29 17:36:11 -03:00
misc/translator
…
mojo Bug 36598: (QA follow-up): tidy up code 2024-10-18 12:07:50 +02:00
selenium Revert "Bug 36025: Selenium test for the query parameters" 2025-01-07 15:47:54 +01:00
www Bug 32693: Fix history.t 2024-05-08 18:23:57 +02:00
00-strict.t Bug 36999: Fix 00-strict.t fails to find koha_perl_deps.pl 2024-06-13 13:43:47 +01:00
Accounts.t Bug 34912: Add 14 hours to 1970 date in Account(s).t 2023-10-04 09:15:39 -04:00
Acquisition.t Bug 32132: (RM follow-up) Use testbuilder in Acquisitions.t 2024-04-24 10:08:28 +01:00
Amazon.t
…
ArticleRequests.t Bug 37392: (follow-up) Limit a borrower not in a group and fix tests 2024-11-01 09:34:39 -03:00
AudioAlerts.t
…
Auth.t Bug 37104: Unit tests 2024-07-01 18:55:52 +02:00
AuthUtils.t
…
Auth_with_cas.t
…
Auth_with_ldap.t Bug 38526: (bug 36822 follow-up): Improve datetime comparison in tests 2024-11-25 13:16:40 +01:00
Auth_with_shibboleth.t Bug 38526: (bug 36822 follow-up): Improve datetime comparison in tests 2024-11-25 13:16:40 +01:00
AuthorisedValues.t Bug 28869: Unit tests 2024-05-17 10:36:24 +02:00
AuthoritiesMarc.t Bug 35989: (QA follow-up): Fix QA tests 2024-06-06 15:18:43 +01:00
AuthoritiesMarc_GetTagsLabels.t
…
Barcodes.t Bug 37070: (QA follow-up) Fix qa script issues 2024-10-18 14:26:05 +02:00
Barcodes_ValueBuilder.t
…
Biblio.t Bug 37349: Unit tests 2024-11-25 13:16:39 +01:00
Biblio_holdsqueue.t
…
Breeding.t Bug 28166: (QA follow-up) Fix and tidy tests and code 2023-10-23 11:33:50 -03:00
Breeding_Auth.t Bug 33404: Add unit tests 2023-07-05 12:17:22 -03:00
Budgets.t Bug 31631: (QA follow-up) Tidy code 2023-10-18 15:41:37 -03:00
Cache.t
…
Calendar.t Bug 33727: (QA follow-up) perl tidy whole file 2023-07-14 12:14:37 -03:00
Charset.t
…
Circulation.t Bug 38505: CanBookBeIssued preparation: Add tests for falsy barcode 2025-01-10 19:19:28 +01:00
Circulation_holdsqueue.t Bug 32496: Reduce unnecessary unblessings of objects in Circulation.pm 2023-09-22 10:52:39 -03:00
ClassSources.t Bug 37870: Run tests from ClassSources.t within transactions 2024-09-12 13:52:35 +02:00
Clubs.t
…
Context.t Bug 32687: Get server version in Context::get_versions 2023-02-24 17:52:28 -03:00
Contract.t
…
CourseReserves.t Bug 36687: (RM follow-up) Fix unit tests 2024-05-09 09:22:00 +01:00
DecreaseLoanHighHolds.t Bug 32496: Reduce unnecessary unblessings of objects in Circulation.pm 2023-09-22 10:52:39 -03:00
Filter_MARC_ViewPolicy.t Bug 32648: Clear cache in Filter_MARC_ViewPolicy.t 2023-05-16 11:24:26 +02:00
Fines.t
…
FrameworkPlugin.t Bug 37146: Add tests 2024-08-01 17:26:37 +02:00
Heading.t Bug 33557: Add LinkerConsiderThesaurus system preference 2023-05-10 15:26:26 -03:00
Heading_MARC21.t Bug 33277: Do not search using thesaurus when linking non 6XX fields 2023-05-10 15:26:22 -03:00
Hold.t Bug 34032: (QA follow-up) Tidy code 2024-04-29 09:35:38 +02:00
Holds.t Bug 37868: Remove C4::Reserves::ToggleSuspend 2024-10-21 15:10:35 +02:00
HoldsQueue.t Bug 32565: (follow-up) Tidy 2024-04-30 14:32:07 +02:00
Holidays.t Bug 27249: Replace DateTime->now by dt_from_string 2023-10-17 14:45:34 -03:00
ILSDI_Services.t Bug 38233: Add regression tests 2024-10-29 16:14:35 +01:00
ImportBatch.t Bug 32804: (QA follow-up) Typo ahs and fix ImportBatch.t 2023-03-17 09:59:12 -03:00
ImportExportFramework.t
…
Installer.t
…
Items.t Bug 14907: Unit tests 2025-01-10 19:19:18 +01:00
Koha.t Bug 34812: Move subtests to db_dependent/Koha.t 2023-09-18 12:06:27 -03:00
Koha_Database.t Bug 36367: Remove schema_stack 2024-06-14 11:17:18 +01:00
Koha_Elasticsearch.t Bug 35138: Fix Koha_Elasticsearch.t 2024-04-30 12:00:59 +02:00
Koha_ExternalContent_OverDrive.t
…
Koha_MetadataRecord_Authority.t
…
Koha_Misc_Files.t
…
Languages.t Bug 38646: Update unit test for change 2025-01-10 19:19:17 +01:00
Letters.t Bug 38758: Add subtest to Letters.t 2024-12-23 13:36:24 +01:00
LibraryGroups.t
…
Linker_Default.t Bug 35125: Respect LinkerConsiderThesaurus in update_cache 2024-07-01 18:55:42 +02:00
Linker_FirstMatch.t
…
Log.t Bug 37522: Unit tests 2024-10-29 16:14:44 +01:00
MarcModificationTemplates.t Bug 24480: (follow-up) Adjust tests 2023-11-03 12:04:35 -03:00
Matcher.t Bug 33869: Move Matcher.t to t/db_dependent 2023-09-01 11:07:45 -03:00
Members.t Bug 37845: Remove C4::Members::DeleteExpiredOpacRegistrations 2024-10-21 15:10:31 +02:00
Message.t Bug 37757: (follow-up) Adjust existing tests 2024-09-13 16:16:01 -03:00
MungeMarcPrice.t
…
Overdues.t Bug 36128: (QA follow-up) Add regression test 2024-06-27 14:04:47 +02:00
Passwordrecovery.t
…
PatronLists.t Bug 32730: Add Patron Lists tab to patron details and circulation pages 2023-11-01 17:23:09 -03:00
Patroncards.t Bug 37898: Wrap Patroncards.t inside a transaction 2024-09-19 12:50:20 +01:00
Patrons.t Bug 36508: Unit tests 2024-04-30 14:32:04 +02:00
Prices.t Bug 34967: Move to db_dependent 2023-10-03 09:24:50 -04:00
Record.t Bug 14670: Fix tests and import 2024-11-14 10:46:37 +01:00
RecordProcessor_EmbedSeeFromHeadings.t
…
Reports.t
…
Reserves.t Bug 38777: Use branch reply to for HOLD messages 2025-01-07 15:47:52 +01:00
RotatingCollections.t
…
Search.t Bug 36924: Remove warning "Value not allowed for auto_incr itemnumber in Item" 2024-05-23 17:51:15 +02:00
Serials.t Bug 37476: Unit tests 2024-07-26 14:50:45 +01:00
Serials_2.t
…
Service.t
…
ShelfBrowser.t
…
Sitemapper.t Bug 36977: (QA follow-up) Adapt tests 2024-10-30 14:34:52 +01:00
SocialData.t Bug 33833: Move to db_dependent 2023-09-05 14:35:36 -03:00
StockRotationItems.t
…
StockRotationRotas.t
…
StockRotationStages.t
…
SuggestionEngine_ExplodedTerms.t
…
Suggestions.t Bug 38235: Unit tests 2024-11-12 17:50:18 +01:00
TablesSettings.t Bug 33484: Fix TablesSettings.t 2024-10-28 17:10:24 +01:00
Tags.t
…
Templates.t
…
TestBuilder.t Bug 28966: (QA follow-up) Fix failing unit tests 2023-07-26 15:41:12 -03:00
Upload.t
…
UsageStats.t Bug 38104: Always update when hea cronjob is run 2025-01-24 16:14:31 +01:00
Virtualshelves.t Bug 28965: (QA follow-up) Fix misc qa issues 2024-11-08 16:09:22 +01:00
XISBN.t
…
XSLT.t Bug 38100: Unit tests 2024-11-08 11:23:50 +01:00
check_kohastructure.t
…
check_sysprefs.t Bug 29948: Adjust sysprefs.sql 2024-05-13 16:24:17 +02:00
db_structure.t
…
rollingloans.t Bug 32496: Reduce unnecessary unblessings of objects in Circulation.pm 2023-09-22 10:52:39 -03:00
sysprefs.t Bug 36793: Unit test 2024-05-17 10:36:34 +02:00
yaml.t
…
zebra_config.pl
…