Skip to content

Commit

Permalink
Merge pull request #398 from MerginMaps/check-translation-banner
Browse files Browse the repository at this point in the history
Script for translation banner
  • Loading branch information
PeterPetrik authored Nov 30, 2023
2 parents 60564a3 + cbe2720 commit 9e3a360
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/test-check-translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Checking translated subpages for migration banner is visible
# Before run, install playwright python package for e2e testing and html page parsing:
# https://playwright.dev/python/docs/intro

import os
import sys
from playwright.sync_api import sync_playwright

CURRENT_PATH = os.path.abspath(__file__)
DIR = os.path.join(os.path.dirname(os.path.dirname(CURRENT_PATH)), 'src')
subpages = []

def test_translation_banner():
for root, subfolders, files in os.walk(DIR):
if os.path.isdir(os.path.join(DIR, root)) and '.vuepress' not in os.path.normpath(os.path.join(DIR, root)):
subpages.append(os.path.relpath(root, DIR).replace('.', ''))

languages = ['de', 'es', 'fr', 'it', 'pt']
base_urls = ["https://{}.merginmaps.com/docs".format(lang) for lang in languages]

problem_pages = []
with sync_playwright() as p:
browser = p.chromium.launch()
for base_url in base_urls:
for subpage in subpages:
url = base_url + '/' + subpage
page = browser.new_page()
page.goto(url)
h1_element = page.locator('h1')
h1_text = h1_element.inner_text()
print('Testing {}'.format(url))
if h1_text!='404' and page.locator('.page-header').is_hidden():
problem_pages.append(url)

if (len(problem_pages) > 0):
print('Problem pages:')
print(problem_pages)
sys.exit(1)

def main():
test_translation_banner()

main()

0 comments on commit 9e3a360

Please sign in to comment.