Skip to content

Commit cdaa9e2

Browse files
committed
Preview all Chinese article cards and English-linked placeholders
1 parent 2fb3d80 commit cdaa9e2

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Preview Chinese article placeholders
2+
on:
3+
push:
4+
branches: [ops/chinese-article-preview]
5+
permissions:
6+
contents: write
7+
jobs:
8+
browser:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 15
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
ref: 2fb3d80fa8f92a2613a8e9150ef69746d1773c08
15+
- uses: actions/jekyll-build-pages@v1
16+
with:
17+
source: ./
18+
destination: ./_site
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
- name: Inspect article previews on desktop and phone
23+
env:
24+
QA_OUTPUT: ${{ runner.temp }}/chinese-article-preview
25+
run: |
26+
python3 -m http.server 8765 --bind 127.0.0.1 --directory _site > /tmp/site-server.log 2>&1 &
27+
mkdir -p "$RUNNER_TEMP/site-browser"
28+
cd "$RUNNER_TEMP/site-browser"
29+
npm install --no-save playwright@1.62.1
30+
npx playwright install --with-deps chromium
31+
cat > check.cjs <<'JS'
32+
const {chromium}=require('playwright');const fs=require('node:fs');const path=require('node:path');const assert=require('node:assert/strict');
33+
(async()=>{const browser=await chromium.launch();const output=process.env.QA_OUTPUT;fs.mkdirSync(output,{recursive:true});const origin='http://127.0.0.1:8765';const context=await browser.newContext({locale:'en-US',viewport:{width:1440,height:1000}});const page=await context.newPage();await context.route(/https:\/\/(?:mc\.yandex\.ru|fonts\.googleapis\.com|cdn\.jsdelivr\.net)\//,r=>r.abort());
34+
await page.goto(origin+'/articles/',{waitUntil:'domcontentloaded'});const english=await page.locator('.article-feed-item h2 a').evaluateAll(items=>items.map(a=>new URL(a.href).pathname));
35+
assert.equal(english.length,8);const report={commit:'2fb3d80fa8f92a2613a8e9150ef69746d1773c08',articles:[],viewports:[],liveHeadingChecks:[]};
36+
for(const width of [1440,390]){await page.setViewportSize({width,height:1000});await page.goto(origin+'/zh-cn/articles/',{waitUntil:'domcontentloaded'});await page.addStyleTag({content:'*,*::before,*::after{animation:none!important;transition:none!important}'});const cards=page.locator('.article-feed-item');assert.equal(await cards.count(),english.length);
37+
const data=await cards.evaluateAll(items=>items.map(item=>({title:item.querySelector('h2').textContent,digest:item.querySelector('.article-preview-copy > p').textContent,url:new URL(item.querySelector('h2 a').href).pathname,date:item.querySelector('time').getAttribute('datetime'),status:item.querySelector('.translation-status').textContent})));
38+
assert.deepEqual(data.map(x=>x.url),english.map(x=>'/zh-cn'+x));assert.deepEqual(data.map(x=>x.date),data.map(x=>x.date).sort().reverse());
39+
for(const card of data){assert.ok(/[\u3400-\u9fff]/.test(card.title));assert.ok(card.digest.length>=50);assert.ok(!card.digest.startsWith('简体中文译文'));assert.equal(card.status,'译文准备中');}
40+
await page.locator('.article-preview-image').evaluateAll(imgs=>imgs.forEach(img=>img.loading='eager'));await page.locator('.article-preview-image').evaluateAll(imgs=>Promise.all(imgs.map(img=>img.decode())));assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);
41+
await page.screenshot({path:path.join(output,'chinese-catalogue-'+width+'.png'),fullPage:true});await page.locator('.article-feed-item').first().screenshot({path:path.join(output,'first-card-'+width+'.png')});report.viewports.push({width,cards:data.length,status:'passed'});
42+
}
43+
for(const en of english){const zh='/zh-cn'+en;await page.goto(origin+zh,{waitUntil:'domcontentloaded'});assert.equal(await page.locator('html').getAttribute('lang'),'zh-CN');const body=await page.locator('.article-content').innerText();assert.ok(body.includes('简体中文全文译文正在准备中'));assert.ok(body.includes('内容摘要'));const link=page.locator('.article-content a').filter({hasText:'英文原文'});assert.equal(await link.getAttribute('href'),en);const digest=await page.locator('.article-content p').last().innerText();assert.ok(digest.length>=50);
44+
const source=await page.request.get('https://fuzzy-technologies.com'+en);assert.equal(source.status(),200,'English source unavailable: '+en);assert.ok((await source.text()).includes('<html lang="en">'));const nav=await page.locator('link[rel="alternate"][hreflang="en"]').getAttribute('href');assert.equal(new URL(nav).pathname,en);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);
45+
if(en.includes('2026-09-27')||en.includes('neural-network'))await page.screenshot({path:path.join(output,'placeholder-'+(en.includes('2026')?'first':'neural')+'-390.png'),fullPage:true});
46+
await link.click();await page.waitForURL(url=>url.pathname===en);assert.equal(await page.locator('html').getAttribute('lang'),'en');report.articles.push({chinese:zh,english:en,liveEnglishStatus:200,status:'passed'});}
47+
for(const route of ['/','/ru/','/zh-cn/','/articles/','/ru/articles/','/zh-cn/articles/']){const response=await page.request.get('https://fuzzy-technologies.com'+route);assert.equal(response.status(),200);const html=await response.text();const heading=html.match(/<h1 class="site-title">([\s\S]*?)<\/h1>/);assert.ok(heading&&!heading[1].includes('®'),'Pink live heading still contains ®: '+route);assert.ok(html.includes('/static/images/FuzzyTechnologies-Logo-registered.svg'));const footer=html.match(/<a class="trademark-link"[\s\S]*?<\/a>/);assert.ok(footer&&footer[0].includes('®'));report.liveHeadingChecks.push({route,status:'passed'});}
48+
fs.writeFileSync(path.join(output,'report.json'),JSON.stringify(report,null,2));console.log('PASS: 8 Chinese cards, 8 placeholder notices/English links, 8 public English sources, 2 viewports and 6 live heading checks.');await browser.close();})().catch(e=>{console.error(e);process.exit(1)});
49+
JS
50+
node check.cjs
51+
- uses: actions/upload-artifact@v4
52+
if: always()
53+
with:
54+
name: chinese-article-previews
55+
path: ${{ runner.temp }}/chinese-article-preview
56+
retention-days: 14
57+
- name: Remove temporary preview branch
58+
if: always()
59+
uses: actions/github-script@v8
60+
with:
61+
script: |
62+
await github.rest.git.deleteRef({owner:context.repo.owner,repo:context.repo.repo,ref:'heads/ops/chinese-article-preview'});

0 commit comments

Comments
 (0)