Bug 40067: Add a cypress test
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 79567178ec)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
67319ff0b8
commit
e692023eb0
|
|
@ -1,64 +1,3 @@
|
|||
const getVendor = () => {
|
||||
return {
|
||||
accountnumber: "69823",
|
||||
active: true,
|
||||
address1: "6897 Library Rd",
|
||||
address2: "Springfield, MA 44224",
|
||||
address3: null,
|
||||
address4: null,
|
||||
aliases: [{ alias: "Test alias" }],
|
||||
baskets: [],
|
||||
baskets_count: 0,
|
||||
contacts: [
|
||||
{
|
||||
name: "Test contact",
|
||||
position: "Test",
|
||||
email: "test@email.com",
|
||||
phone: "0123456789",
|
||||
notes: "Some interesting notes",
|
||||
altphone: "9876543210",
|
||||
fax: "Who uses fax these days?",
|
||||
acqprimary: false,
|
||||
orderacquisition: false,
|
||||
claimacquisition: false,
|
||||
serialsprimary: false,
|
||||
claimissues: false,
|
||||
},
|
||||
],
|
||||
deliverytime: 3,
|
||||
discount: 10,
|
||||
external_id: "test1234",
|
||||
fax: "555-555-9999",
|
||||
gst: false,
|
||||
id: 1,
|
||||
interfaces: [
|
||||
{
|
||||
type: "interface",
|
||||
name: "fancy website",
|
||||
uri: "www.uri.com",
|
||||
login: "login",
|
||||
password: "password",
|
||||
account_email: "email@email.com",
|
||||
notes: "This is a website",
|
||||
},
|
||||
],
|
||||
invoice_currency: "USD",
|
||||
invoice_includes_gst: false,
|
||||
invoices_count: 0,
|
||||
list_currency: "USD",
|
||||
list_includes_gst: false,
|
||||
name: "My Vendor",
|
||||
notes: "Sample vendor",
|
||||
phone: "555-555-5555",
|
||||
postal: "567 Main St. PO Box 25 Springfield, MA 44224",
|
||||
subscriptions: [],
|
||||
subscriptions_count: 0,
|
||||
tax_rate: 0.1965,
|
||||
type: "Print books",
|
||||
url: "https://koha-community.org/",
|
||||
};
|
||||
};
|
||||
|
||||
describe("Vendor CRUD operations", () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
|
|
@ -72,7 +11,7 @@ describe("Vendor CRUD operations", () => {
|
|||
cy.visit("/cgi-bin/koha/acquisition/vendors");
|
||||
cy.get("#vendors_list").contains("There are no vendors defined");
|
||||
|
||||
const vendor = getVendor();
|
||||
const vendor = cy.getVendor();
|
||||
cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
|
||||
statusCode: 200,
|
||||
body: [vendor],
|
||||
|
|
@ -86,7 +25,7 @@ describe("Vendor CRUD operations", () => {
|
|||
});
|
||||
|
||||
it("should add a vendor", () => {
|
||||
const vendor = getVendor();
|
||||
const vendor = cy.getVendor();
|
||||
|
||||
cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
|
||||
statusCode: 200,
|
||||
|
|
@ -180,7 +119,7 @@ describe("Vendor CRUD operations", () => {
|
|||
});
|
||||
|
||||
it("should edit a vendor", () => {
|
||||
const vendor = getVendor();
|
||||
const vendor = cy.getVendor();
|
||||
|
||||
cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
|
||||
statusCode: 200,
|
||||
|
|
@ -219,7 +158,7 @@ describe("Vendor CRUD operations", () => {
|
|||
});
|
||||
|
||||
it("should show a vendor", () => {
|
||||
const vendor = getVendor();
|
||||
const vendor = cy.getVendor();
|
||||
|
||||
// Click the "name" link from the list
|
||||
cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
|
||||
|
|
@ -249,7 +188,7 @@ describe("Vendor CRUD operations", () => {
|
|||
});
|
||||
|
||||
it("should delete a vendor", () => {
|
||||
const vendor = getVendor();
|
||||
const vendor = cy.getVendor();
|
||||
|
||||
// Delete from list
|
||||
// Click the 'Delete' button from the list
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
describe("Sticky toolbar", () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.title().should("eq", "Koha staff interface");
|
||||
});
|
||||
|
||||
it("Should open non-Vue links correctly in the same tab", () => {
|
||||
const vendor = cy.getVendor();
|
||||
vendor.baskets_count = 1;
|
||||
// Click the "name" link from the list
|
||||
cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
|
||||
statusCode: 200,
|
||||
body: [vendor],
|
||||
headers: {
|
||||
"X-Base-Total-Count": "1",
|
||||
"X-Total-Count": "1",
|
||||
},
|
||||
});
|
||||
cy.visit("/cgi-bin/koha/acquisition/vendors");
|
||||
cy.intercept(
|
||||
"GET",
|
||||
new RegExp("/api/v1/acquisitions/vendors/(?!config$).+"),
|
||||
vendor
|
||||
).as("get-vendor");
|
||||
|
||||
const name_link = cy.get(
|
||||
"#vendors_list table tbody tr:first td:first a"
|
||||
);
|
||||
name_link.click();
|
||||
cy.get("#toolbar a").contains("Receive shipments").click();
|
||||
cy.get("h1").contains("Receive shipment from vendor " + vendor.name);
|
||||
});
|
||||
});
|
||||
|
|
@ -1813,6 +1813,67 @@ cy.getSushiService = () => {
|
|||
};
|
||||
};
|
||||
|
||||
cy.getVendor = () => {
|
||||
return {
|
||||
accountnumber: "69823",
|
||||
active: true,
|
||||
address1: "6897 Library Rd",
|
||||
address2: "Springfield, MA 44224",
|
||||
address3: null,
|
||||
address4: null,
|
||||
aliases: [{ alias: "Test alias" }],
|
||||
baskets: [],
|
||||
baskets_count: 0,
|
||||
contacts: [
|
||||
{
|
||||
name: "Test contact",
|
||||
position: "Test",
|
||||
email: "test@email.com",
|
||||
phone: "0123456789",
|
||||
notes: "Some interesting notes",
|
||||
altphone: "9876543210",
|
||||
fax: "Who uses fax these days?",
|
||||
acqprimary: false,
|
||||
orderacquisition: false,
|
||||
claimacquisition: false,
|
||||
serialsprimary: false,
|
||||
claimissues: false,
|
||||
},
|
||||
],
|
||||
deliverytime: 3,
|
||||
discount: 10,
|
||||
external_id: "test1234",
|
||||
fax: "555-555-9999",
|
||||
gst: false,
|
||||
id: 1,
|
||||
interfaces: [
|
||||
{
|
||||
type: "interface",
|
||||
name: "fancy website",
|
||||
uri: "www.uri.com",
|
||||
login: "login",
|
||||
password: "password",
|
||||
account_email: "email@email.com",
|
||||
notes: "This is a website",
|
||||
},
|
||||
],
|
||||
invoice_currency: "USD",
|
||||
invoice_includes_gst: false,
|
||||
invoices_count: 0,
|
||||
list_currency: "USD",
|
||||
list_includes_gst: false,
|
||||
name: "My Vendor",
|
||||
notes: "Sample vendor",
|
||||
phone: "555-555-5555",
|
||||
postal: "567 Main St. PO Box 25 Springfield, MA 44224",
|
||||
subscriptions: [],
|
||||
subscriptions_count: 0,
|
||||
tax_rate: 0.1965,
|
||||
type: "Print books",
|
||||
url: "https://koha-community.org/",
|
||||
};
|
||||
};
|
||||
|
||||
const mysql = require("cypress-mysql");
|
||||
mysql.addCommands();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue