Bugzilla – Attachment 182697 Details for
Bug 38461
Table features needs to be covered by e2e tests using Cypress
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[24.11.x] Bug 38461: (follow-up) Fix tests
2411x-Bug-38461-follow-up-Fix-tests.patch (text/plain), 3.92 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-05-21 16:30:40 UTC
(
hide
)
Description:
[24.11.x] Bug 38461: (follow-up) Fix tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-05-21 16:30:40 UTC
Size:
3.92 KB
patch
obsolete
>From 950d40ab6d5d6be8cdf1436d230ac948e92bead9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 21 May 2025 13:24:16 -0300 >Subject: [PATCH] [24.11.x] Bug 38461: (follow-up) Fix tests > >This patch does two things: > >* Fixes a backport issue with 38461, making `mock_table_settings` have > the right function signature, and accept (and use) the > `table_settings_var` parameter. >* Makes the scope for the `items_table_settings` variable be the window > object, so it is accessible to Cypress for manipulation/mocking. This > is done by changing `let` for `var` [1] > >To test: >1. Run: > $ ktd --shell > k$ run_cypress --spec t/cypress/integration/KohaTable_spec.ts >=> FAIL: Tests fail! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Sign off :-D > >[1] If you are curious about it, change it back to `let` and run the >tests. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../tables/items/catalogue_detail.inc | 2 +- > t/cypress/integration/KohaTable_spec.ts | 20 +++++++++++++------ > 2 files changed, 15 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >index 33117e6cf91..4e82a829656 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >@@ -270,7 +270,7 @@ > embed.push('analytics_count'); > [% END %] > >- let items_table_settings = { >+ var items_table_settings = { > holdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %], > otherholdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json') | $raw %], > }; >diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts >index 009f9ae15d9..6ef44095d73 100644 >--- a/t/cypress/integration/KohaTable_spec.ts >+++ b/t/cypress/integration/KohaTable_spec.ts >@@ -22,24 +22,32 @@ function build_libraries() { > }); > } > >-function mock_table_settings(settings) { >+function mock_table_settings(settings, table_settings_var) { > cy.window().then(win => { >- win.table_settings.columns = win.table_settings.columns.map(c => ({ >+ >+ let table_settings = >+ typeof table_settings_var === "undefined" >+ ? win.table_settings >+ : table_settings_var >+ .split(".") >+ .reduce((acc, key) => acc[key], win); >+ >+ table_settings.columns = table_settings.columns.map(c => ({ > ...c, > is_hidden: 0, > cannot_be_toggled: 0, > })); > if (settings && settings.hasOwnProperty("default_save_state")) { >- win.table_settings.default_save_state = settings.default_save_state; >+ table_settings.default_save_state = settings.default_save_state; > } > if (settings && settings.hasOwnProperty("default_save_state_search")) { >- win.table_settings.default_save_state_search = >+ table_settings.default_save_state_search = > settings.default_save_state_search; > } > > if (settings && settings.columns) { > Object.entries(settings.columns).forEach(([name, values]) => { >- let column = win.table_settings.columns.find( >+ let column = table_settings.columns.find( > cc => cc.columnname == name > ); > Object.entries(values).forEach(([prop, value]) => { >@@ -47,7 +55,7 @@ function mock_table_settings(settings) { > }); > }); > } >- cy.wrap(win.table_settings.columns).as("columns"); >+ cy.wrap(table_settings.columns).as("columns"); > }); > } > describe("kohaTable (using REST API)", () => { >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38461
:
174877
|
174878
|
175004
|
175005
|
175006
|
175007
|
175008
|
175009
|
175010
|
175011
|
175015
|
175016
|
175179
|
175223
|
175224
|
175225
|
175226
|
175227
|
175228
|
175229
|
175230
|
175231
|
175232
|
175233
|
175234
|
175235
|
175289
|
175290
|
175291
|
175292
|
176082
|
176083
|
176084
|
176085
|
176086
|
176087
|
176088
|
176089
|
176090
|
176091
|
176092
|
176093
|
176793
|
176846
|
176902
| 182697