api#326 Числовые UTM и новый шум каждого перехода
This commit is contained in:
1 parent
f30742c2fb
commit
81e189ca67
16 files changed
+303
-160
No files matched your search
@@ -8,7 +8,7 @@ try{for(const width of [1440,768,390,320])for(const theme of ['light','dark'])fo
|
||||
const ctx=await browser.newContext({viewport:{width,height:900},isMobile:width<768,hasTouch:width<768}),page=await ctx.newPage(),errors=[];
|
||||
page.on('pageerror',e=>errors.push(e.message));
|
||||
await page.route('**/*',route=>['GET','HEAD','OPTIONS'].includes(route.request().method())?route.continue():route.abort());
|
||||
await page.goto(base+'/?theme='+theme+'&indpic='+indpic,{waitUntil:'networkidle'});
|
||||
await page.goto(base+'/?theme=abcd'+(theme==='dark'?'1':'2')+'&indpic=abcd'+indpic,{waitUntil:'networkidle'});
|
||||
await page.waitForFunction(()=>document.querySelector('#examples').dataset.examplesState==='ready');
|
||||
assert.equal(await page.title(),'Улучшение изображения');assert(await page.locator('#dropzone-form').isVisible());
|
||||
const footer=await page.locator('.footer').innerText();assert(!/Наши реквизиты|ИНН:|ОГРНИП:|Кардаполов|Иванов/.test(footer));assert.equal(await page.locator('.footer img[src*="payment.svg"] ').count(),0);assert(footer.includes(new URL(base).hostname));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// api#326: реальный handoff codec, включая сохранённые legacy records.
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const vm = require('node:vm');
|
||||
const source = fs.readFileSync('/app/components/utm-handoff.php','utf8').split("<<<'JS'\n")[1].split('\nJS;')[0];
|
||||
const context = {window:{},URLSearchParams,Uint8Array,crypto:require('node:crypto').webcrypto};
|
||||
vm.runInNewContext(source,context);
|
||||
const handoff=context.window.ZoomzillaUtmHandoff;
|
||||
const defaults={indpic:'1',theme:'1',degr:'1',reg:'2',chob:'2',tp:'1',cons:'2',focus:'1'};
|
||||
const selected={indpic:'2',theme:'2',degr:'2',reg:'1',chob:'1',tp:'2',cons:'3',focus:'2'};
|
||||
const foreign='utm_source=abcd9same&subid=%D1%82%D0%B5%D1%81%D1%82+%2B+%26&id=42&stage=keep';
|
||||
for(const meta of [
|
||||
{redirectUtm:foreign,utmDigits:selected},
|
||||
{redirectUtm:foreign+'&indpic=2&theme=light°r=2®istration=before&bchoice=b&tp=2&cons=3&focus=center&chb=a'},
|
||||
{redirectUtm:foreign+'&indpic=abcd2&theme=абвг2°r=abcd2®=abcd1&chob=abcd1&tp=abcd2&cons=abcd3&focus=abcd2'}
|
||||
]){
|
||||
const before=JSON.stringify(meta);
|
||||
const first=new URLSearchParams(handoff.query(meta,defaults));
|
||||
const second=new URLSearchParams(handoff.query(meta,defaults));
|
||||
for(const [key,digit] of Object.entries(selected)){
|
||||
assert.match(first.get(key),/^[A-Za-z0-9]{10}$/);
|
||||
assert.equal(first.get(key)[4],digit);
|
||||
assert.equal(second.get(key)[4],digit);
|
||||
assert.notEqual(first.get(key),second.get(key));
|
||||
}
|
||||
for(const query of [first,second]){
|
||||
assert.equal(query.get('utm_source'),'abcd9same');
|
||||
assert.equal(query.get('subid'),'тест + &');
|
||||
assert.equal(query.get('id'),'42'); assert.equal(query.get('stage'),'keep');
|
||||
for(const legacy of ['registration','bchoice','chb'])assert.equal(query.has(legacy),false);
|
||||
}
|
||||
assert.equal(JSON.stringify(meta),before);
|
||||
}
|
||||
const typeIn=new URLSearchParams(handoff.query({redirectUtm:'',utmDigits:defaults},defaults));
|
||||
for(const [key,digit]of Object.entries(defaults))assert.equal(typeIn.get(key)[4],digit);
|
||||
console.log('OK: all8 fresh noise/repeated handoff, legacy recovery, type-in, foreign/technical values');
|
||||
Reference in new issue
Block a user