Bugzilla – Attachment 176087 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]
Bug 38461: Refactoring - mock_table_settings
Bug-38461-Refactoring---mocktablesettings.patch (text/plain), 9.44 KB, created by
Martin Renvoize (ashimema)
on 2025-01-02 16:18:54 UTC
(
hide
)
Description:
Bug 38461: Refactoring - mock_table_settings
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-01-02 16:18:54 UTC
Size:
9.44 KB
patch
obsolete
>From 883db08fe93b03dd5062e59ab3f93511838ec55b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Nov 2024 17:06:51 +0100 >Subject: [PATCH] Bug 38461: Refactoring - mock_table_settings > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/cypress/integration/KohaTable_spec.ts | 126 +++++++++++++----------- > 1 file changed, 71 insertions(+), 55 deletions(-) > >diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts >index 71bfdafffe4..eef837c0cf9 100644 >--- a/t/cypress/integration/KohaTable_spec.ts >+++ b/t/cypress/integration/KohaTable_spec.ts >@@ -21,6 +21,35 @@ function build_libraries() { > }); > }); > } >+ >+function mock_table_settings(settings) { >+ cy.window().then(win => { >+ win.table_settings.columns = win.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; >+ } >+ if (settings && settings.hasOwnProperty("default_save_state_search")) { >+ win.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( >+ cc => cc.columnname == name >+ ); >+ Object.entries(values).forEach(([prop, value]) => { >+ column[prop] = value; >+ }); >+ }); >+ } >+ cy.wrap(win.table_settings.columns).as("columns"); >+ }); >+} > describe("kohaTable (using REST API)", () => { > beforeEach(() => { > cy.login(); >@@ -77,13 +106,11 @@ describe("kohaTable (using REST API)", () => { > build_libraries().then(() => { > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >+ mock_table_settings(); >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length >+ columns.length > ); > }); > }); >@@ -93,22 +120,19 @@ describe("kohaTable (using REST API)", () => { > build_libraries().then(() => { > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >- win.table_settings.columns.find( >- c => c.columnname == "library_code" >- ).is_hidden = 1; >+ mock_table_settings({ >+ columns: { library_code: { is_hidden: 1 } }, >+ }); >+ >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length - 1 >+ columns.length - 1 > ); >- cy.get(`#${table_id} th`).contains("Name"); >- cy.get(`#${table_id} th`) >- .contains("Code") >- .should("not.exist"); > }); >+ >+ cy.get(`#${table_id} th`).contains("Name"); >+ cy.get(`#${table_id} th`).contains("Code").should("not.exist"); > }); > }); > >@@ -116,17 +140,15 @@ describe("kohaTable (using REST API)", () => { > build_libraries().then(() => { > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.default_save_state = 0; >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >- win.table_settings.columns.find( >- c => c.columnname == "library_code" >- ).is_hidden = 1; >+ mock_table_settings({ >+ default_save_state: 0, >+ columns: { library_code: { is_hidden: 1 } }, >+ }); >+ >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length - 1 >+ columns.length - 1 > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`) >@@ -138,7 +160,7 @@ describe("kohaTable (using REST API)", () => { > .click(); > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length >+ columns.length > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`).contains("Code"); >@@ -146,17 +168,15 @@ describe("kohaTable (using REST API)", () => { > > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.default_save_state = 0; >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >- win.table_settings.columns.find( >- c => c.columnname == "library_code" >- ).is_hidden = 1; >+ mock_table_settings({ >+ default_save_state: 0, >+ columns: { library_code: { is_hidden: 1 } }, >+ }); >+ >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length >+ columns.length > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`) >@@ -170,17 +190,15 @@ describe("kohaTable (using REST API)", () => { > build_libraries().then(() => { > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.default_save_state = 1; >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >- win.table_settings.columns.find( >- c => c.columnname == "library_code" >- ).is_hidden = 1; >+ mock_table_settings({ >+ default_save_state: 1, >+ columns: { library_code: { is_hidden: 1 } }, >+ }); >+ >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length - 1 >+ columns.length - 1 > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`) >@@ -192,7 +210,7 @@ describe("kohaTable (using REST API)", () => { > .click(); > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length >+ columns.length > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`).contains("Code"); >@@ -200,17 +218,15 @@ describe("kohaTable (using REST API)", () => { > > cy.visit("/cgi-bin/koha/admin/branches.pl"); > >- cy.window().then(win => { >- win.table_settings.default_save_state = 1; >- win.table_settings.columns = win.table_settings.columns.map( >- c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) >- ); >- win.table_settings.columns.find( >- c => c.columnname == "library_code" >- ).is_hidden = 1; >+ mock_table_settings({ >+ default_save_state: 1, >+ columns: { library_code: { is_hidden: 1 } }, >+ }); >+ >+ cy.get("@columns").then(columns => { > cy.get(`#${table_id} th`).should( > "have.length", >- win.table_settings.columns.length >+ columns.length > ); > cy.get(`#${table_id} th`).contains("Name"); > cy.get(`#${table_id} th`).contains("Code"); >-- >2.47.1
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