Lines 21-26
function build_libraries() {
Link Here
|
21 |
}); |
21 |
}); |
22 |
}); |
22 |
}); |
23 |
} |
23 |
} |
|
|
24 |
|
25 |
function mock_table_settings(settings) { |
26 |
cy.window().then(win => { |
27 |
win.table_settings.columns = win.table_settings.columns.map(c => ({ |
28 |
...c, |
29 |
is_hidden: 0, |
30 |
cannot_be_toggled: 0, |
31 |
})); |
32 |
if (settings && settings.hasOwnProperty("default_save_state")) { |
33 |
win.table_settings.default_save_state = settings.default_save_state; |
34 |
} |
35 |
if (settings && settings.hasOwnProperty("default_save_state_search")) { |
36 |
win.table_settings.default_save_state_search = |
37 |
settings.default_save_state_search; |
38 |
} |
39 |
|
40 |
if (settings && settings.columns) { |
41 |
Object.entries(settings.columns).forEach(([name, values]) => { |
42 |
let column = win.table_settings.columns.find( |
43 |
cc => cc.columnname == name |
44 |
); |
45 |
Object.entries(values).forEach(([prop, value]) => { |
46 |
column[prop] = value; |
47 |
}); |
48 |
}); |
49 |
} |
50 |
cy.wrap(win.table_settings.columns).as("columns"); |
51 |
}); |
52 |
} |
24 |
describe("kohaTable (using REST API)", () => { |
53 |
describe("kohaTable (using REST API)", () => { |
25 |
beforeEach(() => { |
54 |
beforeEach(() => { |
26 |
cy.login(); |
55 |
cy.login(); |
Lines 77-89
describe("kohaTable (using REST API)", () => {
Link Here
|
77 |
build_libraries().then(() => { |
106 |
build_libraries().then(() => { |
78 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
107 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
79 |
|
108 |
|
80 |
cy.window().then(win => { |
109 |
mock_table_settings(); |
81 |
win.table_settings.columns = win.table_settings.columns.map( |
110 |
cy.get("@columns").then(columns => { |
82 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
|
|
83 |
); |
84 |
cy.get(`#${table_id} th`).should( |
111 |
cy.get(`#${table_id} th`).should( |
85 |
"have.length", |
112 |
"have.length", |
86 |
win.table_settings.columns.length |
113 |
columns.length |
87 |
); |
114 |
); |
88 |
}); |
115 |
}); |
89 |
}); |
116 |
}); |
Lines 93-114
describe("kohaTable (using REST API)", () => {
Link Here
|
93 |
build_libraries().then(() => { |
120 |
build_libraries().then(() => { |
94 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
121 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
95 |
|
122 |
|
96 |
cy.window().then(win => { |
123 |
mock_table_settings({ |
97 |
win.table_settings.columns = win.table_settings.columns.map( |
124 |
columns: { library_code: { is_hidden: 1 } }, |
98 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
125 |
}); |
99 |
); |
126 |
|
100 |
win.table_settings.columns.find( |
127 |
cy.get("@columns").then(columns => { |
101 |
c => c.columnname == "library_code" |
|
|
102 |
).is_hidden = 1; |
103 |
cy.get(`#${table_id} th`).should( |
128 |
cy.get(`#${table_id} th`).should( |
104 |
"have.length", |
129 |
"have.length", |
105 |
win.table_settings.columns.length - 1 |
130 |
columns.length - 1 |
106 |
); |
131 |
); |
107 |
cy.get(`#${table_id} th`).contains("Name"); |
|
|
108 |
cy.get(`#${table_id} th`) |
109 |
.contains("Code") |
110 |
.should("not.exist"); |
111 |
}); |
132 |
}); |
|
|
133 |
|
134 |
cy.get(`#${table_id} th`).contains("Name"); |
135 |
cy.get(`#${table_id} th`).contains("Code").should("not.exist"); |
112 |
}); |
136 |
}); |
113 |
}); |
137 |
}); |
114 |
|
138 |
|
Lines 116-132
describe("kohaTable (using REST API)", () => {
Link Here
|
116 |
build_libraries().then(() => { |
140 |
build_libraries().then(() => { |
117 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
141 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
118 |
|
142 |
|
119 |
cy.window().then(win => { |
143 |
mock_table_settings({ |
120 |
win.table_settings.default_save_state = 0; |
144 |
default_save_state: 0, |
121 |
win.table_settings.columns = win.table_settings.columns.map( |
145 |
columns: { library_code: { is_hidden: 1 } }, |
122 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
146 |
}); |
123 |
); |
147 |
|
124 |
win.table_settings.columns.find( |
148 |
cy.get("@columns").then(columns => { |
125 |
c => c.columnname == "library_code" |
|
|
126 |
).is_hidden = 1; |
127 |
cy.get(`#${table_id} th`).should( |
149 |
cy.get(`#${table_id} th`).should( |
128 |
"have.length", |
150 |
"have.length", |
129 |
win.table_settings.columns.length - 1 |
151 |
columns.length - 1 |
130 |
); |
152 |
); |
131 |
cy.get(`#${table_id} th`).contains("Name"); |
153 |
cy.get(`#${table_id} th`).contains("Name"); |
132 |
cy.get(`#${table_id} th`) |
154 |
cy.get(`#${table_id} th`) |
Lines 138-144
describe("kohaTable (using REST API)", () => {
Link Here
|
138 |
.click(); |
160 |
.click(); |
139 |
cy.get(`#${table_id} th`).should( |
161 |
cy.get(`#${table_id} th`).should( |
140 |
"have.length", |
162 |
"have.length", |
141 |
win.table_settings.columns.length |
163 |
columns.length |
142 |
); |
164 |
); |
143 |
cy.get(`#${table_id} th`).contains("Name"); |
165 |
cy.get(`#${table_id} th`).contains("Name"); |
144 |
cy.get(`#${table_id} th`).contains("Code"); |
166 |
cy.get(`#${table_id} th`).contains("Code"); |
Lines 146-162
describe("kohaTable (using REST API)", () => {
Link Here
|
146 |
|
168 |
|
147 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
169 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
148 |
|
170 |
|
149 |
cy.window().then(win => { |
171 |
mock_table_settings({ |
150 |
win.table_settings.default_save_state = 0; |
172 |
default_save_state: 0, |
151 |
win.table_settings.columns = win.table_settings.columns.map( |
173 |
columns: { library_code: { is_hidden: 1 } }, |
152 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
174 |
}); |
153 |
); |
175 |
|
154 |
win.table_settings.columns.find( |
176 |
cy.get("@columns").then(columns => { |
155 |
c => c.columnname == "library_code" |
|
|
156 |
).is_hidden = 1; |
157 |
cy.get(`#${table_id} th`).should( |
177 |
cy.get(`#${table_id} th`).should( |
158 |
"have.length", |
178 |
"have.length", |
159 |
win.table_settings.columns.length |
179 |
columns.length |
160 |
); |
180 |
); |
161 |
cy.get(`#${table_id} th`).contains("Name"); |
181 |
cy.get(`#${table_id} th`).contains("Name"); |
162 |
cy.get(`#${table_id} th`) |
182 |
cy.get(`#${table_id} th`) |
Lines 170-186
describe("kohaTable (using REST API)", () => {
Link Here
|
170 |
build_libraries().then(() => { |
190 |
build_libraries().then(() => { |
171 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
191 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
172 |
|
192 |
|
173 |
cy.window().then(win => { |
193 |
mock_table_settings({ |
174 |
win.table_settings.default_save_state = 1; |
194 |
default_save_state: 1, |
175 |
win.table_settings.columns = win.table_settings.columns.map( |
195 |
columns: { library_code: { is_hidden: 1 } }, |
176 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
196 |
}); |
177 |
); |
197 |
|
178 |
win.table_settings.columns.find( |
198 |
cy.get("@columns").then(columns => { |
179 |
c => c.columnname == "library_code" |
|
|
180 |
).is_hidden = 1; |
181 |
cy.get(`#${table_id} th`).should( |
199 |
cy.get(`#${table_id} th`).should( |
182 |
"have.length", |
200 |
"have.length", |
183 |
win.table_settings.columns.length - 1 |
201 |
columns.length - 1 |
184 |
); |
202 |
); |
185 |
cy.get(`#${table_id} th`).contains("Name"); |
203 |
cy.get(`#${table_id} th`).contains("Name"); |
186 |
cy.get(`#${table_id} th`) |
204 |
cy.get(`#${table_id} th`) |
Lines 192-198
describe("kohaTable (using REST API)", () => {
Link Here
|
192 |
.click(); |
210 |
.click(); |
193 |
cy.get(`#${table_id} th`).should( |
211 |
cy.get(`#${table_id} th`).should( |
194 |
"have.length", |
212 |
"have.length", |
195 |
win.table_settings.columns.length |
213 |
columns.length |
196 |
); |
214 |
); |
197 |
cy.get(`#${table_id} th`).contains("Name"); |
215 |
cy.get(`#${table_id} th`).contains("Name"); |
198 |
cy.get(`#${table_id} th`).contains("Code"); |
216 |
cy.get(`#${table_id} th`).contains("Code"); |
Lines 200-216
describe("kohaTable (using REST API)", () => {
Link Here
|
200 |
|
218 |
|
201 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
219 |
cy.visit("/cgi-bin/koha/admin/branches.pl"); |
202 |
|
220 |
|
203 |
cy.window().then(win => { |
221 |
mock_table_settings({ |
204 |
win.table_settings.default_save_state = 1; |
222 |
default_save_state: 1, |
205 |
win.table_settings.columns = win.table_settings.columns.map( |
223 |
columns: { library_code: { is_hidden: 1 } }, |
206 |
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 }) |
224 |
}); |
207 |
); |
225 |
|
208 |
win.table_settings.columns.find( |
226 |
cy.get("@columns").then(columns => { |
209 |
c => c.columnname == "library_code" |
|
|
210 |
).is_hidden = 1; |
211 |
cy.get(`#${table_id} th`).should( |
227 |
cy.get(`#${table_id} th`).should( |
212 |
"have.length", |
228 |
"have.length", |
213 |
win.table_settings.columns.length |
229 |
columns.length |
214 |
); |
230 |
); |
215 |
cy.get(`#${table_id} th`).contains("Name"); |
231 |
cy.get(`#${table_id} th`).contains("Name"); |
216 |
cy.get(`#${table_id} th`).contains("Code"); |
232 |
cy.get(`#${table_id} th`).contains("Code"); |
217 |
- |
|
|