diff --git a/lib/billing.ts b/lib/billing.ts index 8a966d9a..40c37523 100644 --- a/lib/billing.ts +++ b/lib/billing.ts @@ -7,7 +7,7 @@ import { hoistCountry } from "./extension"; -const selectors = { +export const selectors = { line_1: '[name="street[0]"]', line_2: '[name="street[1]"]', line_3: '[name="street[2]"]', diff --git a/test/snapshot/cypress/integration/customer-checkout-billing.spec.ts b/test/snapshot/cypress/integration/customer-checkout-billing.spec.ts index 01eab28e..fa9be2a4 100644 --- a/test/snapshot/cypress/integration/customer-checkout-billing.spec.ts +++ b/test/snapshot/cypress/integration/customer-checkout-billing.spec.ts @@ -41,17 +41,24 @@ describe("Customer address form", () => { }); }); + // Stick to selector from bindings + // Avoid early optimisation (putting tests in util functions) + + describe("setup", () => { - it("hoists country field"); + // 1. Country field is lifted before address lines + // 2. Select US - postcode lookup and autocomplete disables + // 3. Select UK - postcode lookup and autocomplete enables + it("loads address validation tools on page"); }); describe("autocomplete", () => { + // Search for address from line 1 it("enables address search on line 1"); - it("hides if unsupported country selected"); }); describe("postcode lookup", () => { + // Search for postcode in postcode lookup it("enables postcode lookup"); - it("hides if unsupported country selected"); }); }); diff --git a/test/snapshot/cypress/integration/customer-checkout-shipping.spec.ts b/test/snapshot/cypress/integration/customer-checkout-shipping.spec.ts new file mode 100644 index 00000000..fa9be2a4 --- /dev/null +++ b/test/snapshot/cypress/integration/customer-checkout-shipping.spec.ts @@ -0,0 +1,64 @@ +/// + +import { Config } from "@ideal-postcodes/jsutil"; +import { address as fixtures } from "@ideal-postcodes/api-fixtures"; +const address = fixtures.jersey; + +declare global { + interface Window { + idpcConfig: Partial; + } +} + +describe("Customer address form", () => { + before(() => { + cy.visit("./fixtures/customer-checkout-billing.html", { + onBeforeLoad: window => { + window.idpcConfig = { + apiKey: Cypress.env("API_KEY"), + populateOrganisation: true, + populateCounty: true, + autocomplete: true, + postcodeLookup: true, + autocompleteOverride: { + checkKey: false + }, + postcodeLookupOverride: { + checkKey: false + } + }; + }, + onLoad: window => { + const document = window.document; + const script = document.createElement("script"); + script.setAttribute("type", "text/javascript"); + script.setAttribute( + "src", + "http://localhost:60154/test/snapshot/fixtures/binding.js" + ); + document.head.appendChild(script); + } + }); + }); + + // Stick to selector from bindings + // Avoid early optimisation (putting tests in util functions) + + + describe("setup", () => { + // 1. Country field is lifted before address lines + // 2. Select US - postcode lookup and autocomplete disables + // 3. Select UK - postcode lookup and autocomplete enables + it("loads address validation tools on page"); + }); + + describe("autocomplete", () => { + // Search for address from line 1 + it("enables address search on line 1"); + }); + + describe("postcode lookup", () => { + // Search for postcode in postcode lookup + it("enables postcode lookup"); + }); +});