Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save depoulo/543fbdd9517502af2edd5e9a76ca4588 to your computer and use it in GitHub Desktop.
Save depoulo/543fbdd9517502af2edd5e9a76ca4588 to your computer and use it in GitHub Desktop.
Compare html bodys for different pages for Now and Beyond. Requires `yarn start` to be running with shops for `fatty` and `skinny`.
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'No branchname provided.'
exit 0
fi
themes=( editorial limelight neutral spotlight structure uptown vision )
fattyPages=( en p/apple-jam-with-gallery p/apple-jam-without-gallery p/t-shirt-includes-basic-product-type p/navy-shoes search search?q=* l/contact i/about-us c/category cart unknown )
skinnyPages=( i/home p/test-product p/neues-produkt p/product-with-video p/refrence-price-test-product-1 search search?q=prod l/contact i/about-us p/unknown i/unknown cart unknown checkout/personal-data checkout/shipping checkout/payment checkout/confirmation )
baseUrl=http://localhost:7000
initialBranch=`git rev-parse --abbrev-ref HEAD`
initialBranchPath="${initialBranch/\//-}"
currentBranch=$initialBranch
currentBranchPath="${currentBranch/\//-}"
function removeSpecialChars {
echo $1 | sed 's/[^[:alpha:].-]/-/g'
}
function questionMarkOrAmpersand {
if [[ "$1" == *"?"* ]]; then echo "&"; else echo "?"; fi
}
# clear out the script tag line, whitespaces and empty comments
function prepareDiff {
IFS= read -r -d $'\0' data
echo $data | sed -r 's/.*<div id="app">/<div>/g' | sed -r 's/<script nonce=.*//g' \
| sed 's/<!---->//g' | sed 's/<!-- -->//g' \
| sed "s/PickupToken[^&\"]*//g" | sed "s/value=\"[^\"]*\"//g" \
| sed "s/<code>[^/]*//g"
}
function crawl {
for theme in "${themes[@]}"; do
mkdir -p ./compare/$currentBranchPath/$theme
themeParams="previewTheme=epages.$theme@dev"
for page in "${fattyPages[@]}"; do
pagePath="$(removeSpecialChars $page)"
url="$baseUrl/$page$(questionMarkOrAmpersand $page)shop=fatty&$themeParams"
echo $url
curl -s -L -H 'Cookie: epCookieConsent=0; apay-session-set=true; session_id=eyJjc3JmU2VjcmV0IjoidkdvWk1Xclg3S3Y2anZfOUdISFNnaHVHIiwidW5peFRpbWVzdGFtcCI6MTU5MjI5MTk5Mzc4NCwiY2FydFRva2VuIjoiNUVFODcyOTctMENFRC1CNTYxLTY3NzItRDU4MDlBQjM2NzREIiwiY2FydElkIjoiNUVFODcyOTctMENFRC1CNTYxLTY3NzItRDU4MDlBQjM2NzREIn0=; session_id.sig=J_YIpl7Kjq6xXw53iiKKQ0wjTtQ' \
$url | prepareDiff > ./compare/$currentBranchPath/$theme/fatty.$pagePath.html
done
for page in "${skinnyPages[@]}"; do
pagePath="$(removeSpecialChars $page)"
url="$baseUrl/$page$(questionMarkOrAmpersand $page)shop=skinny&$themeParams"
echo $url
curl -s -L -H 'Cookie: epCookieConsent=0; session_id=eyJjc3JmU2VjcmV0IjoiNzBna2F6djdFOHAxcUtoYTMwX0xHMUt1IiwidW5peFRpbWVzdGFtcCI6MTU5MjIzMTQ2Nzc1OCwiY2FydElkIjoiYWRlMDJmZGMtZjI2Yi00M2IyLWJiZWUtOTRmMTgzOGQ5NDg2In0=; session_id.sig=59-PYaSQE7WFLK9HJbAVPHRZYQ0' \
$url | prepareDiff > ./compare/$currentBranchPath/$theme/skinny.$pagePath.html
done
done
}
crawl
git checkout $1
currentBranch=`git rev-parse --abbrev-ref HEAD`
currentBranchPath="${currentBranch/\//-}"
sleep 5
crawl
cp -r compare compare-orig
npx prettier --loglevel silent --html-whitespace-sensitivity strict --write compare/**/*
cd ./compare/$currentBranchPath
for theme in "${themes[@]}"; do
for file in $theme/*; do
diff --brief $file ../$initialBranchPath/$file > /dev/null
[ $? != 0 ] && echo -e "$file has differences"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment