Bug 33606: Add a erm/config route to retrieve the ERM config needed for the Vue app

This could be extended later in bug 32968 to pass the permission of the
logged in user.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(cherry picked from commit cda3c377a20c401ef9a755f24eb839d515a8af72)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5078f9f4df)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-04-25 15:56:51 +02:00 committed by Matt Blenkinsop
parent 9f77254010
commit 17796faffc
14 changed files with 310 additions and 154 deletions

View file

@ -31,6 +31,28 @@ Koha::REST::V1::Acquisitions::Funds
=head2 Class methods
=head3 config
Return the configuration options needed for the ERM Vue app
=cut
sub config {
my $c = shift->openapi->valid_input or return;
return $c->render(
status => 200,
openapi => {
settings => {
ERMModule => C4::Context->preference('ERMModule'),
ERMProviders => [split ',', C4::Context->preference('ERMProviders')]
},
#permissions => {
# erm =>
#}
},
)
}
=head3 list_users
Return the list of possible ERM' users

View file

@ -0,0 +1,7 @@
---
type: object
properties:
settings:
type: object
description: List of sysprefs used for the ERM module
additionalProperties: false

View file

@ -0,0 +1,38 @@
---
/erm/config:
get:
x-mojo-to: ERM#config
operationId: getERMconfig
description: This resource returns a list of options needed for the ERM Vue app
summary: get the ERM config
tags:
- ERM
produces:
- application/json
responses:
200:
description: The ERM config
schema:
$ref: "../swagger.yaml#/definitions/erm_config"
400:
description: Bad request
schema:
$ref: "../swagger.yaml#/definitions/error"
403:
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
500:
description: |
Internal server error. Possible `error_code` attribute values:
* `internal_server_error`
schema:
$ref: "../swagger.yaml#/definitions/error"
503:
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
erm: 1

View file

@ -32,6 +32,8 @@ definitions:
$ref: ./definitions/city.yaml
erm_agreement:
$ref: ./definitions/erm_agreement.yaml
erm_config:
$ref: ./definitions/erm_config.yaml
erm_eholdings_title:
$ref: ./definitions/erm_eholdings_title.yaml
erm_eholdings_package:
@ -195,6 +197,8 @@ paths:
$ref: ./paths/config_smtp_servers.yaml#/~1config~1smtp_servers
"/config/smtp_servers/{smtp_server_id}":
$ref: "./paths/config_smtp_servers.yaml#/~1config~1smtp_servers~1{smtp_server_id}"
/erm/config:
$ref: ./paths/erm_config.yaml#/~1erm~1config
/erm/agreements:
$ref: ./paths/erm_agreements.yaml#/~1erm~1agreements
"/erm/agreements/{agreement_id}":

View file

@ -82,7 +82,7 @@ export default {
const { get_lib_from_av, map_av_dt_filter } = AVStore
const ERMStore = inject("ERMStore")
const { sysprefs } = ERMStore
const { config } = ERMStore
const table = ref()
const filters = reactive({
@ -98,7 +98,7 @@ export default {
get_lib_from_av,
escape_str,
map_av_dt_filter,
sysprefs,
config,
table,
}
},
@ -168,7 +168,7 @@ export default {
this.show_table = true
this.local_count_packages = null
if (this.sysprefs.ERMProviders.includes("local")) {
if (this.config.ERMProviders.includes("local")) {
const client = APIClient.erm
const query = this.filters
? {

View file

@ -85,7 +85,7 @@ export default {
const { get_lib_from_av } = AVStore
const ERMStore = inject("ERMStore")
const { sysprefs } = ERMStore
const { config } = ERMStore
const table = ref()
const filters = reactive({
@ -99,7 +99,7 @@ export default {
av_title_publication_types,
get_lib_from_av,
escape_str,
sysprefs,
config,
table,
}
},
@ -179,7 +179,7 @@ export default {
"/api/v1/erm/eholdings/ebsco/titles"
)
}
if (this.sysprefs.ERMProviders.includes("local")) {
if (this.config.ERMProviders.includes("local")) {
const client = APIClient.erm
const q = this.filters

View file

@ -1,5 +1,5 @@
<template>
<div v-if="initialized && sysprefs.ERMModule == 1">
<div v-if="initialized && config.settings.ERMModule == 1">
<div id="sub-header">
<Breadcrumbs />
<Help />
@ -49,13 +49,13 @@ export default {
const ERMStore = inject("ERMStore")
const { sysprefs } = storeToRefs(ERMStore)
const { config } = storeToRefs(ERMStore)
return {
vendorStore,
AVStore,
ERMStore,
sysprefs,
config,
setError,
loading,
loaded,
@ -121,23 +121,15 @@ export default {
})
)
promises.push(
sysprefs_client.sysprefs.get("ERMProviders").then(
providers => {
this.sysprefs.ERMProviders = providers.value.split(",")
},
error => {}
)
)
return Promise.all(promises)
}
const sysprefs_client = APIClient.sysprefs
sysprefs_client.sysprefs
.get("ERMModule")
.then(value => {
this.sysprefs.ERMModule = value.value
if (this.sysprefs.ERMModule != 1) {
const client = APIClient.erm
client.config
.get()
.then(config => {
this.config = config
if (this.config.settings.ERMModule != 1) {
return this.setError(
this.$__(
'The e-resource management module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule">ERMModule</a> to use it'
@ -157,7 +149,7 @@ export default {
const eHoldings = navigationTree.find(
element => element.path === "/cgi-bin/koha/erm/eholdings"
)
const providers = this.sysprefs.ERMProviders
const providers = this.config.settings.ERMProviders
eHoldings.children = eHoldings.children.filter(element =>
providers
.map(provider => `${eHoldings.path}/${provider}`)

View file

@ -7,6 +7,15 @@ export class ERMAPIClient extends HttpClient {
});
}
get config() {
return {
get: () =>
this.get({
endpoint: "config",
}),
};
}
get agreements() {
return {
get: id =>

View file

@ -43,13 +43,13 @@ function get_agreement() {
license_id: 1,
name: "license name",
status: "expired",
type: "alliance"
type: "alliance",
},
license_id:1,
license_id: 1,
notes: "license notes",
physical_location: "cupboard",
status: "controlling",
uri: "license uri"
uri: "license uri",
},
{
agreement_id: 1,
@ -59,39 +59,39 @@ function get_agreement() {
license_id: 2,
name: "second license name",
status: "expired",
type: "alliance"
type: "alliance",
},
license_id:2,
license_id: 2,
notes: "second license notes",
physical_location: "cupboard",
status: "future",
uri: "license uri"
}
uri: "license uri",
},
],
agreement_relationships: [
{
agreement_id: 1,
notes: 'related agreement notes',
notes: "related agreement notes",
related_agreement: {
agreement_id: 2,
description: "agreement description",
name: "agreement name"
name: "agreement name",
},
related_agreement_id: 2,
relationship: "supersedes"
}
relationship: "supersedes",
},
],
agreement_packages: [],
documents: [
{
agreement_id:1,
agreement_id: 1,
file_description: "file description",
file_name: "file.json",
notes: "file notes",
physical_location: "file physical location",
uri: "file uri",
uploaded_on: "2022-10-27T11:57:02+00:00"
}
uploaded_on: "2022-10-27T11:57:02+00:00",
},
],
};
}
@ -101,27 +101,30 @@ function get_licenses_to_relate() {
{
license_id: 1,
description: "a license",
name: "first license name"
name: "first license name",
},
{
license_id: 2,
description: "a second license",
name: "second license name"
name: "second license name",
},
{
license_id: 3,
description: "a third license",
name: "third license name"
name: "third license name",
},
]
];
}
describe("Agreement CRUD operations", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
cy.intercept(
"GET",
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});
it("List agreements", () => {
@ -155,25 +158,43 @@ describe("Agreement CRUD operations", () => {
cy.intercept("GET", "/api/v1/erm/agreements/*", agreement);
cy.visit("/cgi-bin/koha/erm/agreements");
cy.get("#agreements_list").contains("Showing 1 to 1 of 1 entries");
cy.get(".filters").find("label").should(($labels) => {
expect($labels).to.have.length(2)
expect($labels.eq(0)).to.contain('Filter by expired')
expect($labels.eq(1)).to.contain('Show mine only')
}); // Filter options appear
cy.get(".filters")
.find("label")
.should($labels => {
expect($labels).to.have.length(2);
expect($labels.eq(0)).to.contain("Filter by expired");
expect($labels.eq(1)).to.contain("Show mine only");
}); // Filter options appear
// Test filtering
cy.intercept("GET", "/api/v1/erm/agreements?max_expiration_date=*", []).as("getActiveAgreements");
cy.intercept(
"GET",
"/api/v1/erm/agreements?max_expiration_date=*",
[]
).as("getActiveAgreements");
cy.get("#expired_filter").check();
cy.get("#filter_table").click();
cy.wait('@getActiveAgreements')
.its('request.url')
.should('include', 'max_expiration_date='+dates["today_iso"]); // Defaults to today
cy.get("#max_expiration_date_filter").should("have.value", dates["today_iso"]); // Input box reflects default
cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["today_iso"]); // Browser url also updated
cy.wait("@getActiveAgreements")
.its("request.url")
.should("include", "max_expiration_date=" + dates["today_iso"]); // Defaults to today
cy.get("#max_expiration_date_filter").should(
"have.value",
dates["today_iso"]
); // Input box reflects default
cy.url().should(
"include",
"/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" +
dates["today_iso"]
); // Browser url also updated
// Now test that the url for this particular state works
cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["today_iso"]);
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["today_iso"]);
cy.visit(
"/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" +
dates["today_iso"]
);
cy.wait("@getActiveAgreements")
.its("request.url")
.should("include", "max_expiration_date=" + dates["today_iso"]);
// Now test with a user entered date
cy.get("#max_expiration_date_filter+input").click({ force: true });
@ -183,20 +204,37 @@ describe("Agreement CRUD operations", () => {
.next("span")
.click(); // select tomorrow
cy.get("#filter_table").click();
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]);
cy.get("#max_expiration_date_filter").should("have.value", dates["tomorrow_iso"]);
cy.wait("@getActiveAgreements")
.its("request.url")
.should("include", "max_expiration_date=" + dates["tomorrow_iso"]);
cy.get("#max_expiration_date_filter").should(
"have.value",
dates["tomorrow_iso"]
);
// Assert that browser url changed again to reflect the user entered date
cy.url().should('include', "/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]);
cy.url().should(
"include",
"/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" +
dates["tomorrow_iso"]
);
// Now test that the url for the updated state works
cy.visit("/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date="+dates["tomorrow_iso"]);
cy.wait('@getActiveAgreements').its('request.url').should('include', 'max_expiration_date='+dates["tomorrow_iso"]);
cy.visit(
"/cgi-bin/koha/erm/agreements?by_expired=true&max_expiration_date=" +
dates["tomorrow_iso"]
);
cy.wait("@getActiveAgreements")
.its("request.url")
.should("include", "max_expiration_date=" + dates["tomorrow_iso"]);
// Verify that the date input is automatically filled if "by_expired" ticked but date is empty
cy.get("#max_expiration_date_filter+input").clear();
cy.get("#expired_filter").check();
cy.get("#filter_table").click();
cy.get("#max_expiration_date_filter").should('have.value', dates["today_iso"]);
cy.get("#max_expiration_date_filter").should(
"have.value",
dates["today_iso"]
);
// Test filter button with show mine_only ticked
});
@ -308,12 +346,18 @@ describe("Agreement CRUD operations", () => {
// Add new document
cy.get("#documents").contains("Add new document").click();
cy.get("#document_0 input[id=file_0]").click();
cy.get('#document_0 input[id=file_0]').selectFile('t/cypress/fixtures/file.json');
cy.get("#document_0 input[id=file_0]").selectFile(
"t/cypress/fixtures/file.json"
);
cy.get("#document_0 .file_information span").contains("file.json");
cy.get('#document_0 input[id=file_description_0]').type('file description');
cy.get('#document_0 input[id=physical_location_0]').type('file physical location');
cy.get('#document_0 input[id=uri_0]').type('file URI');
cy.get('#document_0 input[id=notes_0]').type('file notes');
cy.get("#document_0 input[id=file_description_0]").type(
"file description"
);
cy.get("#document_0 input[id=physical_location_0]").type(
"file physical location"
);
cy.get("#document_0 input[id=uri_0]").type("file URI");
cy.get("#document_0 input[id=notes_0]").type("file notes");
// Submit the form, get 500
cy.intercept("POST", "/api/v1/erm/agreements", {
@ -352,7 +396,9 @@ describe("Agreement CRUD operations", () => {
cy.get("#agreement_license_0 #license_id_0 .vs__search").type(
related_license.license.name
);
cy.get("#agreement_license_0 #license_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first license suggestion
cy.get("#agreement_license_0 #license_id_0 .vs__dropdown-menu li")
.eq(0)
.click({ force: true }); //click first license suggestion
cy.get("#agreement_license_0 #license_status_0 .vs__search").type(
related_license.status + "{enter}",
{ force: true }
@ -361,7 +407,9 @@ describe("Agreement CRUD operations", () => {
related_license.physical_location + "{enter}",
{ force: true }
);
cy.get("#agreement_license_0 #license_notes_0").type(related_license.notes);
cy.get("#agreement_license_0 #license_notes_0").type(
related_license.notes
);
cy.get("#agreement_license_0 #license_uri_0").type(related_license.uri);
// Add new related agreement
@ -371,17 +419,24 @@ describe("Agreement CRUD operations", () => {
body: cy.get_agreements_to_relate(),
});
cy.visit("/cgi-bin/koha/erm/agreements/add");
cy.get("#agreement_relationships").contains("Add new related agreement").click();
cy.get("#agreement_relationships")
.contains("Add new related agreement")
.click();
cy.get("#related_agreement_0").contains("Related agreement 1");
cy.get("#related_agreement_0 #related_agreement_id_0 .vs__search").type(
related_agreement.related_agreement.name
);
cy.get("#related_agreement_0 #related_agreement_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first agreement suggestion
cy.get("#related_agreement_0 #related_agreement_notes_0").type(related_agreement.notes);
cy.get("#related_agreement_0 #related_agreement_relationship_0 .vs__search").type(
related_agreement.relationship + "{enter}",
{ force: true }
cy.get(
"#related_agreement_0 #related_agreement_id_0 .vs__dropdown-menu li"
)
.eq(0)
.click({ force: true }); //click first agreement suggestion
cy.get("#related_agreement_0 #related_agreement_notes_0").type(
related_agreement.notes
);
cy.get(
"#related_agreement_0 #related_agreement_relationship_0 .vs__search"
).type(related_agreement.relationship + "{enter}", { force: true });
});
it("Edit agreement", () => {
@ -394,10 +449,10 @@ describe("Agreement CRUD operations", () => {
{
method: "GET",
url: "/api/v1/erm/agreements*",
times: 1
times: 1,
},
{
body: agreements
body: agreements,
}
);
@ -456,13 +511,19 @@ describe("Agreement CRUD operations", () => {
cy.get("#notes_1").should("have.value", "this is a note");
//Test related content
cy.get("#agreement_license_0 #license_id_0 .vs__selected").contains("first license name");
cy.get("#agreement_license_1 #license_id_1 .vs__selected").contains("second license name");
cy.get("#document_0 .file_information span").contains("file.json" );
cy.get("#related_agreement_0 #related_agreement_id_0 .vs__selected").contains("agreement name");
cy.get("#agreement_license_0 #license_id_0 .vs__selected").contains(
"first license name"
);
cy.get("#agreement_license_1 #license_id_1 .vs__selected").contains(
"second license name"
);
cy.get("#document_0 .file_information span").contains("file.json");
cy.get(
"#related_agreement_0 #related_agreement_id_0 .vs__selected"
).contains("agreement name");
// Submit the form, get 500
cy.intercept("PUT", "/api/v1/erm/agreements/*", (req) => {
cy.intercept("PUT", "/api/v1/erm/agreements/*", req => {
req.reply({
statusCode: 500,
delay: 1000,
@ -542,7 +603,9 @@ describe("Agreement CRUD operations", () => {
cy.get("#agreements_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
cy.get(".dialog.alert.confirmation h1").contains(
"remove this agreement"
);
cy.contains(agreement.name);
// Accept the confirmation dialog, get 500
@ -562,9 +625,13 @@ describe("Agreement CRUD operations", () => {
cy.get("#agreements_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
cy.get(".dialog.alert.confirmation h1").contains(
"remove this agreement"
);
cy.contains("Yes, delete").click();
cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted");
cy.get("main div[class='dialog message']")
.contains("Agreement")
.contains("deleted");
// Delete from show
// Click the "name" link from the list
@ -594,11 +661,13 @@ describe("Agreement CRUD operations", () => {
"Agreement #" + agreement.agreement_id
);
cy.get('#agreements_show .action_links .fa-trash').click();
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement");
cy.get("#agreements_show .action_links .fa-trash").click();
cy.get(".dialog.alert.confirmation h1").contains(
"remove this agreement"
);
cy.contains("Yes, delete").click();
//Make sure we return to list after deleting from show
cy.get("#agreements_list table tbody tr:first")
cy.get("#agreements_list table tbody tr:first");
});
});

View file

@ -25,8 +25,11 @@ describe("Dialog operations", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
cy.intercept(
"GET",
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});
it("There are no ... defined", () => {
@ -69,7 +72,9 @@ describe("Dialog operations", () => {
cy.intercept("GET", "/api/v1/erm/agreements*", []);
cy.get("#navmenulist").contains("Agreements").click();
// Info messages should be cleared when view is changed
cy.get("main div[class='dialog message']").contains("There are no agreements defined");
cy.get("main div[class='dialog message']").contains(
"There are no agreements defined"
);
cy.get("main div[class='dialog message']").should("have.length", 1);
});

View file

@ -20,14 +20,14 @@ function get_license() {
user_roles: [],
documents: [
{
license_id:1,
license_id: 1,
file_description: "file description",
file_name: "file.json",
notes: "file notes",
physical_location: "file physical location",
uri: "file uri",
uploaded_on: "2022-10-27T11:57:02+00:00"
}
uploaded_on: "2022-10-27T11:57:02+00:00",
},
],
};
}
@ -36,8 +36,11 @@ describe("License CRUD operations", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
cy.intercept(
"GET",
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});
it("List license", () => {
@ -90,8 +93,12 @@ describe("License CRUD operations", () => {
cy.get("#license_name").type(license.name);
cy.get("#license_description").type(license.description);
cy.get("#licenses_add").contains("Submit").click();
cy.get("#license_type .vs__search").type(license.type + '{enter}',{force:true});
cy.get("#license_status .vs__search").type(license.status + '{enter}',{force:true});
cy.get("#license_type .vs__search").type(license.type + "{enter}", {
force: true,
});
cy.get("#license_status .vs__search").type(license.status + "{enter}", {
force: true,
});
cy.get("#started_on+input").click();
cy.get(".flatpickr-calendar")
@ -109,12 +116,18 @@ describe("License CRUD operations", () => {
// Add new document
cy.get("#documents").contains("Add new document").click();
cy.get("#document_0 input[id=file_0]").click();
cy.get('#document_0 input[id=file_0]').selectFile('t/cypress/fixtures/file.json');
cy.get("#document_0 input[id=file_0]").selectFile(
"t/cypress/fixtures/file.json"
);
cy.get("#document_0 .file_information span").contains("file.json");
cy.get('#document_0 input[id=file_description_0]').type('file description');
cy.get('#document_0 input[id=physical_location_0]').type('file physical location');
cy.get('#document_0 input[id=uri_0]').type('file URI');
cy.get('#document_0 input[id=notes_0]').type('file notes');
cy.get("#document_0 input[id=file_description_0]").type(
"file description"
);
cy.get("#document_0 input[id=physical_location_0]").type(
"file physical location"
);
cy.get("#document_0 input[id=uri_0]").type("file URI");
cy.get("#document_0 input[id=notes_0]").type("file notes");
// Submit the form, get 500
cy.intercept("POST", "/api/v1/erm/licenses", {
@ -131,9 +144,7 @@ describe("License CRUD operations", () => {
body: license,
});
cy.get("#licenses_add").contains("Submit").click();
cy.get("main div[class='dialog message']").contains(
"License created"
);
cy.get("main div[class='dialog message']").contains("License created");
});
it("Edit license", () => {
@ -152,9 +163,7 @@ describe("License CRUD operations", () => {
"get-license"
);
cy.visit("/cgi-bin/koha/erm/licenses");
cy.get("#licenses_list table tbody tr:first")
.contains("Edit")
.click();
cy.get("#licenses_list table tbody tr:first").contains("Edit").click();
cy.wait("@get-license");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#licenses_add h2").contains("Edit license");
@ -171,7 +180,7 @@ describe("License CRUD operations", () => {
cy.get("#ended_on").invoke("val").should("eq", dates["tomorrow_iso"]);
// Test related document
cy.get("#document_0 .file_information span").contains("file.json" );
cy.get("#document_0 .file_information span").contains("file.json");
// Submit the form, get 500
cy.intercept("PUT", "/api/v1/erm/licenses/*", {
@ -188,9 +197,7 @@ describe("License CRUD operations", () => {
body: license,
});
cy.get("#licenses_add").contains("Submit").click();
cy.get("main div[class='dialog message']").contains(
"License updated"
);
cy.get("main div[class='dialog message']").contains("License updated");
});
it("Show license", () => {
@ -219,9 +226,7 @@ describe("License CRUD operations", () => {
name_link.click();
cy.wait("@get-license");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#licenses_show h2").contains(
"License #" + license.license_id
);
cy.get("#licenses_show h2").contains("License #" + license.license_id);
});
it("Delete license", () => {
@ -265,7 +270,9 @@ describe("License CRUD operations", () => {
.click();
cy.get(".dialog.alert.confirmation h1").contains("remove this license");
cy.contains("Yes, delete").click();
cy.get("main div[class='dialog message']").contains("License").contains("deleted");
cy.get("main div[class='dialog message']")
.contains("License")
.contains("deleted");
// Delete from show
// Click the "name" link from the list
@ -291,15 +298,13 @@ describe("License CRUD operations", () => {
name_link.click();
cy.wait("@get-license");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#licenses_show h2").contains(
"License #" + license.license_id
);
cy.get("#licenses_show h2").contains("License #" + license.license_id);
cy.get('#licenses_show .action_links .fa-trash').click();
cy.get("#licenses_show .action_links .fa-trash").click();
cy.get(".dialog.alert.confirmation h1").contains("remove this license");
cy.contains("Yes, delete").click();
//Make sure we return to list after deleting from show
cy.get("#licenses_list table tbody tr:first")
cy.get("#licenses_list table tbody tr:first");
});
});

View file

@ -13,11 +13,11 @@ function get_package() {
agreement: {
agreement_id: 2,
description: "agreement description",
name: "agreement name"
name: "agreement name",
},
agreement_id: 2,
package_id: 1
}
package_id: 1,
},
],
resources_count: 0,
};
@ -27,8 +27,11 @@ describe("Package CRUD operations", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
cy.intercept(
"GET",
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});
it("List package", () => {
@ -76,7 +79,6 @@ describe("Package CRUD operations", () => {
});
it("Add package", () => {
cy.intercept("GET", "/api/v1/erm/agreements*", []);
// Click the button in the toolbar
@ -135,7 +137,9 @@ describe("Package CRUD operations", () => {
cy.get("#agreement_id_0 .vs__search").type(
related_agreement.agreement.name
);
cy.get("#agreement_id_0 .vs__dropdown-menu li").eq(0).click( { force: true } ); //click first agreement suggestion
cy.get("#agreement_id_0 .vs__dropdown-menu li")
.eq(0)
.click({ force: true }); //click first agreement suggestion
});
it("Edit package", () => {
@ -172,7 +176,9 @@ describe("Package CRUD operations", () => {
cy.get("#package_content_type .vs__selected").contains("Print");
//Test related content
cy.get("#package_agreement_0 #agreement_id_0 .vs__selected").contains("second agreement name");
cy.get("#package_agreement_0 #agreement_id_0 .vs__selected").contains(
"second agreement name"
);
// Submit the form, get 500
cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
@ -307,7 +313,9 @@ describe("Package CRUD operations", () => {
.click();
cy.get(".dialog.alert.confirmation h1").contains("remove this package");
cy.contains("Yes, delete").click();
cy.get("main div[class='dialog message']").contains("Local package").contains("deleted");
cy.get("main div[class='dialog message']")
.contains("Local package")
.contains("deleted");
// Delete from show
// Click the "name" link from the list
@ -339,11 +347,11 @@ describe("Package CRUD operations", () => {
"Package #" + erm_package.package_id
);
cy.get('#packages_show .action_links .fa-trash').click();
cy.get("#packages_show .action_links .fa-trash").click();
cy.get(".dialog.alert.confirmation h1").contains("remove this package");
cy.contains("Yes, delete").click();
//Make sure we return to list after deleting from show
cy.get("#packages_list table tbody tr:first")
cy.get("#packages_list table tbody tr:first");
});
});

View file

@ -1,34 +1,36 @@
import { mount } from "@cypress/vue";
describe("Searchbar header changes", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}');
cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}');
cy.intercept(
"GET",
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});
it("Default option is agreements", () => {
cy.visit("/cgi-bin/koha/erm/erm.pl");
cy.get("#agreement_search_tab").parent().should("have.class", "active")
cy.get("#agreement_search_tab").parent().should("have.class", "active");
cy.visit("/cgi-bin/koha/erm/agreements");
cy.get("#agreement_search_tab").parent().should("have.class", "active")
})
cy.get("#agreement_search_tab").parent().should("have.class", "active");
});
it("Should change to licenses when in licenses", () => {
cy.visit("/cgi-bin/koha/erm/licenses");
cy.get("#license_search_tab").parent().should("have.class", "active")
})
cy.get("#license_search_tab").parent().should("have.class", "active");
});
it("Should change to packages when in local packages", () => {
cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
cy.get("#package_search_tab").parent().should("have.class", "active")
})
cy.get("#package_search_tab").parent().should("have.class", "active");
});
it("Should change to titles when in local titles", () => {
cy.visit("/cgi-bin/koha/erm/eholdings/local/titles");
cy.get("#title_search_tab").parent().should("have.class", "active")
})
})
cy.get("#title_search_tab").parent().should("have.class", "active");
});
});

View file

@ -23,13 +23,8 @@ describe("Title CRUD operations", () => {
cy.title().should("eq", "Koha staff interface");
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
'{"value":"1"}'
);
cy.intercept(
"GET",
"/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
'{"value":"local"}'
"/api/v1/erm/config",
'{"settings":{"ERMModule":"1","ERMProviders":["local"]}}'
);
});