Lines 156-161
describe("Agreement CRUD operations", () => {
Link Here
|
156 |
cy.intercept("GET", "/api/v1/erm/agreements/*", agreement); |
156 |
cy.intercept("GET", "/api/v1/erm/agreements/*", agreement); |
157 |
cy.visit("/cgi-bin/koha/erm/agreements"); |
157 |
cy.visit("/cgi-bin/koha/erm/agreements"); |
158 |
cy.get("#agreements_list").contains("Showing 1 to 1 of 1 entries"); |
158 |
cy.get("#agreements_list").contains("Showing 1 to 1 of 1 entries"); |
|
|
159 |
cy.get(".filters").find("label").should(($labels) => { |
160 |
expect($labels).to.have.length(2) |
161 |
expect($labels.eq(0)).to.contain('Filter by expired') |
162 |
expect($labels.eq(1)).to.contain('Show mine only') |
163 |
}); // Filter options appear |
164 |
|
165 |
// Test filtering |
166 |
cy.intercept("GET", "/api/v1/erm/agreements?max_expiration_date=*", []).as("getActiveAgreements"); |
167 |
cy.get("#expired_filter").check(); |
168 |
cy.get("#filter_table").click(); |
169 |
cy.wait('@getActiveAgreements') |
170 |
.its('request.url') |
171 |
.should('include', 'max_expiration_date='+dates["today_iso"]); // Defaults to today |
172 |
cy.get("#max_expiration_date_filter").should("have.value", dates["today_iso"]); // Input box reflects default |
173 |
cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true"); // Browser url also updated |
174 |
|
175 |
// Now test that the url for this particular state works |
176 |
cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true"); |
177 |
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["today_iso"]); |
178 |
|
179 |
// Now test with a user entered date |
180 |
cy.get("#max_expiration_date_filter+input").click({ force: true }); |
181 |
cy.get(".flatpickr-calendar") |
182 |
.eq(0) |
183 |
.find("span.today") |
184 |
.next("span") |
185 |
.click(); // select tomorrow |
186 |
cy.get("#filter_table").click(); |
187 |
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]); |
188 |
cy.get("#max_expiration_date_filter").should("have.value", dates["tomorrow_iso"]); |
189 |
// Assert that browser url changed again to reflect the user entered date |
190 |
cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]); |
191 |
|
192 |
// Now test that the url for the updated state works |
193 |
cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]); |
194 |
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]); |
195 |
|
196 |
// Test filter button with show mine_only ticked |
159 |
}); |
197 |
}); |
160 |
|
198 |
|
161 |
it("Add agreement", () => { |
199 |
it("Add agreement", () => { |
162 |
- |
|
|