This commit is contained in:
parent
320af54b3d
commit
4666c1995f
14 changed files with 876 additions and 346 deletions
|
|
@ -100,13 +100,16 @@ void CatalogueContract() {
|
|||
// checkout charges.
|
||||
{
|
||||
// The listing's shipping block is now carrier data, so the
|
||||
// render needs a table. US is priced here on purpose: the
|
||||
// carrier will happily quote it and the shop still must not
|
||||
// advertise it.
|
||||
// render needs a table. Three of these four are priced on purpose
|
||||
// and must still not be advertised: US is refused on insurance, DE
|
||||
// and GB on their missing producer registrations. The carrier will
|
||||
// happily quote all three, which is exactly why the filter is worth
|
||||
// asserting — CH is the only one here besides home that sells.
|
||||
const std::vector<ShipRates> feedTable{
|
||||
{ "NL", { { 2000, 895 } } },
|
||||
{ "CH", { { 2000, 2450 } } },
|
||||
{ "DE", { { 2000, 995 } } },
|
||||
{ "GB", { { 2000, 2450 } } },
|
||||
{ "GB", { { 2000, 3300 } } },
|
||||
{ "US", { { 2000, 1794 } } },
|
||||
};
|
||||
auto pp = Views::RenderProduct(pr, Rates{}, feedTable);
|
||||
|
|
@ -137,6 +140,13 @@ void CatalogueContract() {
|
|||
Check(pp.meta.jsonLd.find("\"8.95\"") != std::string::npos
|
||||
&& pp.meta.jsonLd.find("\"24.50\"") != std::string::npos,
|
||||
"schema: shipping rates come from the carrier table");
|
||||
// And nothing the shop refuses is advertised, whatever the carrier
|
||||
// quotes for it — by rate, so a filter that dropped the country code
|
||||
// but kept the price would still be caught.
|
||||
Check(pp.meta.jsonLd.find("\"9.95\"") == std::string::npos
|
||||
&& pp.meta.jsonLd.find("\"33.00\"") == std::string::npos
|
||||
&& pp.meta.jsonLd.find("\"17.94\"") == std::string::npos,
|
||||
"schema: refused destinations are never advertised");
|
||||
Check(pp.meta.jsonLd.find("\"17.94\"") == std::string::npos
|
||||
&& pp.meta.jsonLd.find("\"US\"") == std::string::npos,
|
||||
"schema: a refused destination is never advertised, priced or not");
|
||||
|
|
@ -378,11 +388,23 @@ void CheckoutPreviewData() {
|
|||
// The blob is a JSON document inside an HTML attribute, so every quote
|
||||
// arrives escaped — matching the escaped form is matching what the
|
||||
// browser actually parses back out.
|
||||
Check(html.find(""x":["US","CA"]") != std::string_view::npos,
|
||||
"checkout: the preview carries the no-sale list verbatim");
|
||||
Check(html.find(""s":["RU","BY","KP"]")
|
||||
!= std::string_view::npos,
|
||||
"checkout: the preview carries the sanctions list verbatim");
|
||||
// `w` is the shipping ALLOW-list: the preview refuses a country by its
|
||||
// ABSENCE here, which is why the payload stays five codes long instead of
|
||||
// enumerating the two hundred that are closed.
|
||||
Check(html.find(""w":["NL","CH","AU","
|
||||
""HK","SG","RS","ME","
|
||||
""AL","XK","GE"]") != std::string_view::npos,
|
||||
"checkout: the preview carries the shipping allow-list verbatim");
|
||||
Check(html.find(""US"") == std::string_view::npos,
|
||||
"checkout: no deny-list survives in the preview payload");
|
||||
// Both refusals ship their own sentence, or the preview would word a decline
|
||||
// differently from the submit that follows it.
|
||||
Check(html.find(""sm"") != std::string_view::npos
|
||||
&& html.find(""rm"") != std::string_view::npos,
|
||||
"checkout: the preview carries a message for each refusal");
|
||||
// The unit weight, which is what selects a bracket out of the carrier
|
||||
// table the same blob carries.
|
||||
Check(html.find(""g":700") != std::string_view::npos,
|
||||
|
|
|
|||
Loading…
Reference in a new issue