Line 0
Link Here
|
0 |
- |
1 |
import { mount } from "@cypress/vue"; |
|
|
2 |
|
3 |
describe("Add/search user", () => { |
4 |
beforeEach(() => { |
5 |
cy.login(); |
6 |
cy.title().should("eq", "Koha staff interface"); |
7 |
cy.intercept( |
8 |
"GET", |
9 |
"/api/v1/erm/config", |
10 |
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' |
11 |
); |
12 |
}); |
13 |
|
14 |
it("Add agreement", () => { |
15 |
let vendors = cy.get_vendors_to_relate(); |
16 |
// No agreement, no license yet |
17 |
cy.intercept("GET", "/api/v1/erm/agreements*", { |
18 |
statusCode: 200, |
19 |
body: [], |
20 |
}); |
21 |
cy.intercept("GET", "/api/v1/erm/licenses*", { |
22 |
statusCode: 200, |
23 |
body: [], |
24 |
}); |
25 |
|
26 |
//Intercept patrons request |
27 |
cy.intercept("GET", "/api/v1/patrons*", { |
28 |
statusCode: 200, |
29 |
body: [ |
30 |
{ |
31 |
patron_id: 1, |
32 |
firstname: "foo", |
33 |
surname: "bar", |
34 |
category_id: "S", |
35 |
library_id: "CPL", |
36 |
}, |
37 |
{ |
38 |
patron_id: 2, |
39 |
firstname: "foofoo", |
40 |
surname: "barbar", |
41 |
category_id: "S", |
42 |
library_id: "CPL", |
43 |
}, |
44 |
], |
45 |
headers: { |
46 |
"X-Base-Total-Count": "2", |
47 |
"X-Total-Count": "2", |
48 |
}, |
49 |
}); |
50 |
|
51 |
cy.intercept("GET", "/api/v1/patrons/1", { |
52 |
statusCode: 200, |
53 |
body: { |
54 |
patron_id: 1, |
55 |
firstname: "foo", |
56 |
surname: "bar", |
57 |
category_id: "S", |
58 |
library_id: "CPL", |
59 |
}, |
60 |
}); |
61 |
|
62 |
// Click the button in the toolbar |
63 |
cy.visit("/cgi-bin/koha/erm/agreements"); |
64 |
cy.contains("New agreement").click(); |
65 |
cy.get("#agreements_add h2").contains("New agreement"); |
66 |
cy.left_menu_active_item_is("Agreements"); |
67 |
|
68 |
cy.contains("Add new user").click(); |
69 |
cy.contains("Select user").click(); |
70 |
cy.get("#patron_search_modal fieldset.action") |
71 |
.contains("Search") |
72 |
.click(); |
73 |
|
74 |
cy.get("#patron_search_modal table").contains("bar, foo"); |
75 |
cy.get("#patron_search_modal td").contains("Select").click(); |
76 |
|
77 |
cy.get("#user_roles li:first span.user").contains("foo bar"); |
78 |
}); |
79 |
}); |