Lines 6-28
describe("Test data", () => {
Link Here
|
6 |
cy.title().should("eq", "Koha staff interface"); |
6 |
cy.title().should("eq", "Koha staff interface"); |
7 |
}); |
7 |
}); |
8 |
|
8 |
|
9 |
it("should create an object based on passed data", () => { |
9 |
// yarn cypress run --config video=false,screenshotOnRunFailure=false --spec t/cypress/integration/DataTest_spec.ts |
|
|
10 |
|
11 |
it("should create an object based on passed data and remove it", () => { |
12 |
var patron_count = 0; |
13 |
cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { |
14 |
patron_count = result[0].count; |
15 |
}); |
16 |
|
10 |
const testPatronData = { |
17 |
const testPatronData = { |
11 |
firstname: "Cypress", |
18 |
firstname: "CypressTest", |
12 |
surname: "Test", |
19 |
surname: "SurnameTest", |
|
|
20 |
cardnumber: "td" + Math.floor(Math.random() * 8), |
13 |
}; |
21 |
}; |
14 |
|
22 |
|
15 |
cy.exec(`perl t/cypress/support/cypress_patron.pl --setup ${patron}`); |
23 |
cy.buildObject("Koha::Patrons", testPatronData); |
16 |
cy.exec(buildCommand) |
24 |
|
17 |
cy.query( |
25 |
cy.query( |
18 |
"SELECT firstname, surname FROM borrowers WHERE firstname=?", |
26 |
"SELECT firstname, surname FROM borrowers WHERE firstname=?", |
19 |
"Cypress" |
27 |
testPatronData.firstname |
20 |
).then(result => { |
28 |
).then(result => { |
21 |
expect(result[0].surname).to.equal('Test'); |
29 |
expect(result[0].surname).to.equal(testPatronData.surname); |
22 |
}); |
30 |
}); |
23 |
cy.exec(`perl t/cypress/support/cypress_patron.pl --teardown ${patron}`); |
|
|
24 |
|
31 |
|
25 |
}); |
32 |
cy.buildObject("Koha::Patrons", testPatronData, "teardown"); |
26 |
|
33 |
|
27 |
|
34 |
cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { |
|
|
35 |
expect(result[0].count).to.equal(patron_count); |
36 |
}); |
37 |
}); |
28 |
}); |
38 |
}); |