test: fix locator.viewportRatio() tests (#19931)

Drive-by: make sure `locator.viewportRatio()` returns `0`
for non-existing element.
This commit is contained in:
Andrey Lushnikov 2023-01-06 16:55:38 -08:00 committed by GitHub
parent 7bbaf2af21
commit 1385007185
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,7 +157,7 @@ it('locator.count should work with deleted Map in main world', async ({ page })
it('locator.viewportRatio', async ({ page }) => {
await page.setContent(`
<style>body { padding: 0; margin: 0; } div { position: absolute; left: 0; top: 0 }</style>
<style>body { overflow: hidden; padding: 0; margin: 0; } div { position: absolute; left: 0; top: 0 }</style>
<div id=fills-viewport style='width: 100vw; height: 100vh;'></div>
<div id=half-viewport style='width: 50vw; height: 100vh;'></div>
<div id=twice-viewport style='width: 200vw; height: 100vh;'></div>
@ -167,4 +167,5 @@ it('locator.viewportRatio', async ({ page }) => {
expect.soft(await page.locator('#half-viewport').viewportRatio()).toBe(1);
expect.soft(await page.locator('#twice-viewport').viewportRatio()).toBe(0.5);
expect.soft(await page.locator('#off-viewport').viewportRatio()).toBe(0);
expect.soft(await page.locator('#does-not-exist').viewportRatio()).toBe(0);
});