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

(-)a/t/cypress/integration/t/insertData.ts (-1 / +46 lines)
Lines 7-12 const { APIClient } = require("./../../plugins/dist/api-client.cjs.js"); Link Here
7
let client = APIClient.default;
7
let client = APIClient.default;
8
8
9
describe("insertData", () => {
9
describe("insertData", () => {
10
11
    let tablesToCheck = [
12
        "borrowers",
13
        "branches",
14
        "items",
15
        "biblio",
16
        "reserves",
17
    ];
18
    beforeEach(() => {
19
        const counts = {};
20
21
        const queries = tablesToCheck.map(table => {
22
            return cy
23
                .task("query", {
24
                    sql: `SELECT COUNT(*) as count FROM ${table}`,
25
                })
26
                .then(result => {
27
                    counts[table] = result[0].count;
28
                });
29
        });
30
31
        cy.wrap(Promise.all(queries)).then(() => {
32
            cy.wrap(counts).as("initialCounts");
33
        });
34
    });
35
10
    describe("insertSampleBiblio", () => {
36
    describe("insertSampleBiblio", () => {
11
        it("should generate library and item type", () => {
37
        it("should generate library and item type", () => {
12
            cy.task("insertSampleBiblio", { item_count: 3 }).then(objects => {
38
            cy.task("insertSampleBiblio", { item_count: 3 }).then(objects => {
Lines 175-178 describe("insertData", () => { Link Here
175
            );
201
            );
176
        });
202
        });
177
    });
203
    });
204
205
    afterEach(function () {
206
        cy.get("@initialCounts").then(initialCounts => {
207
            const queries = tablesToCheck.map(table => {
208
                return cy
209
                    .task("query", {
210
                        sql: `SELECT COUNT(*) as count FROM ${table}`,
211
                    })
212
                    .then(result => {
213
                        const finalCount = result[0].count;
214
                        expect(
215
                            finalCount,
216
                            `Row count for ${table} should match`
217
                        ).to.eq(initialCounts[table]);
218
                    });
219
            });
220
221
            return Promise.all(queries);
222
        });
223
    });
178
});
224
});
179
- 

Return to bug 40181