Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ JSON validation for amp-story-shopping config #37474

Merged
merged 132 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 128 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
f4578ce
added camelcase to shopping config files
jshamble Jan 25, 2022
08ed0ea
added attribute validators for validate config
jshamble Jan 25, 2022
343505f
added upper limit for max string length
jshamble Jan 25, 2022
6012335
Merge branch 'main' into shoppingJSONValidation
jshamble Jan 25, 2022
1e8f51e
added validate number and optional attributes
jshamble Jan 25, 2022
1e087c1
optimzied arrays
jshamble Jan 25, 2022
7a1bcd0
spruced up required and optional attribute blaidtor
jshamble Jan 25, 2022
4f03c3b
added in proper valdiation checks using reduce funcitons
jshamble Jan 25, 2022
1cb969c
Added in required attributes
jshamble Jan 25, 2022
2d0b837
added correct unit tests
jshamble Jan 27, 2022
ca49d98
added correct attribtues to the visual diff tests
jshamble Jan 27, 2022
5154d0b
fixed JSON formatting of remote config
jshamble Jan 27, 2022
fca4c71
finished writing unit tests for config
jshamble Jan 28, 2022
71d15ca
added in merge conflicts
jshamble Jan 29, 2022
304decc
added camelCase
jshamble Jan 29, 2022
8972268
fixed merge conflicts
jshamble Jan 29, 2022
371b63a
fixed unit test
jshamble Jan 29, 2022
27439de
changed producttagid to prodcutId
jshamble Jan 31, 2022
b845f04
Fixed a few find and replace bugs
jshamble Feb 1, 2022
eaa33ab
resolved merge coflicts for validation
jshamble Feb 1, 2022
1b8d825
added tempalte literals
jshamble Feb 1, 2022
f2ddeda
fix reduce array
jshamble Feb 1, 2022
67b20df
removed unused fiedls
jshamble Feb 2, 2022
689ffdf
changed test string
jshamble Feb 2, 2022
45810b6
udpated test to remove unusd fields
jshamble Feb 2, 2022
ca6437f
fixed merge conflicts with config file
jshamble Feb 2, 2022
5ff7a95
added better vladiation logic
jshamble Feb 3, 2022
e572f0d
resolved merge conflict
jshamble Feb 3, 2022
879748d
fixed unit test
jshamble Feb 3, 2022
962082c
updated unit tests
jshamble Feb 3, 2022
323e5fb
removed unued variable
jshamble Feb 7, 2022
8525bb1
refactored unit tests and typedefs
jshamble Feb 8, 2022
c7fdf1d
test, do not merge
jshamble Feb 9, 2022
f80405d
added in test that throw errors
jshamble Feb 9, 2022
066b74e
fixed a few validation PR things
jshamble Feb 10, 2022
77b9216
Added alt attribute for product images
jshamble Feb 10, 2022
2807b20
udpated visual diff tests
jshamble Feb 10, 2022
d4d61a3
accepted incoming change
jshamble Feb 11, 2022
e281376
added better string test
jshamble Feb 11, 2022
cc287f2
added update to config
jshamble Feb 14, 2022
fc96279
Added in aggregate enhancement for validation
jshamble Feb 14, 2022
02f9614
removed page attachment as it's lazy lodaded
jshamble Feb 14, 2022
df21db3
added in logic to skip optional attributes
jshamble Feb 14, 2022
66434f8
updated unit tests
jshamble Feb 14, 2022
f4a7dc7
updated unit test
jshamble Feb 14, 2022
13c97b5
updated unit tests
jshamble Feb 14, 2022
97324a7
updated unit tests
jshamble Feb 14, 2022
5fc78b5
updated unit test
jshamble Feb 15, 2022
9eacbea
added reducer logic for config valdiation
jshamble Feb 16, 2022
62eae59
added essetial fields method
jshamble Feb 16, 2022
5009a9c
dupated code path to the correc texecution path
jshamble Feb 16, 2022
894490e
removed bad console log
jshamble Feb 16, 2022
00bc835
removed unnnescessary exports
jshamble Feb 16, 2022
753d3f1
rmeoved unnened exports
jshamble Feb 16, 2022
bacb336
removed extra config valdiation
jshamble Feb 16, 2022
747cb26
resolved merge conflicts
jshamble Feb 18, 2022
f055eae
fixed unit test for shopping config
jshamble Feb 18, 2022
5dc690f
amp story shopping lang de
jshamble Feb 18, 2022
be3c5e3
added in vlaidation unit tests
jshamble Feb 24, 2022
650e553
Addd unit tests to work
jshamble Feb 24, 2022
62babe7
added alt attribute
jshamble Feb 24, 2022
4d194ca
removed alt code
jshamble Feb 24, 2022
f5de054
fixed merge conflicts
jshamble Feb 28, 2022
2a3a8d0
relsolved merge conflicts
jshamble Feb 28, 2022
c68410f
added remove shopping tag by index logic
jshamble Feb 28, 2022
57cedbd
added validation config checks for Arraay, obejcts, added stoppping c…
jshamble Mar 1, 2022
5126603
added validation config checks for Arraay, obejcts, added stoppping c…
jshamble Mar 1, 2022
21672e1
addex splice index to add correct index offset
jshamble Mar 1, 2022
2caf52a
added seprate array function
jshamble Mar 1, 2022
47e1a00
unit test cleanup
jshamble Mar 1, 2022
3ab6ba9
changed name
jshamble Mar 1, 2022
ff13eac
made aggregate rating optional
jshamble Mar 1, 2022
770a5b4
made aggregate rating optional
jshamble Mar 1, 2022
b4bb45d
Added some nit fixes to shoppingtagvalidation
jshamble Mar 1, 2022
71534b5
updated logic, added case where optional fields with no validaterequi…
jshamble Mar 1, 2022
2c528bc
added blocking rendering for optional attributes (revert this commit …
jshamble Mar 3, 2022
65b2837
added validateCurrency and validate currency unit test
jshamble Mar 3, 2022
a77859c
optimized currency by using international number format's built-in er…
jshamble Mar 3, 2022
8bd891e
optimized currency by using international number format's built-in er…
jshamble Mar 3, 2022
6d38c72
updated it to return functions
jshamble Mar 3, 2022
177a46d
updated warning mesage
jshamble Mar 3, 2022
fa71011
updated error and warning message with nullish coalescing operator
jshamble Mar 3, 2022
bc5eb5b
updated error and warning message with nullish coalescing operator
jshamble Mar 4, 2022
e3a37c6
updated and simplified reducer into a filter function
jshamble Mar 4, 2022
1d514e9
updated and simplified reducer into a filter function
jshamble Mar 4, 2022
82aacc5
added test for validate HTML id
jshamble Mar 4, 2022
94002db
cleaned up validation conifg
jshamble Mar 4, 2022
c5c369e
fixed up vlaidtion config
jshamble Mar 5, 2022
4509c20
got validation unit tests to pass, added several validation config en…
jshamble Mar 18, 2022
daeaff4
added product vendor id
jshamble Mar 18, 2022
fbf9aea
updated merge conflixt with product vendor
jshamble Mar 18, 2022
e324c5d
resolved merge conflict
jshamble Mar 18, 2022
dbc2e10
fixed some validation test files
jshamble Mar 19, 2022
b016415
added shopping config fixes
jshamble Mar 19, 2022
23781e6
thrwo away invalid remote config URL
jshamble Mar 19, 2022
2fe6544
fixed validtion test errors
jshamble Mar 21, 2022
196d80d
updated unit tests with length checks
jshamble Mar 23, 2022
3a22618
added validation
jshamble Mar 23, 2022
8145081
udpated validation unit tests
jshamble Mar 23, 2022
0dd3202
added test dependencies
jshamble Mar 24, 2022
71122cc
removed unneesc dependencies
jshamble Mar 24, 2022
6c7afae
Merge branch 'main' into shoppingJSONValidation
jshamble Mar 28, 2022
28a9648
integrated ajv json schema validator initial commit
jshamble Mar 28, 2022
2364cc6
added validate prodcut to configuration
jshamble Mar 28, 2022
a194ab0
add back in some code, per function or per block validation?
jshamble Mar 28, 2022
cded925
merge main to fix buidl process
jshamble Mar 29, 2022
025505b
updated json schema to a working schema
jshamble Mar 29, 2022
6c8e73e
added valid config
jshamble Mar 29, 2022
49febec
added First working validation for ajv json schema
jshamble Mar 30, 2022
48a66d6
updated unit tests yet again
jshamble Mar 30, 2022
30232d1
cleaned up json schema code
jshamble Mar 30, 2022
32e9549
added passing unit tests, updated regex, updated .html files to pass …
jshamble Mar 31, 2022
1302930
resolve merge conflict
jshamble Mar 31, 2022
bbc02d8
added realtive url validation
jshamble Mar 31, 2022
2042a25
updated test regex
jshamble Apr 1, 2022
d916aa8
added support for relative URLs
jshamble Apr 2, 2022
7553f85
added better url checks
jshamble Apr 4, 2022
3aced13
added udpated export functions relativeToSourceUrl
jshamble Apr 4, 2022
cfd15c4
fixed test
jshamble Apr 4, 2022
97529ea
fixed prettier formatting
jshamble Apr 4, 2022
b47223f
fixed json formatting
jshamble Apr 4, 2022
e59bc61
fixed json formatting
jshamble Apr 4, 2022
85151a8
Merge branch 'main' into shoppingJSONValidation
jshamble Apr 4, 2022
4227e69
Merge branch 'main' into shoppingJSONValidation
jshamble Apr 4, 2022
03e0b27
added additoinal items
jshamble Apr 4, 2022
66dafaa
added item name prefix
jshamble Apr 5, 2022
bf8bd53
resolved merge conflicts
jshamble Apr 5, 2022
8204ae9
added newline test
jshamble Apr 5, 2022
c3a8b5f
refactored code, page id, etc
jshamble Apr 6, 2022
656f63e
Merge branch 'main' into shoppingJSONValidation
jshamble Apr 6, 2022
b4144d3
added comment to pass circleci tests
jshamble Apr 6, 2022
dbf5af0
pass circleCI
jshamble Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/amp-story/amp-story-shopping.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@
"productPrice": 799.00,
"productPriceCurrency": "USD",
"productImages": [
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 1"},
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 2"},
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 3"},
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 4"},
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 5"},
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 6"}
{"url": "https://source.unsplash.com/Ry9WBo3qmoc/500x500", "alt": "lamp 1"},
{"url": "https://source.unsplash.com/KP7p0-DRGbg", "alt": "lamp 2"},
{"url": "https://source.unsplash.com/mFnbFaCIu1I", "alt": "lamp 3"},
{"url": "https://source.unsplash.com/py9sH2rThWs", "alt": "lamp 4"},
{"url": "https://source.unsplash.com/VDPauwJ_sHo", "alt": "lamp 5"},
{"url": "https://source.unsplash.com/3LTht2nxd34", "alt": "lamp 6"}
],
"aggregateRating": {
"ratingValue": 4.4,
Expand Down
281 changes: 281 additions & 0 deletions examples/amp-story/shopping/product.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
{
"$defs": {
jshamble marked this conversation as resolved.
Show resolved Hide resolved
"https": {
"type": "string",
"format": "uri-reference",
"pattern": "^(/|https://|https?://(127.0.0.1|([^/]+\\.)?localhost)(:[0-9]+)?/)"
}
},
"title": "Product",
"description": "A product from an amp-story-shopping configuration.",
"type": "object",
"additionalProperties": false,
"properties": {
jshamble marked this conversation as resolved.
Show resolved Hide resolved
"productId": {
"description": "Keys for amp-story-shopping-tag nodes, sent out in analytics events.",
"type": "string"
},
"productUrl": {
"description": "Links to the product's website, whne the buy now button is clicked.",
"type": "string",
"$ref": "#/$defs/https"
},
"productTitle": {
"description": "The name of the product, displayed on the tag.",
"type": "string"
},
"productPrice": {
"description": "The price of the product, displayed on the tag.",
"type": "number"
},
"productPriceCurrency": {
"description": "The ISO 4217 currency code of the product price.",
"type": "string",
"enum": [
"AED",
"AFN",
"ALL",
"AMD",
"ANG",
"AOA",
"ARS",
"AUD",
"AWG",
"AZN",
"BAM",
"BBD",
"BDT",
"BGN",
"BHD",
"BIF",
"BMD",
"BND",
"BOB",
"BOV",
"BRL",
"BSD",
"BTN",
"BWP",
"BYN",
"BZD",
"CAD",
"CDF",
"CHE",
"CHF",
"CHW",
"CLF",
"CLP",
"CNY",
"COP",
"COU",
"CRC",
"CUC",
"CUP",
"CVE",
"CZK",
"DJF",
"DKK",
"DOP",
"DZD",
"EGP",
"ERN",
"ETB",
"EUR",
"FJD",
"FKP",
"GBP",
"GEL",
"GHS",
"GIP",
"GMD",
"GNF",
"GTQ",
"GYD",
"HKD",
"HNL",
"HRK",
"HTG",
"HUF",
"IDR",
"ILS",
"INR",
"IQD",
"IRR",
"ISK",
"JMD",
"JOD",
"JPY",
"KES",
"KGS",
"KHR",
"KMF",
"KPW",
"KRW",
"KWD",
"KYD",
"KZT",
"LAK",
"LBP",
"LKR",
"LRD",
"LSL",
"LYD",
"MAD",
"MDL",
"MGA",
"MKD",
"MMK",
"MNT",
"MOP",
"MRU",
"MUR",
"MVR",
"MWK",
"MXN",
"MXV",
"MYR",
"MZN",
"NAD",
"NGN",
"NIO",
"NOK",
"NPR",
"NZD",
"OMR",
"PAB",
"PEN",
"PGK",
"PHP",
"PKR",
"PLN",
"PYG",
"QAR",
"RON",
"RSD",
"RUB",
"RWF",
"SAR",
"SBD",
"SCR",
"SDG",
"SEK",
"SGD",
"SHP",
"SLL",
"SOS",
"SRD",
"SSP",
"STN",
"SVC",
"SYP",
"SZL",
"THB",
"TJS",
"TMT",
"TND",
"TOP",
"TRY",
"TTD",
"TWD",
"TZS",
"UAH",
"UGX",
"USD",
"USN",
"UYI",
"UYU",
"UYW",
"UZS",
"VED",
"VES",
"VND",
"VUV",
"WST",
"XAF",
"XAG",
"XAU",
"XBA",
"XBB",
"XBC",
"XBD",
"XCD",
"XDR",
"XOF",
"XPD",
"XPF",
"XPT",
"XSU",
"XTS",
"XUA",
"XXX",
"YER",
"ZAR",
"ZMW",
"ZWL"
]
},
"productImages": {
"description": "A list of images for the product used in the carousel of the product page",
"type": "array",
"items": {
"required": ["url", "alt"],
"additionalProperties": false,
"type": "object",
"properties": {
"url": {
"$ref": "#/$defs/https"
},
"alt": {
"type": "string"
}
}
}
},
"productDetails": {
"description": "Details about the product used in the product details page",
"type": "string"
},
"productBrand": {
"description": "Brand name of the product used in the tag.",
"type": "string"
},
"productIcon": {
"description": "Links the icon image for the product in the tag. Defaults to a shopping bag icon.",
"type": "string"
},
"productTagText": {
"description": "Text for the Prodcut tag. Supersedes productPrice",
"type": "string"
},
"aggregateRating": {
"description": "Ratings and review data for the product displayed on the product page.",
"type": "object",
"required": ["ratingValue", "reviewCount", "reviewUrl"],
"additionalProperties": false,
"properties": {
"ratingValue": {
"description": "The aggregate rating value of the product.",
"type": "number"
},
"reviewCount": {
"description": "The number of reviews for the product.",
"type": "number"
},
"reviewUrl": {
"description": "The Url for the product reviews.",
"type": "string",
"$ref": "#/$defs/https"
}
}
}
},
"required": [
"productId",
"productUrl",
"productTitle",
"productPrice",
"productPriceCurrency",
"productImages",
"productDetails"
]
}
32 changes: 16 additions & 16 deletions examples/visual-tests/amp-story/amp-story-shopping-landscape.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 6"}
],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "One newline after this. \n Two newlines after this. \n\n Five consecutive newlines after this, should become 2 newlines. \n\n\n\n\n Many consecutive newlines with different spacing and tabs after this, should become 2 newlines. \n \n\n \n \n \n \n \n I hope it works!"
Expand All @@ -85,8 +85,8 @@
"productPriceCurrency": "INR",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "art"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand All @@ -100,8 +100,8 @@
"productTagText": "The perfectly imperfect yellow chair",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "chair"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand All @@ -116,8 +116,8 @@
"productIcon": "/examples/visual-tests/amp-story/img/shopping/icon.png",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "flowers"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand Down Expand Up @@ -160,8 +160,8 @@
{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "lamp 6"}
],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand All @@ -175,8 +175,8 @@
"productPriceCurrency": "INR",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "art"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand All @@ -190,8 +190,8 @@
"productTagText": "The perfectly imperfect yellow chair",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "chair"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand All @@ -206,8 +206,8 @@
"productIcon": "/examples/visual-tests/amp-story/img/shopping/icon.png",
"productImages": [{"url": "/examples/visual-tests/amp-story/img/cat1.jpg", "alt": "flowers"}],
"aggregateRating": {
"ratingValue": "4.4",
"reviewCount": "89",
"ratingValue": 4.4,
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"reviewCount": 89,
"reviewUrl": "https://www.google.com"
},
"productDetails": "One newline after this. \n Two newlines after this. \n\n Five consecutive newlines after this, should become 2 newlines. \n\n\n\n\n Many consecutive newlines with different spacing and tabs after this, should become 2 newlines. \n \n\n \n \n \n \n \n I hope it works!"
"productDetails": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere error deserunt dignissimos in laborum ea molestias veritatis sint laudantium iusto expedita atque provident doloremque, ad voluptatem culpa adipisci."
},
{
"productUrl": "https://www.google.com",
Expand Down
Loading