View | Details | Raw Unified | Return to bug 39315
Collapse All | Expand All

(-)a/t/cypress/integration/KohaTable/Holdings_spec.ts (+292 lines)
Line 0 Link Here
1
const RESTdefaultPageSize = "20"; // FIXME Mock this
2
const baseTotalCount = "42";
3
4
describe("catalogue/detail/holdings_table", () => {
5
    const table_id = "holdings_table";
6
    beforeEach(() => {
7
        cy.login();
8
        cy.title().should("eq", "Koha staff interface");
9
        cy.window().then(win => {
10
            win.localStorage.clear();
11
        });
12
13
        // FIXME All the following code should not be reused as it
14
        // It must be moved to a Cypress command or task "buildSampleBiblio" or even "insertSampleBiblio"
15
        let generated_objects = {};
16
        const objects = [{ object: "library" }, { object: "item_type" }];
17
        cy.wrap(Promise.resolve())
18
            .then(() => {
19
                return objects.reduce((chain, { object }) => {
20
                    return chain.then(() => {
21
                        return cy
22
                            .task("buildSampleObject", { object })
23
                            .then(attributes => {
24
                                generated_objects[object] = attributes;
25
                            });
26
                    });
27
                }, Promise.resolve());
28
            })
29
            .then(() => {
30
                const library = generated_objects["library"];
31
                const item_type = generated_objects["item_type"];
32
                const queries = [
33
                    {
34
                        query: "INSERT INTO branches(branchcode, branchname) VALUES (?, ?)",
35
                        values: [library.library_id, library.name],
36
                    },
37
                    {
38
                        query: "INSERT INTO itemtypes(itemtype, description) VALUES (?, ?)",
39
                        values: [item_type.item_type_id, item_type.description],
40
                    },
41
                ];
42
                cy.wrap(Promise.resolve())
43
                    .then(() => {
44
                        return queries.reduce((chain, { query, values }) => {
45
                            return chain.then(() => cy.query(query, values));
46
                        }, Promise.resolve());
47
                    })
48
                    .then(() => {
49
                        let biblio = {
50
                            leader: "     nam a22     7a 4500",
51
                            fields: [
52
                                { "005": "20250120101920.0" },
53
                                {
54
                                    "245": {
55
                                        ind1: "",
56
                                        ind2: "",
57
                                        subfields: [{ a: "Some boring read" }],
58
                                    },
59
                                },
60
                                {
61
                                    "100": {
62
                                        ind1: "",
63
                                        ind2: "",
64
                                        subfields: [
65
                                            { c: "Some boring author" },
66
                                        ],
67
                                    },
68
                                },
69
                                {
70
                                    "942": {
71
                                        ind1: "",
72
                                        ind2: "",
73
                                        subfields: [
74
                                            { c: item_type.item_type_id },
75
                                        ],
76
                                    },
77
                                },
78
                            ],
79
                        };
80
                        cy.request({
81
                            method: "POST",
82
                            url: "/api/v1/biblios",
83
                            headers: {
84
                                "Content-Type": "application/marc-in-json",
85
                                "x-confirm-not-duplicate": 1,
86
                            },
87
                            body: biblio,
88
                        }).then(response => {
89
                            const biblio_id = response.body.id;
90
                            cy.wrap(biblio_id).as("biblio_id");
91
                            cy.request({
92
                                method: "POST",
93
                                url: `/api/v1/biblios/${biblio_id}/items`,
94
                                headers: {
95
                                    "Content-Type": "application/json",
96
                                },
97
                                body: {
98
                                    home_library_id: library.library_id,
99
                                    holding_library_id: library.library_id,
100
                                },
101
                            });
102
                        });
103
                    });
104
            });
105
        cy.query(
106
            "SELECT value FROM systempreferences WHERE variable='AlwaysShowHoldingsTableFilters'"
107
        ).then(value => {
108
            cy.wrap(value).as("syspref_AlwaysShowHoldingsTableFilters");
109
        });
110
    });
111
112
    afterEach(
113
        () =>
114
            function () {
115
                cleanup();
116
                cy.set_syspref(
117
                    "AlwaysShowHoldingsTableFilters",
118
                    this.syspref_AlwaysShowHoldingsTableFilters
119
                );
120
            }
121
    );
122
123
    it("Correctly init the table", function () {
124
        // Do not use `() => {` or this.biblio_id won't be retrieved
125
        const biblio_id = this.biblio_id;
126
        cy.task("buildSampleObjects", {
127
            object: "item",
128
            count: RESTdefaultPageSize,
129
            values: {
130
                biblio_id,
131
                checkout: null,
132
                transfer: null,
133
                lost_status: 0,
134
                withdrawn: 0,
135
                damaged_status: 0,
136
                not_for_loan_status: 0,
137
                course_item: null,
138
                cover_image_ids: [],
139
            },
140
        }).then(items => {
141
            cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, {
142
                statuscode: 200,
143
                body: items,
144
                headers: {
145
                    "X-Base-Total-Count": baseTotalCount,
146
                    "X-Total-Count": baseTotalCount,
147
                },
148
            });
149
150
            cy.visit(
151
                "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + biblio_id
152
            );
153
154
            cy.window().then(win => {
155
                win.libraries_map = items.reduce((map, i) => {
156
                    map[i.library_id] = i.library_id;
157
                    return map;
158
                }, {});
159
            });
160
161
            cy.get(`#${table_id}_wrapper tbody tr`).should(
162
                "have.length",
163
                RESTdefaultPageSize
164
            );
165
166
            cy.get(`#${table_id}_wrapper .dt-info`).contains(
167
                `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
168
            );
169
        });
170
    });
171
172
    it("Show filters", function () {
173
        // Do not use `() => {` or this.biblio_id won't be retrieved
174
        const biblio_id = this.biblio_id;
175
        cy.task("buildSampleObjects", {
176
            object: "item",
177
            count: RESTdefaultPageSize,
178
            values: {
179
                biblio_id,
180
                checkout: null,
181
                transfer: null,
182
                lost_status: 0,
183
                withdrawn: 0,
184
                damaged_status: 0,
185
                not_for_loan_status: 0,
186
                course_item: null,
187
                cover_image_ids: [],
188
            },
189
        }).then(items => {
190
            cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, {
191
                statuscode: 200,
192
                body: items,
193
                headers: {
194
                    "X-Base-Total-Count": baseTotalCount,
195
                    "X-Total-Count": baseTotalCount,
196
                },
197
            });
198
199
            cy.set_syspref("AlwaysShowHoldingsTableFilters", 0).then(() => {
200
                cy.visit(
201
                    "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
202
                        biblio_id
203
                );
204
205
                // Hide the 'URL' column
206
                cy.mock_table_settings(
207
                    {
208
                        columns: { uri: { is_hidden: 1 } },
209
                    },
210
                    "items_table_settings.holdings"
211
                );
212
213
                cy.window().then(win => {
214
                    win.libraries_map = items.reduce((map, i) => {
215
                        map[i.library_id] = i.library_id;
216
                        return map;
217
                    }, {});
218
                });
219
220
                cy.get("@columns").then(columns => {
221
                    cy.get(`#${table_id}_wrapper tbody tr`).should(
222
                        "have.length",
223
                        RESTdefaultPageSize
224
                    );
225
226
                    // Filters are not displayed
227
                    cy.get(`#${table_id} thead tr`).should("have.length", 1);
228
229
                    cy.get(`#${table_id} th`).contains("Status");
230
                    cy.get(`#${table_id} th`)
231
                        .contains("URL")
232
                        .should("not.exist");
233
                    cy.get(`#${table_id} th`)
234
                        .contains("Course reserves")
235
                        .should("not.exist");
236
237
                    cy.get(".show_filters").click();
238
                    cy.get(`#${table_id}_wrapper .dt-info`).contains(
239
                        `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
240
                    );
241
                    // Filters are displayed
242
                    cy.get(`#${table_id} thead tr`).should("have.length", 2);
243
244
                    cy.get(`#${table_id} th`).contains("Status");
245
                    cy.get(`#${table_id} th`)
246
                        .contains("URL")
247
                        .should("not.exist");
248
                    cy.get(`#${table_id} th`)
249
                        .contains("Course reserves")
250
                        .should("not.exist");
251
                });
252
            });
253
254
            cy.set_syspref("AlwaysShowHoldingsTableFilters", 1).then(() => {
255
                cy.visit(
256
                    "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
257
                        biblio_id
258
                );
259
260
                // Hide the 'URL' column
261
                cy.mock_table_settings(
262
                    {
263
                        columns: { uri: { is_hidden: 1 } },
264
                    },
265
                    "items_table_settings.holdings"
266
                );
267
268
                cy.window().then(win => {
269
                    win.libraries_map = items.reduce((map, i) => {
270
                        map[i.library_id] = i.library_id;
271
                        return map;
272
                    }, {});
273
                });
274
275
                cy.get("@columns").then(columns => {
276
                    cy.get(`#${table_id}_wrapper tbody tr`).should(
277
                        "have.length",
278
                        RESTdefaultPageSize
279
                    );
280
281
                    // Filters are displayed
282
                    cy.get(`#${table_id} thead tr`).should("have.length", 2);
283
284
                    cy.get(".hide_filters").click();
285
286
                    // Filters are not displayed
287
                    cy.get(`#${table_id} thead tr`).should("have.length", 1);
288
                });
289
            });
290
        });
291
    });
292
});
(-)a/t/cypress/integration/KohaTable/KohaTable_spec.ts (-360 / +7 lines)
Lines 22-63 function build_libraries() { Link Here
22
        });
22
        });
23
}
23
}
24
24
25
function mock_table_settings(settings, table_settings_var) {
26
    cy.window().then(win => {
27
        let table_settings =
28
            typeof table_settings_var === "undefined"
29
                ? win.table_settings
30
                : table_settings_var
31
                      .split(".")
32
                      .reduce((acc, key) => acc[key], win);
33
34
        table_settings.columns = table_settings.columns.map(c => ({
35
            ...c,
36
            is_hidden: 0,
37
            cannot_be_toggled: 0,
38
        }));
39
        if (settings && settings.hasOwnProperty("default_save_state")) {
40
            table_settings.default_save_state = settings.default_save_state;
41
        }
42
        if (settings && settings.hasOwnProperty("default_save_state_search")) {
43
            table_settings.default_save_state_search =
44
                settings.default_save_state_search;
45
        }
46
47
        if (settings && settings.columns) {
48
            Object.entries(settings.columns).forEach(([name, values]) => {
49
                let column = table_settings.columns.find(
50
                    cc => cc.columnname == name
51
                );
52
                Object.entries(values).forEach(([prop, value]) => {
53
                    column[prop] = value;
54
                });
55
            });
56
        }
57
        cy.wrap(table_settings.columns).as("columns");
58
    });
59
}
60
61
describe("kohaTable (using REST API)", () => {
25
describe("kohaTable (using REST API)", () => {
62
    beforeEach(() => {
26
    beforeEach(() => {
63
        cy.login();
27
        cy.login();
Lines 114-120 describe("kohaTable (using REST API)", () => { Link Here
114
            build_libraries().then(() => {
78
            build_libraries().then(() => {
115
                cy.visit("/cgi-bin/koha/admin/branches.pl");
79
                cy.visit("/cgi-bin/koha/admin/branches.pl");
116
80
117
                mock_table_settings();
81
                cy.mock_table_settings();
118
                cy.get("@columns").then(columns => {
82
                cy.get("@columns").then(columns => {
119
                    cy.get(`#${table_id} th`).should(
83
                    cy.get(`#${table_id} th`).should(
120
                        "have.length",
84
                        "have.length",
Lines 128-134 describe("kohaTable (using REST API)", () => { Link Here
128
            build_libraries().then(() => {
92
            build_libraries().then(() => {
129
                cy.visit("/cgi-bin/koha/admin/branches.pl");
93
                cy.visit("/cgi-bin/koha/admin/branches.pl");
130
94
131
                mock_table_settings({
95
                cy.mock_table_settings({
132
                    columns: { library_code: { is_hidden: 1 } },
96
                    columns: { library_code: { is_hidden: 1 } },
133
                });
97
                });
134
98
Lines 148-154 describe("kohaTable (using REST API)", () => { Link Here
148
            build_libraries().then(() => {
112
            build_libraries().then(() => {
149
                cy.visit("/cgi-bin/koha/admin/branches.pl");
113
                cy.visit("/cgi-bin/koha/admin/branches.pl");
150
114
151
                mock_table_settings({
115
                cy.mock_table_settings({
152
                    default_save_state: 0,
116
                    default_save_state: 0,
153
                    columns: { library_code: { is_hidden: 1 } },
117
                    columns: { library_code: { is_hidden: 1 } },
154
                });
118
                });
Lines 176-182 describe("kohaTable (using REST API)", () => { Link Here
176
140
177
                cy.visit("/cgi-bin/koha/admin/branches.pl");
141
                cy.visit("/cgi-bin/koha/admin/branches.pl");
178
142
179
                mock_table_settings({
143
                cy.mock_table_settings({
180
                    default_save_state: 0,
144
                    default_save_state: 0,
181
                    columns: { library_code: { is_hidden: 1 } },
145
                    columns: { library_code: { is_hidden: 1 } },
182
                });
146
                });
Lines 198-204 describe("kohaTable (using REST API)", () => { Link Here
198
            build_libraries().then(() => {
162
            build_libraries().then(() => {
199
                cy.visit("/cgi-bin/koha/admin/branches.pl");
163
                cy.visit("/cgi-bin/koha/admin/branches.pl");
200
164
201
                mock_table_settings({
165
                cy.mock_table_settings({
202
                    default_save_state: 1,
166
                    default_save_state: 1,
203
                    columns: { library_code: { is_hidden: 1 } },
167
                    columns: { library_code: { is_hidden: 1 } },
204
                });
168
                });
Lines 226-232 describe("kohaTable (using REST API)", () => { Link Here
226
190
227
                cy.visit("/cgi-bin/koha/admin/branches.pl");
191
                cy.visit("/cgi-bin/koha/admin/branches.pl");
228
192
229
                mock_table_settings({
193
                cy.mock_table_settings({
230
                    default_save_state: 1,
194
                    default_save_state: 1,
231
                    columns: { library_code: { is_hidden: 1 } },
195
                    columns: { library_code: { is_hidden: 1 } },
232
                });
196
                });
Lines 246-252 describe("kohaTable (using REST API)", () => { Link Here
246
            build_libraries().then(() => {
210
            build_libraries().then(() => {
247
                cy.visit("/cgi-bin/koha/admin/branches.pl");
211
                cy.visit("/cgi-bin/koha/admin/branches.pl");
248
212
249
                mock_table_settings({
213
                cy.mock_table_settings({
250
                    default_save_state: 1,
214
                    default_save_state: 1,
251
                    columns: { library_code: { is_hidden: 1 } },
215
                    columns: { library_code: { is_hidden: 1 } },
252
                });
216
                });
Lines 476-795 describe("ERM ", () => { Link Here
476
        });
440
        });
477
    });
441
    });
478
});
442
});
479
480
describe("Hit all tables", () => {
481
    beforeEach(() => {
482
        cy.login();
483
        cy.title().should("eq", "Koha staff interface");
484
        cy.window().then(win => {
485
            win.localStorage.clear();
486
        });
487
    });
488
489
    describe("catalogue/detail/holdings_table", () => {
490
        const table_id = "holdings_table";
491
        beforeEach(() => {
492
            // FIXME All the following code should not be reused as it
493
            // It must be moved to a Cypress command or task "buildSampleBiblio" or even "insertSampleBiblio"
494
            let generated_objects = {};
495
            const objects = [{ object: "library" }, { object: "item_type" }];
496
            cy.wrap(Promise.resolve())
497
                .then(() => {
498
                    return objects.reduce((chain, { object }) => {
499
                        return chain.then(() => {
500
                            return cy
501
                                .task("buildSampleObject", { object })
502
                                .then(attributes => {
503
                                    generated_objects[object] = attributes;
504
                                });
505
                        });
506
                    }, Promise.resolve());
507
                })
508
                .then(() => {
509
                    const library = generated_objects["library"];
510
                    const item_type = generated_objects["item_type"];
511
                    const queries = [
512
                        {
513
                            query: "INSERT INTO branches(branchcode, branchname) VALUES (?, ?)",
514
                            values: [library.library_id, library.name],
515
                        },
516
                        {
517
                            query: "INSERT INTO itemtypes(itemtype, description) VALUES (?, ?)",
518
                            values: [
519
                                item_type.item_type_id,
520
                                item_type.description,
521
                            ],
522
                        },
523
                    ];
524
                    cy.wrap(Promise.resolve())
525
                        .then(() => {
526
                            return queries.reduce(
527
                                (chain, { query, values }) => {
528
                                    return chain.then(() =>
529
                                        cy.query(query, values)
530
                                    );
531
                                },
532
                                Promise.resolve()
533
                            );
534
                        })
535
                        .then(() => {
536
                            let biblio = {
537
                                leader: "     nam a22     7a 4500",
538
                                fields: [
539
                                    { "005": "20250120101920.0" },
540
                                    {
541
                                        "245": {
542
                                            ind1: "",
543
                                            ind2: "",
544
                                            subfields: [
545
                                                { a: "Some boring read" },
546
                                            ],
547
                                        },
548
                                    },
549
                                    {
550
                                        "100": {
551
                                            ind1: "",
552
                                            ind2: "",
553
                                            subfields: [
554
                                                { c: "Some boring author" },
555
                                            ],
556
                                        },
557
                                    },
558
                                    {
559
                                        "942": {
560
                                            ind1: "",
561
                                            ind2: "",
562
                                            subfields: [
563
                                                { c: item_type.item_type_id },
564
                                            ],
565
                                        },
566
                                    },
567
                                ],
568
                            };
569
                            cy.request({
570
                                method: "POST",
571
                                url: "/api/v1/biblios",
572
                                headers: {
573
                                    "Content-Type": "application/marc-in-json",
574
                                    "x-confirm-not-duplicate": 1,
575
                                },
576
                                body: biblio,
577
                            }).then(response => {
578
                                const biblio_id = response.body.id;
579
                                cy.wrap(biblio_id).as("biblio_id");
580
                                cy.request({
581
                                    method: "POST",
582
                                    url: `/api/v1/biblios/${biblio_id}/items`,
583
                                    headers: {
584
                                        "Content-Type": "application/json",
585
                                    },
586
                                    body: {
587
                                        home_library_id: library.library_id,
588
                                        holding_library_id: library.library_id,
589
                                    },
590
                                });
591
                            });
592
                        });
593
                });
594
            cy.query(
595
                "SELECT value FROM systempreferences WHERE variable='AlwaysShowHoldingsTableFilters'"
596
            ).then(value => {
597
                cy.wrap(value).as("syspref_AlwaysShowHoldingsTableFilters");
598
            });
599
        });
600
601
        afterEach(
602
            () =>
603
                function () {
604
                    cleanup();
605
                    cy.set_syspref(
606
                        "AlwaysShowHoldingsTableFilters",
607
                        this.syspref_AlwaysShowHoldingsTableFilters
608
                    );
609
                }
610
        );
611
612
        it("Correctly init the table", function () {
613
            // Do not use `() => {` or this.biblio_id won't be retrieved
614
            const biblio_id = this.biblio_id;
615
            cy.task("buildSampleObjects", {
616
                object: "item",
617
                count: RESTdefaultPageSize,
618
                values: {
619
                    biblio_id,
620
                    checkout: null,
621
                    transfer: null,
622
                    lost_status: 0,
623
                    withdrawn: 0,
624
                    damaged_status: 0,
625
                    not_for_loan_status: 0,
626
                    course_item: null,
627
                    cover_image_ids: [],
628
                },
629
            }).then(items => {
630
                cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, {
631
                    statuscode: 200,
632
                    body: items,
633
                    headers: {
634
                        "X-Base-Total-Count": baseTotalCount,
635
                        "X-Total-Count": baseTotalCount,
636
                    },
637
                });
638
639
                cy.visit(
640
                    "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
641
                        biblio_id
642
                );
643
644
                cy.window().then(win => {
645
                    win.libraries_map = items.reduce((map, i) => {
646
                        map[i.library_id] = i.library_id;
647
                        return map;
648
                    }, {});
649
                });
650
651
                cy.get(`#${table_id}_wrapper tbody tr`).should(
652
                    "have.length",
653
                    RESTdefaultPageSize
654
                );
655
656
                cy.get(`#${table_id}_wrapper .dt-info`).contains(
657
                    `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
658
                );
659
            });
660
        });
661
662
        it("Show filters", function () {
663
            // Do not use `() => {` or this.biblio_id won't be retrieved
664
            const biblio_id = this.biblio_id;
665
            cy.task("buildSampleObjects", {
666
                object: "item",
667
                count: RESTdefaultPageSize,
668
                values: {
669
                    biblio_id,
670
                    checkout: null,
671
                    transfer: null,
672
                    lost_status: 0,
673
                    withdrawn: 0,
674
                    damaged_status: 0,
675
                    not_for_loan_status: 0,
676
                    course_item: null,
677
                    cover_image_ids: [],
678
                },
679
            }).then(items => {
680
                cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, {
681
                    statuscode: 200,
682
                    body: items,
683
                    headers: {
684
                        "X-Base-Total-Count": baseTotalCount,
685
                        "X-Total-Count": baseTotalCount,
686
                    },
687
                });
688
689
                cy.set_syspref("AlwaysShowHoldingsTableFilters", 0).then(() => {
690
                    cy.visit(
691
                        "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
692
                            biblio_id
693
                    );
694
695
                    // Hide the 'URL' column
696
                    mock_table_settings(
697
                        {
698
                            columns: { uri: { is_hidden: 1 } },
699
                        },
700
                        "items_table_settings.holdings"
701
                    );
702
703
                    cy.window().then(win => {
704
                        win.libraries_map = items.reduce((map, i) => {
705
                            map[i.library_id] = i.library_id;
706
                            return map;
707
                        }, {});
708
                    });
709
710
                    cy.get("@columns").then(columns => {
711
                        cy.get(`#${table_id}_wrapper tbody tr`).should(
712
                            "have.length",
713
                            RESTdefaultPageSize
714
                        );
715
716
                        // Filters are not displayed
717
                        cy.get(`#${table_id} thead tr`).should(
718
                            "have.length",
719
                            1
720
                        );
721
722
                        cy.get(`#${table_id} th`).contains("Status");
723
                        cy.get(`#${table_id} th`)
724
                            .contains("URL")
725
                            .should("not.exist");
726
                        cy.get(`#${table_id} th`)
727
                            .contains("Course reserves")
728
                            .should("not.exist");
729
730
                        cy.get(".show_filters").click();
731
                        cy.get(`#${table_id}_wrapper .dt-info`).contains(
732
                            `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
733
                        );
734
                        // Filters are displayed
735
                        cy.get(`#${table_id} thead tr`).should(
736
                            "have.length",
737
                            2
738
                        );
739
740
                        cy.get(`#${table_id} th`).contains("Status");
741
                        cy.get(`#${table_id} th`)
742
                            .contains("URL")
743
                            .should("not.exist");
744
                        cy.get(`#${table_id} th`)
745
                            .contains("Course reserves")
746
                            .should("not.exist");
747
                    });
748
                });
749
750
                cy.set_syspref("AlwaysShowHoldingsTableFilters", 1).then(() => {
751
                    cy.visit(
752
                        "/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
753
                            biblio_id
754
                    );
755
756
                    // Hide the 'URL' column
757
                    mock_table_settings(
758
                        {
759
                            columns: { uri: { is_hidden: 1 } },
760
                        },
761
                        "items_table_settings.holdings"
762
                    );
763
764
                    cy.window().then(win => {
765
                        win.libraries_map = items.reduce((map, i) => {
766
                            map[i.library_id] = i.library_id;
767
                            return map;
768
                        }, {});
769
                    });
770
771
                    cy.get("@columns").then(columns => {
772
                        cy.get(`#${table_id}_wrapper tbody tr`).should(
773
                            "have.length",
774
                            RESTdefaultPageSize
775
                        );
776
777
                        // Filters are displayed
778
                        cy.get(`#${table_id} thead tr`).should(
779
                            "have.length",
780
                            2
781
                        );
782
783
                        cy.get(".hide_filters").click();
784
785
                        // Filters are not displayed
786
                        cy.get(`#${table_id} thead tr`).should(
787
                            "have.length",
788
                            1
789
                        );
790
                    });
791
                });
792
            });
793
        });
794
    });
795
});
(-)a/t/cypress/support/e2e.js (-1 / +36 lines)
Lines 1822-1824 Cypress.Commands.add("set_syspref", (variable, value) => { Link Here
1822
        return client.sysprefs.update(variable, value);
1822
        return client.sysprefs.update(variable, value);
1823
    });
1823
    });
1824
});
1824
});
1825
- 
1825
1826
Cypress.Commands.add("mock_table_settings", (settings, table_settings_var) => {
1827
    cy.window().then(win => {
1828
        let table_settings =
1829
            typeof table_settings_var === "undefined"
1830
                ? win.table_settings
1831
                : table_settings_var
1832
                      .split(".")
1833
                      .reduce((acc, key) => acc[key], win);
1834
1835
        table_settings.columns = table_settings.columns.map(c => ({
1836
            ...c,
1837
            is_hidden: 0,
1838
            cannot_be_toggled: 0,
1839
        }));
1840
        if (settings && settings.hasOwnProperty("default_save_state")) {
1841
            table_settings.default_save_state = settings.default_save_state;
1842
        }
1843
        if (settings && settings.hasOwnProperty("default_save_state_search")) {
1844
            table_settings.default_save_state_search =
1845
                settings.default_save_state_search;
1846
        }
1847
1848
        if (settings && settings.columns) {
1849
            Object.entries(settings.columns).forEach(([name, values]) => {
1850
                let column = table_settings.columns.find(
1851
                    cc => cc.columnname == name
1852
                );
1853
                Object.entries(values).forEach(([prop, value]) => {
1854
                    column[prop] = value;
1855
                });
1856
            });
1857
        }
1858
        cy.wrap(table_settings.columns).as("columns");
1859
    });
1860
});

Return to bug 39315