-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from uktrade/feature/tet-680-order-receipt-pa…
…ge-e2e-tests create test data, add cypress tests for the receipt page
- Loading branch information
Showing
7 changed files
with
184 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<table> | ||
<table data-test="cost-table"> | ||
<thead> | ||
<tr> | ||
<th>Order number</th> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const { paidQuote } = require("../test-data"); | ||
|
||
describe("Reciept spec", () => { | ||
const order = paidQuote; | ||
|
||
context( | ||
"When clicking on the 'View your payment receipt' in the order page", | ||
() => { | ||
it("should take you to the receipt page", () => { | ||
cy.visit(`http://localhost:4000/${order.public_token}`); | ||
cy.contains("View your payment receipt").click(); | ||
cy.get('[data-test="heading"]') | ||
.should("exist") | ||
.and("have.text", "Receipt"); | ||
}); | ||
} | ||
); | ||
|
||
context("When on the receipt page", () => { | ||
beforeEach(() => { | ||
cy.visit(`http://localhost:4000/${order.public_token}/receipt`); | ||
}); | ||
|
||
it("should show the address of the company the receipt is for", () => { | ||
cy.contains("To") | ||
.should("exist") | ||
.parent() | ||
.and("contain", order.billing_company_name) | ||
.and("contain", order.billing_address_town) | ||
.and("contain", order.billing_address_1) | ||
.and("contain", order.billing_address_postcode) | ||
.and("contain", order.billing_address_country); | ||
}); | ||
|
||
it("should show the invoice number and a receipt date", () => { | ||
cy.contains("Invoice number").should("exist"); | ||
cy.contains("Receipt date").should("exist"); | ||
}); | ||
|
||
it("should show the invoice adderss and VAT number", () => { | ||
cy.contains("From").should("exist"); | ||
cy.contains("VAT number").should("exist"); | ||
}); | ||
|
||
it("should show a table with the order number, the description and the amount", () => { | ||
cy.get('[data-test="cost-table"]') | ||
.should("exist") | ||
.and("contain", order.reference) | ||
.and("contain", `UK Government support in ${order.primaryMarket.name}`) | ||
.and("contain", order.subtotal_cost); | ||
}); | ||
|
||
it("should show the payments heading with the number of payments that were made", () => { | ||
cy.get('[data-test="payments-heading"]') | ||
.should("exist") | ||
.and("contain", "Payment details") | ||
.children() | ||
.and("contain", `(${order.payments.length} payments)`); | ||
}); | ||
|
||
it("should show the information for each payment", () => { | ||
cy.get('[data-test="payment-1"]') | ||
.should("exist") | ||
.and("contain", "Payment 1") | ||
.and("contain", "Method") | ||
.and("contain", order.payments[0].method) | ||
.and("contain", "Amount received") | ||
.and("contain", order.payments[0].amount) | ||
.and("contain", "Received on"); | ||
|
||
cy.get('[data-test="payment-2"]') | ||
.should("exist") | ||
.and("contain", "Payment 2") | ||
.and("contain", "Method") | ||
.and("contain", order.payments[1].method) | ||
.and("contain", "Amount received") | ||
.and("contain", order.payments[1].amount) | ||
.and("contain", "Received on"); | ||
}); | ||
|
||
it("should take you to the order history page when clicking 'View you order history' link", () => { | ||
cy.get('[data-test="view-order-history-link"]') | ||
.should("exist") | ||
.click() | ||
.location("pathname") | ||
.should("eq", `/${order.public_token}`); | ||
|
||
cy.contains("Your order").should("exist"); | ||
}); | ||
|
||
it("should have a 'Print this page' link", () => { | ||
cy.contains("Print this page").should("exist"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export const quoteAwaitingAcceptance = { | ||
reference: "WHY589/23", | ||
created_on: "2024-03-08T13:56:12.108209Z", | ||
company: "fc3530bc-383c-4b18-94c8-8fbe918bee31", | ||
contact: "9b1138ab-ec7b-497f-b8c3-27fed21694ef", | ||
primary_market: "5daf72a6-5d95-e211-a939-e4115bead28a ", | ||
sector: "355f977b-8ac3-e211-a646-e4115bead28a", | ||
service_types: ["22fc9edd-41a5-4182-ba4e-baacc681d5f7"], | ||
description: "test order", | ||
public_token: "7AGZC7uaAIV-5L34J5lnZXHvFG9J1xnbBQnieAUCn-LRJpr-QA", | ||
delivery_date: "2030-05-07", | ||
discount_value: 0, | ||
vat_status: "outside_eu", | ||
net_cost: 500000, | ||
subtotal_cost: 500000, | ||
vat_cost: 0, | ||
total_cost: 500000, | ||
billing_company_name: "Motorleaf", | ||
billing_address_1: "5000 Rue Saint-Patrick,", | ||
billing_address_town: "Montréal", | ||
billing_address_postcode: "H4E 1A8", | ||
billing_address_country: "Canada", | ||
}; | ||
|
||
export const acceptedQuote = { | ||
reference: "RYM547/24", | ||
created_on: "2024-03-08T13:56:12.108209Z", | ||
company: "fc3530bc-383c-4b18-94c8-8fbe918bee31", | ||
contact: "9b1138ab-ec7b-497f-b8c3-27fed21694ef", | ||
primary_market: "5daf72a6-5d95-e211-a939-e4115bead28a", | ||
sector: "355f977b-8ac3-e211-a646-e4115bead28a", | ||
service_types: ["22fc9edd-41a5-4182-ba4e-baacc681d5f7"], | ||
description: "test order", | ||
public_token: "XXMPH3b2185a7Vpe2f3RiI5HXT0Nshrck_6xGJuRp4UAsA6vkQ", | ||
delivery_date: "2030-05-07", | ||
discount_value: 0, | ||
vat_status: "outside_eu", | ||
net_cost: 500000, | ||
subtotal_cost: 500000, | ||
vat_cost: 0, | ||
total_cost: 500000, | ||
billing_company_name: "Motorleaf", | ||
billing_address_1: "5000 Rue Saint-Patrick,", | ||
billing_address_town: "Montréal", | ||
billing_address_postcode: "H4E 1A8", | ||
billing_address_country: "Canada", | ||
}; | ||
|
||
export const paidQuote = { | ||
reference: "CJC167/23", | ||
status: "draft", | ||
description: "test order paid", | ||
public_token: "h93Dn7DKvMLbUB5Yz2h5z7dL1mXXGUa_UiPNBkVoyKLmBE29YQ", | ||
primaryMarket: { name: "Canada" }, | ||
delivery_date: "2030-05-07", | ||
vat_status: "outside_eu", | ||
subtotal_cost: "£1,000.00", | ||
billing_company_name: "Motorleaf", | ||
billing_address_1: "5000 Rue Saint-Patrick,", | ||
billing_address_town: "Montréal", | ||
billing_address_postcode: "H4E 1A8", | ||
billing_address_country: "Canada", | ||
payments: [ | ||
{ method: "Bacs", amount: "£500" }, | ||
{ method: "Manual", amount: "£500" }, | ||
], | ||
}; |