22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
from pathlib import Path
|
|
from lxml import html
|
|
import sys
|
|
root=Path(sys.argv[1])
|
|
headers=[]
|
|
for p in sorted((root/'dist').glob('*.html')):
|
|
d=html.parse(str(p))
|
|
if d.xpath('//meta[@http-equiv="refresh"]'):continue
|
|
hs=d.xpath('//header[contains(concat(" ",normalize-space(@class)," ")," site-header ")]')
|
|
assert len(hs)==1,p.name
|
|
h=hs[0]
|
|
for a in h.xpath('.//a'):
|
|
a.attrib.pop('aria-current',None)
|
|
if 'nav-item' in a.get('class',''):a.set('class','nav-item')
|
|
headers.append((p.name,html.tostring(h,encoding='unicode',with_tail=False)))
|
|
assert len({v for _,v in headers})==1,'Header markup differs'
|
|
s=html.parse(str(root/'dist'/'support.html'))
|
|
assert len(s.xpath('//*[@data-billing]'))==2
|
|
assert len(s.xpath('//*[contains(concat(" ",normalize-space(@class)," ")," membership-card ")]'))==3
|
|
assert len(s.xpath('//*[@id="support-form"]'))==1
|
|
assert s.xpath('//*[@id="plans"]')[0].getparent().index(s.xpath('//*[@id="plans"]')[0]) < s.xpath('//*[@id="one-time"]')[0].getparent().index(s.xpath('//*[@id="one-time"]')[0])
|
|
print('PASS: identical header markup on',len(headers),'pages; unified support and one shared billing toggle.') |