Bug 40181: Make sure data won't be added by insertData
We are here testing that data inserted by insertData tasks can be
easily removed from the DB using deleteSampleObjects
Test plan:
Cypress test t/cypress/integration/t/insertData.ts must pass
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 34e4b19ff5)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
0810cc3b7a
commit
f8e6f72f26
|
|
@ -2,6 +2,31 @@ const { query } = require("./../../plugins/db.js");
|
|||
const { getBasicAuthHeader } = require("./../../plugins/auth.js");
|
||||
|
||||
describe("insertData", () => {
|
||||
let tablesToCheck = [
|
||||
"borrowers",
|
||||
"branches",
|
||||
"items",
|
||||
"biblio",
|
||||
"reserves",
|
||||
];
|
||||
beforeEach(() => {
|
||||
const counts = {};
|
||||
|
||||
const queries = tablesToCheck.map(table => {
|
||||
return cy
|
||||
.task("query", {
|
||||
sql: `SELECT COUNT(*) as count FROM ${table}`,
|
||||
})
|
||||
.then(result => {
|
||||
counts[table] = result[0].count;
|
||||
});
|
||||
});
|
||||
|
||||
cy.wrap(Promise.all(queries)).then(() => {
|
||||
cy.wrap(counts).as("initialCounts");
|
||||
});
|
||||
});
|
||||
|
||||
describe("deleteSampleObjects", () => {
|
||||
it("should delete everything from Object", () => {
|
||||
cy.task("insertSampleBiblio", { item_count: 2 }).then(objects => {
|
||||
|
|
@ -189,4 +214,24 @@ describe("insertData", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
cy.get("@initialCounts").then(initialCounts => {
|
||||
const queries = tablesToCheck.map(table => {
|
||||
return cy
|
||||
.task("query", {
|
||||
sql: `SELECT COUNT(*) as count FROM ${table}`,
|
||||
})
|
||||
.then(result => {
|
||||
const finalCount = result[0].count;
|
||||
expect(
|
||||
finalCount,
|
||||
`Row count for ${table} should match`
|
||||
).to.eq(initialCounts[table]);
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(queries);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue