Lines 22-45
function build_libraries() {
Link Here
|
22 |
}); |
22 |
}); |
23 |
} |
23 |
} |
24 |
|
24 |
|
25 |
function mock_table_settings(settings) { |
25 |
function mock_table_settings(settings, table_settings_var) { |
26 |
cy.window().then(win => { |
26 |
cy.window().then(win => { |
27 |
win.table_settings.columns = win.table_settings.columns.map(c => ({ |
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 => ({ |
28 |
...c, |
35 |
...c, |
29 |
is_hidden: 0, |
36 |
is_hidden: 0, |
30 |
cannot_be_toggled: 0, |
37 |
cannot_be_toggled: 0, |
31 |
})); |
38 |
})); |
32 |
if (settings && settings.hasOwnProperty("default_save_state")) { |
39 |
if (settings && settings.hasOwnProperty("default_save_state")) { |
33 |
win.table_settings.default_save_state = settings.default_save_state; |
40 |
table_settings.default_save_state = settings.default_save_state; |
34 |
} |
41 |
} |
35 |
if (settings && settings.hasOwnProperty("default_save_state_search")) { |
42 |
if (settings && settings.hasOwnProperty("default_save_state_search")) { |
36 |
win.table_settings.default_save_state_search = |
43 |
table_settings.default_save_state_search = |
37 |
settings.default_save_state_search; |
44 |
settings.default_save_state_search; |
38 |
} |
45 |
} |
39 |
|
46 |
|
40 |
if (settings && settings.columns) { |
47 |
if (settings && settings.columns) { |
41 |
Object.entries(settings.columns).forEach(([name, values]) => { |
48 |
Object.entries(settings.columns).forEach(([name, values]) => { |
42 |
let column = win.table_settings.columns.find( |
49 |
let column = table_settings.columns.find( |
43 |
cc => cc.columnname == name |
50 |
cc => cc.columnname == name |
44 |
); |
51 |
); |
45 |
Object.entries(values).forEach(([prop, value]) => { |
52 |
Object.entries(values).forEach(([prop, value]) => { |
Lines 47-55
function mock_table_settings(settings) {
Link Here
|
47 |
}); |
54 |
}); |
48 |
}); |
55 |
}); |
49 |
} |
56 |
} |
50 |
cy.wrap(win.table_settings.columns).as("columns"); |
57 |
cy.wrap(table_settings.columns).as("columns"); |
51 |
}); |
58 |
}); |
52 |
} |
59 |
} |
|
|
60 |
|
53 |
describe("kohaTable (using REST API)", () => { |
61 |
describe("kohaTable (using REST API)", () => { |
54 |
beforeEach(() => { |
62 |
beforeEach(() => { |
55 |
cy.login(); |
63 |
cy.login(); |
Lines 528-532
describe("Hit all tables", () => {
Link Here
|
528 |
); |
536 |
); |
529 |
}); |
537 |
}); |
530 |
}); |
538 |
}); |
|
|
539 |
|
540 |
it("Show filters", () => { |
541 |
const biblio_id = 1; |
542 |
cy.task("buildSampleObjects", { |
543 |
object: "item", |
544 |
count: RESTdefaultPageSize, |
545 |
values: { |
546 |
biblio_id, |
547 |
checkout: null, |
548 |
transfer: null, |
549 |
lost_status: 0, |
550 |
withdrawn: 0, |
551 |
damaged_status: 0, |
552 |
not_for_loan_status: 0, |
553 |
course_item: null, |
554 |
}, |
555 |
}).then(items => { |
556 |
cy.intercept("get", `/api/v1/biblios/${biblio_id}/items*`, { |
557 |
statuscode: 200, |
558 |
body: items, |
559 |
headers: { |
560 |
"X-Base-Total-Count": baseTotalCount, |
561 |
"X-Total-Count": baseTotalCount, |
562 |
}, |
563 |
}); |
564 |
|
565 |
cy.visit( |
566 |
"/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + |
567 |
biblio_id |
568 |
); |
569 |
|
570 |
// Hide the 'URL' column |
571 |
mock_table_settings( |
572 |
{ |
573 |
columns: { uri: { is_hidden: 1 } }, |
574 |
}, |
575 |
"items_table_settings.holdings" |
576 |
); |
577 |
|
578 |
cy.window().then(win => { |
579 |
win.libraries_map = items.reduce((map, i) => { |
580 |
map[i.library_id] = i.library_id; |
581 |
return map; |
582 |
}, {}); |
583 |
}); |
584 |
|
585 |
cy.get("@columns").then(columns => { |
586 |
cy.get(`#${table_id}_wrapper tbody tr`).should( |
587 |
"have.length", |
588 |
RESTdefaultPageSize |
589 |
); |
590 |
|
591 |
cy.get(`#${table_id} th`).contains("Status"); |
592 |
cy.get(`#${table_id} th`) |
593 |
.contains("URL") |
594 |
.should("not.exist"); |
595 |
cy.get(`#${table_id} th`) |
596 |
.contains("Course reserves") |
597 |
.should("not.exist"); |
598 |
|
599 |
cy.get(".show_filters").click(); |
600 |
cy.get(`#${table_id}_wrapper .dt-info`).contains( |
601 |
`Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries` |
602 |
); |
603 |
|
604 |
cy.get(`#${table_id} th`).contains("Status"); |
605 |
cy.get(`#${table_id} th`) |
606 |
.contains("URL") |
607 |
.should("not.exist"); |
608 |
cy.get(`#${table_id} th`) |
609 |
.contains("Course reserves") |
610 |
.should("not.exist"); |
611 |
}); |
612 |
}); |
613 |
}); |
531 |
}); |
614 |
}); |
532 |
}); |
615 |
}); |
533 |
- |
|
|