Bug 37893: Rewrite: Move to composition API as well as other changes to use the latest of bug 38201

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-10-07 14:33:23 +00:00 committed by Lucas Gass
parent cd25cca2b5
commit 6b28a7da7d
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
16 changed files with 1211 additions and 1242 deletions

View File

@ -57,13 +57,15 @@ sub delete {
return $self->SUPER::delete;
}
# sub _update_config_timestamp {
# my $timestamp = DateTime->now;
sub _update_config_timestamp {
return 1;
# my $config_timestamp = Koha::SIP2::ServerParams->find( { key => 'config_timestamp' } )
# || Koha::SIP2::ServerParam->new( { key => 'config_timestamp' } );
# $config_timestamp->value( DateTime->now->epoch )->store;
# }
# my $timestamp = DateTime->now;
# my $config_timestamp = Koha::SIP2::ServerParams->find( { key => 'config_timestamp' } )
# || Koha::SIP2::ServerParam->new( { key => 'config_timestamp' } );
# $config_timestamp->value( DateTime->now->epoch )->store;
}
1;

View File

@ -147,6 +147,7 @@
items:
type: string
enum:
- institution
- custom_item_fields
- item_fields
- custom_patron_fields

View File

@ -1,4 +1,4 @@
export class CataloguingAPIClient {
export class CashAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/",
@ -8,7 +8,7 @@ export class CataloguingAPIClient {
get cash_registers() {
return {
getAll: (query, params, headers) =>
this.getAll({
this.httpClient.getAll({
endpoint: "cash_registers",
query,
params,

View File

@ -20,7 +20,7 @@ export class ItemAPIClient {
get item_types() {
return {
getAll: (query, params, headers) =>
this.getAll({
this.httpClient.getAll({
endpoint: "item_types",
query,
params,

View File

@ -1,7 +1,7 @@
export class PatronAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/patrons/",
baseURL: "/api/v1/",
});
}
@ -9,15 +9,15 @@ export class PatronAPIClient {
return {
get: id =>
this.httpClient.get({
endpoint: id,
endpoint: "patrons/" + id,
}),
};
}
get patron_categories() {
get categories() {
return {
getAll: (query, params, headers) =>
this.getAll({
this.httpClient.getAll({
endpoint: "patron_categories",
query,
params,

View File

@ -8,29 +8,29 @@ export class SIP2APIClient {
get institutions() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "institutions/" + id,
}),
getAll: params =>
this.getAll({
this.httpClient.getAll({
endpoint: "institutions",
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "institutions/" + id,
}),
create: institution =>
this.post({
this.httpClient.post({
endpoint: "institutions",
body: institution,
}),
update: (institution, id) =>
this.put({
this.httpClient.put({
endpoint: "institutions/" + id,
body: institution,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"institutions?" +
new URLSearchParams({
@ -45,33 +45,33 @@ export class SIP2APIClient {
get accounts() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "accounts/" + id,
headers: {
"x-koha-embed":
"custom_item_fields,item_fields,custom_patron_fields,patron_attributes,screen_msg_regexs,sort_bin_mappings,system_preference_overrides",
"institution,custom_item_fields,item_fields,custom_patron_fields,patron_attributes,screen_msg_regexs,sort_bin_mappings,system_preference_overrides",
},
}),
getAll: params =>
this.getAll({
this.httpClient.getAll({
endpoint: "accounts",
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "accounts/" + id,
}),
create: account =>
this.post({
this.httpClient.post({
endpoint: "accounts",
body: account,
}),
update: (account, id) =>
this.put({
this.httpClient.put({
endpoint: "accounts/" + id,
body: account,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"accounts?" +
new URLSearchParams({
@ -86,29 +86,29 @@ export class SIP2APIClient {
get listeners() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "listeners/" + id,
}),
getAll: params =>
this.getAll({
this.httpClient.getAll({
endpoint: "listeners",
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "listeners/" + id,
}),
create: listener =>
this.post({
this.httpClient.post({
endpoint: "listeners",
body: listener,
}),
update: (listener, id) =>
this.put({
this.httpClient.put({
endpoint: "listeners/" + id,
body: listener,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"listeners?" +
new URLSearchParams({
@ -123,11 +123,11 @@ export class SIP2APIClient {
get serverparams() {
return {
getAll: params =>
this.getAll({
this.httpClient.getAll({
endpoint: "serverparams",
}),
updateAll: body =>
this.patch({
this.httpClient.patch({
endpoint: "serverparams",
body: body,
}),
@ -137,29 +137,29 @@ export class SIP2APIClient {
get system_preference_overrides() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "system_preference_overrides/" + id,
}),
getAll: params =>
this.getAll({
this.httpClient.getAll({
endpoint: "system_preference_overrides",
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "system_preference_overrides/" + id,
}),
create: system_preference_override =>
this.post({
this.httpClient.post({
endpoint: "system_preference_overrides",
body: system_preference_override,
}),
update: (system_preference_override, id) =>
this.put({
this.httpClient.put({
endpoint: "system_preference_overrides/" + id,
body: system_preference_override,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"system_preference_overrides?" +
new URLSearchParams({

View File

@ -21,9 +21,9 @@
</template>
<script>
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { inject, onBeforeMount, ref } from "vue";
import Breadcrumbs from "../Breadcrumbs.vue";
import { storeToRefs } from "pinia";
import Help from "../Help.vue";
import LeftMenu from "../LeftMenu.vue";
import Dialog from "../Dialog.vue";
@ -31,44 +31,27 @@ import "vue-select/dist/vue-select.css";
export default {
setup() {
const AVStore = inject("AVStore");
const SIP2Store = inject("SIP2Store");
const { authorisedValues } = storeToRefs(SIP2Store);
const { loadAuthorisedValues } = SIP2Store;
return {
AVStore,
};
},
data() {
return {
initialized: false,
};
},
beforeCreate() {
const av_client = APIClient.authorised_values;
const authorised_values = {
av_lost: "LOST",
};
const mainStore = inject("mainStore");
let av_cat_array = Object.keys(authorised_values).map(
function (av_cat) {
return '"' + authorised_values[av_cat] + '"';
}
);
const { loading, loaded, setError } = mainStore;
av_client.values
.getCategoriesWithValues(av_cat_array)
.then(av_categories => {
Object.entries(authorised_values).forEach(
([av_var, av_cat]) => {
const av_match = av_categories.find(
element => element.category_name == av_cat
);
this.AVStore[av_var] = av_match.authorised_values;
}
);
})
.then(() => {
this.initialized = true;
const initialized = ref(false);
onBeforeMount(() => {
loading();
loadAuthorisedValues(authorisedValues.value, SIP2Store).then(() => {
loaded();
initialized.value = true;
});
});
return {
initialized,
};
},
components: {
Breadcrumbs,

View File

@ -1,34 +1,49 @@
<template>
<BaseResource :routeAction="routeAction" :instancedResource="this" />
</template>
<script>
import { inject } from "vue";
import BaseResource from "./../BaseResource.vue";
import { useBaseResource } from "../../composables/base-resource.js";
import { APIClient } from "../../fetch/api-client.js";
import { $__ } from "@koha-vue/i18n";
export default {
extends: BaseResource,
name: "SIP2InstitutionResource",
components: {
BaseResource,
},
props: {
routeAction: String,
},
emits: ["select-resource"],
setup(props) {
return {
...BaseResource.setup({
resourceName: "institution",
nameAttr: "name",
idAttr: "sip_institution_id",
showComponent: "SIP2InstitutionsShow",
listComponent: "SIP2InstitutionsList",
addComponent: "SIP2InstitutionsFormAdd",
editComponent: "SIP2InstitutionsFormAddEdit",
apiClient: APIClient.sip2.institutions,
resourceTableUrl: APIClient.sip2._baseURL + "institutions",
i18n: {
displayName: __("Institution"),
displayNameLowerCase: __("institution"),
displayNamePlural: __("institutions"),
},
}),
};
},
data() {
return {
const baseResource = useBaseResource({
resourceName: "institution",
nameAttr: "name",
idAttr: "sip_institution_id",
components: {
show: "SIP2InstitutionsShow",
list: "SIP2InstitutionsList",
add: "SIP2InstitutionsFormAdd",
edit: "SIP2InstitutionsFormAddEdit",
},
apiClient: APIClient.sip2.institutions,
i18n: {
deleteConfirmationMessage: $__(
"Are you sure you want to remove this institution?"
),
deleteSuccessMessage: $__("Institution %s deleted"),
displayName: $__("Institution"),
editLabel: $__("Edit institution #%s"),
emptyListMessage: $__("There are no institutions defined"),
newLabel: $__("New institution"),
},
table: {
resourceTableUrl:
APIClient.sip2.httpClient._baseURL + "institutions",
},
resourceAttrs: [
{
name: "name",
@ -97,7 +112,7 @@ export default {
{
name: "retries",
required: true,
type: "text",
type: "number",
label: __("Retries"),
show_in_table: true,
group: "Policy",
@ -121,7 +136,7 @@ export default {
{
name: "timeout",
required: true,
type: "text",
type: "number",
label: __("Timeout"),
showInTable: true,
group: "Policy",
@ -131,57 +146,47 @@ export default {
),
},
],
tableOptions: {
columns: this.getTableColumns(),
url: () => this.resourceTableUrl,
table_settings: this.institutions_table_settings,
actions: {
0: ["show"],
"-1": this.embedded
? [
{
select: {
text: this.$__("Select"),
icon: "fa fa-check",
},
},
]
: ["edit", "delete"],
},
props: props,
});
const tableOptions = {
url: () => baseResource.getResourceTableUrl(),
table_settings: institutions_table_settings,
actions: {
0: ["show"],
"-1": ["edit", "delete"],
},
};
},
methods: {
onSubmit(e, institutionToSave) {
const onFormSave = async (e, institutionToSave) => {
e.preventDefault();
let institution = JSON.parse(JSON.stringify(institutionToSave)); // copy
let sip_institution_id = institution.sip_institution_id;
let institution = JSON.parse(JSON.stringify(institutionToSave));
const sip_institution_id = institution.sip_institution_id;
delete institution.sip_institution_id;
const client = APIClient.sip2;
if (sip_institution_id) {
client.institutions
.update(institution, sip_institution_id)
.then(
success => {
this.setMessage(this.$__("Institution updated"));
this.$router.push({ name: "SIP2InstitutionsList" });
},
error => {}
try {
if (sip_institution_id) {
await baseResource.apiClient.update(
institution,
sip_institution_id
);
} else {
client.institutions.create(institution).then(
success => {
this.setMessage(this.$__("Institution created"));
this.$router.push({ name: "SIP2InstitutionsList" });
},
error => {}
);
baseResource.setMessage(__("Institution updated"));
} else {
await baseResource.apiClient.create(institution);
baseResource.setMessage(__("Institution created"));
}
baseResource.router.push({ name: "SIP2InstitutionsList" });
} catch (error) {
// Handle error here if needed
}
},
};
return {
...baseResource,
tableOptions,
onFormSave,
};
},
name: "SIP2InstitutionResource",
};
</script>

View File

@ -1,87 +1,70 @@
<template>
<BaseResource :routeAction="routeAction" :instancedResource="this" />
</template>
<script>
import { computed } from "vue";
import BaseResource from "./../BaseResource.vue";
import { useBaseResource } from "../../composables/base-resource.js";
import { APIClient } from "../../fetch/api-client.js";
import { $__ } from "@koha-vue/i18n";
export default {
extends: BaseResource,
name: "SIP2SystemPreferenceOverrideResource",
components: {
BaseResource,
},
props: {
routeAction: String,
},
setup(props) {
return {
...BaseResource.setup({
resourceName: "system_preference_override",
nameAttr: "variable",
idAttr: "sip_system_preference_override_id",
showComponent: "SIP2SystemPreferenceOverridesShow",
listComponent: "SIP2SystemPreferenceOverridesList",
addComponent: "SIP2SystemPreferenceOverridesFormAdd",
editComponent: "SIP2SystemPreferenceOverridesFormAddEdit",
apiClient: APIClient.sip2.system_preference_overrides,
const baseResource = useBaseResource({
resourceName: "system_preference_override",
nameAttr: "variable",
idAttr: "sip_system_preference_override_id",
components: {
show: "SIP2SystemPreferenceOverridesShow",
list: "SIP2SystemPreferenceOverridesList",
add: "SIP2SystemPreferenceOverridesFormAdd",
edit: "SIP2SystemPreferenceOverridesFormAddEdit",
},
apiClient: APIClient.sip2.system_preference_overrides,
table: {
resourceTableUrl:
APIClient.sip2._baseURL + "system_preference_overrides",
i18n: {
displayName: __("System preference override"),
displayNameLowerCase: __("system preference override"),
displayNamePlural: __("system preference overrides"),
},
}),
};
},
data() {
return {
APIClient.sip2.httpClient._baseURL +
"system_preference_overrides",
},
i18n: {
deleteConfirmationMessage: $__(
"Are you sure you want to remove this system preference override?"
),
deleteSuccessMessage: $__(
"System preference override %s deleted"
),
displayName: $__("System preference override"),
editLabel: $__("Edit system preference override #%s"),
emptyListMessage: $__(
"There are no system preference overrides defined"
),
newLabel: $__("New system preference override"),
},
resourceAttrs: [
{
name: "variable",
required: true,
type: "text",
label: __("Variable"),
label: $__("Variable"),
},
{
name: "value",
required: true,
type: "text",
label: __("Value"),
label: $__("Value"),
},
],
tableOptions: {
columns: this.getTableColumns(),
url: () => this.resourceTableUrl,
table_settings: this.system_preference_overrides_table_settings,
actions: {
0: ["show"],
"-1": this.embedded
? [
{
select: {
text: this.$__("Select"),
icon: "fa fa-check",
},
},
]
: ["edit", "delete"],
},
},
};
},
methods: {
getTableColumns: function () {
return [
{
title: __("Variable"),
data: "variable",
searchable: true,
orderable: true,
},
{
title: __("Value"),
data: "value",
searchable: true,
orderable: true,
},
];
},
onSubmit(e, systemPreferenceOverrideToSave) {
props: props,
});
const onFormSave = async (e, systemPreferenceOverrideToSave) => {
e.preventDefault();
let system_preference_override = JSON.parse(
@ -92,41 +75,44 @@ export default {
delete system_preference_override.sip_system_preference_override_id;
const client = APIClient.sip2;
if (sip_system_preference_override_id) {
client.system_preference_overrides
.update(
try {
if (sip_system_preference_override_id) {
await baseResource.apiClient.update(
system_preference_override,
sip_system_preference_override_id
)
.then(
success => {
this.setMessage(
this.$__("System preference override updated")
);
this.$router.push({
name: "SIP2SystemPreferenceOverridesList",
});
},
error => {}
);
} else {
client.system_preference_overrides
.create(system_preference_override)
.then(
success => {
this.setMessage(
this.$__("System preference override created")
);
this.$router.push({
name: "SIP2SystemPreferenceOverridesList",
});
},
error => {}
baseResource.setMessage(
$__("System preference override updated")
);
} else {
await baseResource.apiClient.create(
system_preference_override
);
baseResource.setMessage(
$__("System preference override created")
);
}
baseResource.router.push({
name: "SIP2SystemPreferenceOverridesList",
});
} catch (error) {
// Handle error here if needed
}
},
};
const tableOptions = computed(() => ({
url: () => baseResource.getResourceTableUrl(),
table_settings: system_preference_overrides_table_settings,
actions: {
0: ["show"],
"-1": ["edit", "delete"],
},
}));
return {
...baseResource,
tableOptions,
onFormSave,
};
},
name: "SIP2SystemPreferenceOverrideResource",
};
</script>

View File

@ -9,7 +9,7 @@ import CashAPIClient from "@fetch/cash-api-client";
import ItemAPIClient from "@fetch/item-api-client";
import RecordSourcesAPIClient from "@fetch/record-sources-api-client";
import SysprefAPIClient from "@fetch/system-preferences-api-client";
import SIP2APIClient from "@fetch/ssip2-api-client";
import SIP2APIClient from "@fetch/sip2-api-client";
import PreservationAPIClient from "@fetch/preservation-api-client";
export const APIClient = {

View File

@ -21,7 +21,6 @@ import { routes as routesDef } from "../routes/sip2";
import { useMainStore } from "../stores/main";
import { useVendorStore } from "../stores/vendors";
import { useAVStore } from "../stores/authorised-values";
import { useSIP2Store } from "../stores/sip2";
import { useNavigationStore } from "../stores/navigation";
import i18n from "../i18n";
@ -29,7 +28,6 @@ import i18n from "../i18n";
const pinia = createPinia();
const mainStore = useMainStore(pinia);
const AVStore = useAVStore(pinia);
const navigationStore = useNavigationStore(pinia);
const routes = navigationStore.setRoutes(routesDef);
@ -51,7 +49,6 @@ const rootComponent = app
app.config.unwrapInjectedRef = true;
app.provide("vendorStore", useVendorStore(pinia));
app.provide("mainStore", mainStore);
app.provide("AVStore", AVStore);
app.provide("navigationStore", navigationStore);
const SIP2Store = useSIP2Store(pinia);
app.provide("SIP2Store", SIP2Store);

View File

@ -1,7 +1,6 @@
import { defineStore } from "pinia";
import { reactive, toRefs } from "vue";
import { withAuthorisedValueActions } from "../composables/authorisedValues";
import { $__ } from "@koha-vue/i18n";
export const useSIP2Store = defineStore("erm", () => {
const store = reactive({

View File

@ -87,7 +87,7 @@ describe("Accounts", () => {
error: "Something went wrong",
});
cy.visit("/cgi-bin/koha/sip2/sip2.pl");
cy.get("#navmenulist").contains("Accounts").click();
cy.get(".sidebar_menu").contains("Accounts").click();
cy.get("main div[class='alert alert-warning']").contains(
/Something went wrong/
);
@ -95,7 +95,7 @@ describe("Accounts", () => {
// GET accounts returns empty list
cy.intercept("GET", "/api/v1/sip2/accounts*", []);
cy.visit("/cgi-bin/koha/sip2/accounts");
cy.get("#account_list").contains("There are no accounts defined");
cy.get("#accounts_list").contains("There are no accounts defined");
// GET accounts returns something
let account = get_account();
@ -111,7 +111,7 @@ describe("Accounts", () => {
});
cy.intercept("GET", "/api/v1/sip2/accounts/*", account);
cy.visit("/cgi-bin/koha/sip2/accounts/");
cy.get("#account_list").contains("Showing 1 to 1 of 1 entries");
cy.get("#accounts_list").contains("Showing 1 to 1 of 1 entries");
});
it("Add account", () => {
@ -132,14 +132,14 @@ describe("Accounts", () => {
// Click the button in the toolbar
cy.visit("/cgi-bin/koha/sip2/accounts");
cy.contains("New account").click();
cy.get("#account_add h2").contains("New account");
cy.get("#accounts_add h2").contains("New account");
cy.left_menu_active_item_is("Accounts");
// Fill in the form for normal attributes
cy.get("#account_add").contains("Submit").click();
cy.get("#accounts_add").contains("Submit").click();
cy.get("input:invalid,textarea:invalid,select:invalid").should(
"have.length",
2
3
);
cy.get("#login_id").type(account.login_id);
cy.get("#login_password").type(account.login_password);
@ -196,13 +196,13 @@ describe("Accounts", () => {
// relationshipWidgets
cy.contains("Add new custom patron field").click();
cy.get("#account_add").contains("Submit").click();
cy.get("#accounts_add").contains("Submit").click();
cy.get("input:invalid,textarea:invalid,select:invalid").should(
"have.length",
2
);
// Add new periods
// Add new custom patron fields
cy.contains("Add new custom patron field").click();
cy.get("#custom_patron_fields_relationship > fieldset").should(
"have.length",
@ -211,8 +211,12 @@ describe("Accounts", () => {
cy.contains("a", "Remove this custom patron field").click();
cy.get("#custom_patron_fields_0 #field").type("test");
cy.get("#custom_patron_fields_0 #template").type("test");
cy.get("#custom_patron_fields_0 #custom_patron_fields_field_0").type(
"test"
);
cy.get("#custom_patron_fields_0 #custom_patron_fields_template_0").type(
"test"
);
cy.get(".accordion-item").each($el => {
cy.wrap($el).children(".collapse").should("have.class", "show");
@ -234,7 +238,7 @@ describe("Accounts", () => {
cy.intercept("POST", "/api/v1/sip2/accounts", {
statusCode: 500,
});
cy.get("#account_add").contains("Submit").click();
cy.get("#accounts_add").contains("Submit").click();
cy.get("main div[class='alert alert-warning']").contains(
"Something went wrong: Error: Internal Server Error"
@ -245,7 +249,7 @@ describe("Accounts", () => {
statusCode: 201,
body: account,
});
cy.get("#account_add").contains("Submit").click();
cy.get("#accounts_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"Account created"
);
@ -273,10 +277,9 @@ describe("Accounts", () => {
);
// Click the 'Edit' button from the list
cy.get("#account_list table tbody tr:first").contains("Edit").click();
cy.get("#accounts_list table tbody tr:first").contains("Edit").click();
cy.wait("@get-account");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#account_add h2").contains("Edit account");
cy.get("#accounts_add h2").contains("Edit account");
cy.left_menu_active_item_is("Accounts");
// Form has been correctly filled in
@ -301,11 +304,10 @@ describe("Accounts", () => {
statusCode: 500,
delay: 1000,
});
});
cy.get("#account_add").contains("Submit").click();
}).as("edit-account");
cy.get("#accounts_add").contains("Submit").click();
cy.get("main div[class='modal_centered']").contains("Submitting...");
cy.wait(1000);
cy.wait("@edit-account");
cy.get("main div[class='alert alert-warning']").contains(
"Something went wrong: Error: Internal Server Error"
);
@ -315,7 +317,7 @@ describe("Accounts", () => {
statusCode: 200,
body: account,
});
cy.get("#account_add").contains("Submit").click();
cy.get("#accounts_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"Account updated"
);
@ -332,20 +334,19 @@ describe("Accounts", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
});
}).as("get-accounts");
cy.intercept("GET", "/api/v1/sip2/accounts/*", account).as(
"get-account"
);
cy.visit("/cgi-bin/koha/sip2/accounts");
let name_link = cy.get("#account_list table tbody tr:first td:first a");
name_link.should(
"have.text",
account.login_id + " (#" + account.sip_account_id + ")"
cy.wait("@get-accounts");
let name_link = cy.get(
"#accounts_list table tbody tr:first td:first a"
);
name_link.should("have.text", account.login_id);
name_link.click();
cy.wait("@get-account");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#account_show h2").contains(
cy.get("#accounts_show h2").contains(
"Account #" + account.sip_account_id
);
cy.left_menu_active_item_is("Accounts");
@ -364,11 +365,13 @@ describe("Accounts", () => {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
});
}).as("get-accounts");
cy.intercept("GET", "/api/v1/sip2/accounts/*", account);
cy.visit("/cgi-bin/koha/sip2/accounts");
cy.get("#account_list table tbody tr:first").contains("Delete").click();
cy.get("#accounts_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(
"remove this account"
);
@ -388,7 +391,9 @@ describe("Accounts", () => {
statusCode: 204,
body: null,
});
cy.get("#account_list table tbody tr:first").contains("Delete").click();
cy.get("#accounts_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(
"remove this account"
);
@ -399,37 +404,28 @@ describe("Accounts", () => {
// Delete from show
// Click the "name" link from the list
cy.intercept("GET", "/api/v1/sip2/accounts*", {
statusCode: 200,
body: accounts,
headers: {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
});
cy.visit("/cgi-bin/koha/sip2/accounts");
cy.wait("@get-accounts");
cy.intercept("GET", "/api/v1/sip2/accounts/*", account).as(
"get-account"
);
cy.visit("/cgi-bin/koha/sip2/accounts");
let name_link = cy.get("#account_list table tbody tr:first td:first a");
name_link.should(
"have.text",
account.login_id + " (#" + account.sip_account_id + ")"
let name_link = cy.get(
"#accounts_list table tbody tr:first td:first a"
);
name_link.should("have.text", account.login_id);
name_link.click();
cy.wait("@get-account");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#account_show h2").contains(
cy.get("#accounts_show h2").contains(
"Account #" + account.sip_account_id
);
cy.get("#account_show #toolbar").contains("Delete").click();
cy.get("#accounts_show #toolbar").contains("Delete").click();
cy.get(".alert-warning.confirmation h1").contains(
"remove this account"
);
cy.contains("Yes, delete").click();
//Make sure we return to list after deleting from show
cy.get("#account_list table tbody tr:first");
cy.get("#accounts_list table tbody tr:first");
});
});

View File

@ -13,7 +13,7 @@ describe("Institutions", () => {
error: "Something went wrong",
});
cy.visit("/cgi-bin/koha/sip2/sip2.pl");
cy.get("#navmenulist").contains("Institutions").click();
cy.get(".sidebar_menu").contains("Institutions").click();
cy.get("main div[class='alert alert-warning']").contains(
/Something went wrong/
);
@ -21,7 +21,7 @@ describe("Institutions", () => {
// GET institutions returns empty list
cy.intercept("GET", "/api/v1/sip2/institutions*", []);
cy.visit("/cgi-bin/koha/sip2/institutions");
cy.get("#institution_list").contains(
cy.get("#institutions_list").contains(
"There are no institutions defined"
);
@ -39,7 +39,7 @@ describe("Institutions", () => {
});
cy.intercept("GET", "/api/v1/sip2/institutions/*", institution);
cy.visit("/cgi-bin/koha/sip2/institutions/");
cy.get("#institution_list").contains("Showing 1 to 1 of 1 entries");
cy.get("#institutions_list").contains("Showing 1 to 1 of 1 entries");
});
it("Add institution", () => {
@ -53,14 +53,14 @@ describe("Institutions", () => {
// Click the button in the toolbar
cy.visit("/cgi-bin/koha/sip2/institutions");
cy.contains("New institution").click();
cy.get("#institution_add h2").contains("New institution");
cy.get("#institutions_add h2").contains("New institution");
cy.left_menu_active_item_is("Institutions");
// Fill in the form for normal attributes
cy.get("#institution_add").contains("Submit").click();
cy.get("#institutions_add").contains("Submit").click();
cy.get("input:invalid,textarea:invalid,select:invalid").should(
"have.length",
2
1
);
cy.get("#name").type(institution.name);
cy.get("#implementation").type(institution.implementation);
@ -81,7 +81,7 @@ describe("Institutions", () => {
cy.intercept("POST", "/api/v1/sip2/institutions", {
statusCode: 500,
});
cy.get("#institution_add").contains("Submit").click();
cy.get("#institutions_add").contains("Submit").click();
cy.get("main div[class='alert alert-warning']").contains(
"Something went wrong: Error: Internal Server Error"
@ -92,7 +92,7 @@ describe("Institutions", () => {
statusCode: 201,
body: institution,
});
cy.get("#institution_add").contains("Submit").click();
cy.get("#institutions_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"Institution created"
);
@ -120,12 +120,11 @@ describe("Institutions", () => {
);
// Click the 'Edit' button from the list
cy.get("#institution_list table tbody tr:first")
cy.get("#institutions_list table tbody tr:first")
.contains("Edit")
.click();
cy.wait("@get-institution");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#institution_add h2").contains("Edit institution");
cy.get("#institutions_add h2").contains("Edit institution");
cy.left_menu_active_item_is("Institutions");
// Form has been correctly filled in
@ -151,7 +150,7 @@ describe("Institutions", () => {
delay: 1000,
});
});
cy.get("#institution_add").contains("Submit").click();
cy.get("#institutions_add").contains("Submit").click();
cy.get("main div[class='modal_centered']").contains("Submitting...");
cy.wait(1000);
@ -164,7 +163,7 @@ describe("Institutions", () => {
statusCode: 200,
body: institution,
});
cy.get("#institution_add").contains("Submit").click();
cy.get("#institutions_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"Institution updated"
);
@ -187,16 +186,12 @@ describe("Institutions", () => {
);
cy.visit("/cgi-bin/koha/sip2/institutions");
let name_link = cy.get(
"#institution_list table tbody tr:first td:first a"
);
name_link.should(
"have.text",
institution.name + " (#" + institution.sip_institution_id + ")"
"#institutions_list table tbody tr:first td:first a"
);
name_link.should("have.text", institution.name);
name_link.click();
cy.wait("@get-institution");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#institution_show h2").contains(
cy.get("#institutions_show h2").contains(
"Institution #" + institution.sip_institution_id
);
cy.left_menu_active_item_is("Institutions");
@ -219,7 +214,7 @@ describe("Institutions", () => {
cy.intercept("GET", "/api/v1/sip2/institutions/*", institution);
cy.visit("/cgi-bin/koha/sip2/institutions");
cy.get("#institution_list table tbody tr:first")
cy.get("#institutions_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(
@ -241,7 +236,7 @@ describe("Institutions", () => {
statusCode: 204,
body: null,
});
cy.get("#institution_list table tbody tr:first")
cy.get("#institutions_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(
@ -267,26 +262,22 @@ describe("Institutions", () => {
);
cy.visit("/cgi-bin/koha/sip2/institutions");
let name_link = cy.get(
"#institution_list table tbody tr:first td:first a"
);
name_link.should(
"have.text",
institution.name + " (#" + institution.sip_institution_id + ")"
"#institutions_list table tbody tr:first td:first a"
);
name_link.should("have.text", institution.name);
name_link.click();
cy.wait("@get-institution");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#institution_show h2").contains(
cy.get("#institutions_show h2").contains(
"Institution #" + institution.sip_institution_id
);
cy.get("#institution_show #toolbar").contains("Delete").click();
cy.get("#institutions_show #toolbar").contains("Delete").click();
cy.get(".alert-warning.confirmation h1").contains(
"remove this institution"
);
cy.contains("Yes, delete").click();
//Make sure we return to list after deleting from show
cy.get("#institution_list table tbody tr:first");
cy.get("#institutions_list table tbody tr:first");
});
});

View File

@ -21,7 +21,7 @@ describe("SystemPreferenceOverrides", () => {
error: "Something went wrong",
});
cy.visit("/cgi-bin/koha/sip2/sip2.pl");
cy.get("#navmenulist").contains("System preference overrides").click();
cy.get(".sidebar_menu").contains("System preference overrides").click();
cy.get("main div[class='alert alert-warning']").contains(
/Something went wrong/
);
@ -29,7 +29,7 @@ describe("SystemPreferenceOverrides", () => {
// GET system_preference_overrides returns empty list
cy.intercept("GET", "/api/v1/sip2/system_preference_overrides*", []);
cy.visit("/cgi-bin/koha/sip2/system_preference_overrides");
cy.get("#system_preference_override_list").contains(
cy.get("#system_preference_overrides_list").contains(
"There are no system preference overrides defined"
);
@ -51,7 +51,7 @@ describe("SystemPreferenceOverrides", () => {
system_preference_overrides
);
cy.visit("/cgi-bin/koha/sip2/system_preference_overrides/");
cy.get("#system_preference_override_list").contains(
cy.get("#system_preference_overrides_list").contains(
"Showing 1 to 1 of 1 entries"
);
});
@ -67,13 +67,13 @@ describe("SystemPreferenceOverrides", () => {
// Click the button in the toolbar
cy.visit("/cgi-bin/koha/sip2/system_preference_overrides");
cy.contains("New system preference override").click();
cy.get("#system_preference_override_add h2").contains(
cy.get("#system_preference_overrides_add h2").contains(
"New system preference override"
);
cy.left_menu_active_item_is("System preference overrides");
// Fill in the form for normal attributes
cy.get("#system_preference_override_add").contains("Submit").click();
cy.get("#system_preference_overrides_add").contains("Submit").click();
cy.get("input:invalid,textarea:invalid,select:invalid").should(
"have.length",
2
@ -85,7 +85,7 @@ describe("SystemPreferenceOverrides", () => {
cy.intercept("POST", "/api/v1/sip2/system_preference_overrides", {
statusCode: 500,
});
cy.get("#system_preference_override_add").contains("Submit").click();
cy.get("#system_preference_overrides_add").contains("Submit").click();
cy.get("main div[class='alert alert-warning']").contains(
"Something went wrong: Error: Internal Server Error"
@ -96,7 +96,7 @@ describe("SystemPreferenceOverrides", () => {
statusCode: 201,
body: system_preference_override,
});
cy.get("#system_preference_override_add").contains("Submit").click();
cy.get("#system_preference_overrides_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"System preference override created"
);
@ -126,12 +126,12 @@ describe("SystemPreferenceOverrides", () => {
).as("get-system_preference_overrides");
// Click the 'Edit' button from the list
cy.get("#system_preference_override_list table tbody tr:first")
cy.get("#system_preference_overrides_list table tbody tr:first")
.contains("Edit")
.click();
cy.wait("@get-system_preference_overrides");
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet!
cy.get("#system_preference_override_add h2").contains(
cy.get("#system_preference_overrides_add h2").contains(
"Edit system preference override"
);
cy.left_menu_active_item_is("System preference overrides");
@ -157,7 +157,7 @@ describe("SystemPreferenceOverrides", () => {
});
}
);
cy.get("#system_preference_override_add").contains("Submit").click();
cy.get("#system_preference_overrides_add").contains("Submit").click();
cy.get("main div[class='modal_centered']").contains("Submitting...");
cy.wait(1000);
@ -170,7 +170,7 @@ describe("SystemPreferenceOverrides", () => {
statusCode: 200,
body: system_preference_overrides,
});
cy.get("#system_preference_override_add").contains("Submit").click();
cy.get("#system_preference_overrides_add").contains("Submit").click();
cy.get("main div[class='alert alert-info']").contains(
"System preference override updated"
);
@ -197,7 +197,7 @@ describe("SystemPreferenceOverrides", () => {
);
cy.visit("/cgi-bin/koha/sip2/system_preference_overrides");
cy.get("#system_preference_override_list table tbody tr:first")
cy.get("#system_preference_overrides_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(
@ -219,7 +219,7 @@ describe("SystemPreferenceOverrides", () => {
statusCode: 204,
body: null,
});
cy.get("#system_preference_override_list table tbody tr:first")
cy.get("#system_preference_overrides_list table tbody tr:first")
.contains("Delete")
.click();
cy.get(".alert-warning.confirmation h1").contains(