fix: ignore hidden book preview controls
This commit is contained in:
1 parent
b14a541344
commit
ef243cceff
2 files changed
+6
-1
No files matched your search
+1
-1
@@ -89,7 +89,7 @@ export async function checkBrowser(url:string,parentSignal?:AbortSignal):Promise
|
||||
await navigate(url);await settle();if(['urait.ru','book.ru'].includes(root))await page.waitForLoadState('networkidle',{timeout:4000}).catch(()=>{});let snapshot=await capture();
|
||||
if(root==='book.ru'){
|
||||
// CSS tooltips become part of the accessible name on hover; retain a stable DOM-text locator.
|
||||
const preview=page.locator('a[href*="reader.new.book.ru"]').filter({hasText:'Ознакомиться'}).first();
|
||||
const preview=page.locator('a[href*="reader.new.book.ru"]').filter({hasText:'Ознакомиться',visible:true}).first();
|
||||
if(await preview.count()){
|
||||
await preview.hover({timeout:3000}).catch(()=>{});
|
||||
await page.waitForFunction(()=>/гостевом\s+режиме|доступны\s+только\s+\d+\s+страниц/i.test(document.body?.innerText??''),undefined,{timeout:3000}).catch(()=>{});snapshot=await capture();
|
||||
|
||||
@@ -68,3 +68,8 @@ test('BOOK.ru locked orange preview is unavailable even without a loaded tooltip
|
||||
fixture=fixture.replace('</body>','<a href="https://reader.new.book.ru/">Читать полностью</a></body>');
|
||||
assert.equal((await checkBrowser('https://book.ru/book/940586')).status,'unknown','A full-reading control contradicts the locked-preview-only signal');
|
||||
});
|
||||
|
||||
test('a hidden BOOK.ru preview cannot prove a restriction through its pseudo-element',async()=>{
|
||||
fixture='<html><head><style>a::after{content:"В гостевом режиме доступны только 20 страниц книги.";display:block}</style></head><body><h1>Book</h1><div style="display:none"><a href="https://reader.new.book.ru/">Ознакомиться</a></div></body></html>';
|
||||
const check=await checkBrowser('https://book.ru/book/940586');assert.equal(check.status,'unknown',check.reason);assert.equal(check.code,200);
|
||||
});
|
||||
Reference in new issue
Block a user