Skip to content

Commit

Permalink
Test order scenarios with variations of orderability
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperg committed Mar 2, 2020
1 parent 7ff8603 commit 50ea8ba
Showing 1 changed file with 50 additions and 23 deletions.
73 changes: 50 additions & 23 deletions src/apps/order-material/order-material.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,59 @@ describe("Order material", () => {
cy.contains("Dit afhentningsbibliotek modtager ikke fjernlån");
});

it("Should display message if materials can't be ordered", () => {
cy.server();
cy.route({
method: "GET",
url: "https://openplatform.dbc.dk/v3/libraries*",
status: 200,
response: {
statusCode: 200,
data: [{ willReceiveIll: "1" }]
}
});
[
{
title: "Should display message if a single material can't be ordered",
availability: [{ orderPossible: false }],
orderable: false
},
{
title: "Should display message if a set of materials can't be ordered",
availability: [{ orderPossible: false }, { orderPossible: false }],
orderable: false
},
{
title: "Should display button if a single material can be ordered",
availability: [{ orderPossible: true }],
orderable: true
},
{
title: "Should display button if a set of materials can be ordered",
availability: [{ orderPossible: true }, { orderPossible: false }],
orderable: true
}
].forEach(scenario => {
it(scenario.title, () => {
cy.server();
cy.route({
method: "GET",
url: "https://openplatform.dbc.dk/v3/libraries*",
status: 200,
response: {
statusCode: 200,
data: [{ willReceiveIll: "1" }]
}
});

cy.route({
method: "GET",
url: "https://openplatform.dbc.dk/v3/availability*",
status: 200,
response: {
statusCode: 200,
data: [{ orderPossible: false }, { orderPossible: false }]
}
});
cy.route({
method: "GET",
url: "https://openplatform.dbc.dk/v3/availability*",
status: 200,
response: {
statusCode: 200,
data: scenario.availability
}
});

cy.visit("/iframe.html?id=apps-order-material--entry");
cy.visit("/iframe.html?id=apps-order-material--entry");

cy.contains("Bestil materiale").should("not.exist");
cy.contains("Kan ikke fjernlånes");
if (scenario.orderable) {
cy.contains("Bestil materiale");
} else {
cy.contains("Bestil materiale").should("not.exist");
cy.contains("Kan ikke fjernlånes");
}
});
});

it("Should send order request to OpenPlatform when clicked", () => {
Expand Down

0 comments on commit 50ea8ba

Please sign in to comment.