View | Details | Raw Unified | Return to bug 40430
Collapse All | Expand All

(-)a/t/cypress/integration/Toolbar_spec.ts (-31 / +50 lines)
Lines 1-39 Link Here
1
describe("Sticky toolbar", () => {
1
describe("Sticky toolbar - basic behavior", () => {
2
    beforeEach(() => {
2
    beforeEach(() => {
3
        cy.login();
3
        cy.login();
4
        cy.title().should("eq", "Koha staff interface");
4
        cy.title().should("eq", "Koha staff interface");
5
    });
5
    });
6
6
7
    it("Should open non-Vue links correctly in the same tab", () => {
8
        const vendor = cy.getVendor();
9
        vendor.baskets_count = 1;
10
        // Click the "name" link from the list
11
        cy.intercept("GET", "/api/v1/acquisitions/vendors\?*", {
12
            statusCode: 200,
13
            body: [vendor],
14
            headers: {
15
                "X-Base-Total-Count": "1",
16
                "X-Total-Count": "1",
17
            },
18
        }).as("get-vendors");
19
        cy.intercept(
20
            "GET",
21
            new RegExp("/api/v1/acquisitions/vendors/(?!config$).+"),
22
            vendor
23
        ).as("get-vendor");
24
25
        cy.visit("/cgi-bin/koha/acquisition/vendors");
26
        cy.wait("@get-vendors");
27
28
        const name_link = cy.get(
29
            "#vendors_list table tbody tr:first td:first a"
30
        );
31
        name_link.click();
32
        cy.wait("@get-vendor");
33
        cy.get("#toolbar a").contains("Receive shipments").click();
34
        cy.get("h1").contains("Receive shipment from vendor " + vendor.name);
35
    });
36
37
    it("Should stick on scroll", () => {
7
    it("Should stick on scroll", () => {
38
        cy.visit("/cgi-bin/koha/acqui/acqui-home.pl");
8
        cy.visit("/cgi-bin/koha/acqui/acqui-home.pl");
39
9
Lines 46-48 describe("Sticky toolbar", () => { Link Here
46
        cy.get("#toolbar").should("not.have.class", "floating");
16
        cy.get("#toolbar").should("not.have.class", "floating");
47
    });
17
    });
48
});
18
});
19
20
describe("Sticky toolbar - vendors", () => {
21
    beforeEach(() => {
22
        cy.login();
23
        cy.title().should("eq", "Koha staff interface");
24
25
        cy.task("buildSampleObject", {
26
            object: "vendor",
27
            values: { active: 1 },
28
        })
29
            .then(generatedVendor => {
30
                delete generatedVendor.list_currency;
31
                delete generatedVendor.invoice_currency;
32
                return cy.task("insertObject", {
33
                    type: "vendor",
34
                    object: generatedVendor,
35
                });
36
            })
37
            .then(vendor => {
38
                cy.wrap(vendor).as("vendor");
39
                return cy.task("buildSampleObject", {
40
                    object: "basket",
41
                    values: { vendor_id: vendor.id },
42
                });
43
            })
44
            .then(generatedBasket => {
45
                return cy.task("insertObject", {
46
                    type: "basket",
47
                    object: generatedBasket,
48
                });
49
            })
50
            .then(basket => {
51
                cy.wrap(basket).as("basket");
52
            });
53
    });
54
    afterEach(function () {
55
        cy.task("deleteSampleObjects", [
56
            { vendor: this.vendor, basket: this.basket },
57
        ]);
58
    });
59
    it("Should open non-Vue links correctly in the same tab", function () {
60
        cy.visit(`/cgi-bin/koha/acquisition/vendors/${this.vendor.id}`);
61
62
        cy.get("#toolbar a").contains("Receive shipments").click();
63
        cy.get("h1").contains(
64
            `Receive shipment from vendor ${this.vendor.name}`
65
        );
66
    });
67
});
(-)a/t/cypress/plugins/insertData.js (-1 / +61 lines)
Lines 333-338 const deleteSampleObjects = async allObjects => { Link Here
333
        hold: "holds",
333
        hold: "holds",
334
        checkout: "checkouts",
334
        checkout: "checkouts",
335
        old_checkout: "old_checkouts",
335
        old_checkout: "old_checkouts",
336
        basket: "baskets",
337
        vendor: "vendors",
336
        patron: "patrons",
338
        patron: "patrons",
337
        item: "items",
339
        item: "items",
338
        biblio: "biblios",
340
        biblio: "biblios",
Lines 360-365 const deleteSampleObjects = async allObjects => { Link Here
360
        "holds",
362
        "holds",
361
        "checkouts",
363
        "checkouts",
362
        "old_checkouts",
364
        "old_checkouts",
365
        "baskets",
366
        "vendors",
363
        "patrons",
367
        "patrons",
364
        "items",
368
        "items",
365
        "biblios",
369
        "biblios",
Lines 431-436 const deleteSampleObjects = async allObjects => { Link Here
431
                    values: ids,
435
                    values: ids,
432
                });
436
                });
433
                break;
437
                break;
438
            case "baskets":
439
                ids = objects.map(i => i.basket_id);
440
                await query({
441
                    sql: `DELETE FROM aqbasket WHERE basketno IN (${ids.map(() => "?").join(",")})`,
442
                    values: ids,
443
                });
444
                break;
445
            case "vendors":
446
                ids = objects.map(i => i.id);
447
                await query({
448
                    sql: `DELETE FROM aqbooksellers WHERE id IN (${ids.map(() => "?").join(",")})`,
449
                    values: ids,
450
                });
451
                break;
434
            default:
452
            default:
435
                throw Error(
453
                throw Error(
436
                    `Not implemented yet: cannot deleted object '${type}'`
454
                    `Not implemented yet: cannot deleted object '${type}'`
Lines 544-549 const insertObject = async ({ type, object, baseUrl, authHeader }) => { Link Here
544
            baseUrl,
562
            baseUrl,
545
            authHeader,
563
            authHeader,
546
        });
564
        });
565
    } else if (type == "vendor") {
566
        const {
567
            id,
568
            baskets_count,
569
            invoices_count,
570
            subscriptions_count,
571
            external_id,
572
            aliases,
573
            baskets,
574
            contacts,
575
            contracts,
576
            interfaces,
577
            invoices,
578
            ...vendor
579
        } = object;
580
581
        let endpoint = "/api/v1/acquisitions/vendors";
582
583
        return apiPost({
584
            endpoint,
585
            body: vendor,
586
            baseUrl,
587
            authHeader,
588
        });
589
    } else if (type == "basket") {
590
        const keysToKeep = ["name", "vendor_id", "close_date"];
591
        const basket = Object.fromEntries(
592
            Object.entries(object).filter(([key]) => keysToKeep.includes(key))
593
        );
594
        return query({
595
            sql: "INSERT INTO aqbasket(basketname, booksellerid, closedate) VALUES (?, ?, ?)",
596
            values: [basket.name, basket.vendor_id, basket.close_date],
597
        })
598
            .then(result => {
599
                const basket_id = result.insertId;
600
                // FIXME We need /acquisitions/baskets/:basket_id
601
                return apiGet({
602
                    endpoint: `/api/v1/acquisitions/baskets?q={"basket_id":"${basket_id}"}`,
603
                    baseUrl,
604
                    authHeader,
605
                });
606
            })
607
            .then(baskets => baskets[0]);
547
    } else {
608
    } else {
548
        throw Error(`Unsupported object type '${type}' to insert`);
609
        throw Error(`Unsupported object type '${type}' to insert`);
549
    }
610
    }
550
- 

Return to bug 40430