Skip to content

Commit 13ac2c7

Browse files
committed
wip
1 parent fae8fef commit 13ac2c7

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

tests/async/test_har.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pytest
2222

23-
from playwright.async_api import Browser, BrowserContext, Error, expect, Page, Route
23+
from playwright.async_api import Browser, BrowserContext, Error, Page, expect
2424
from tests.server import Server
2525

2626

@@ -256,19 +256,26 @@ async def test_should_page_route_from_har_matching_the_method_and_following_redi
256256
async def test_fallback_continue_should_continue_when_not_found_in_har(
257257
context: BrowserContext, server: Server, assetdir: Path
258258
) -> None:
259-
await context.route_from_har(har=assetdir / "har-fulfill.har", not_found='fallback')
259+
await context.route_from_har(har=assetdir / "har-fulfill.har", not_found="fallback")
260260
page = await context.new_page()
261-
await page.goto(server.PREFIX + '/one-style.html')
262-
await expect(page.locator("body")).to_have_css("background-color", "rgb(255, 192, 203)")
261+
await page.goto(server.PREFIX + "/one-style.html")
262+
await expect(page.locator("body")).to_have_css(
263+
"background-color", "rgb(255, 192, 203)"
264+
)
265+
263266

264267
async def test_by_default_should_abort_requests_not_found_in_har(
265-
context: BrowserContext, server: Server, assetdir: Path, is_chromium: bool, is_webkit: bool
268+
context: BrowserContext,
269+
server: Server,
270+
assetdir: Path,
271+
is_chromium: bool,
272+
is_webkit: bool,
266273
) -> None:
267274
await context.route_from_har(har=assetdir / "har-fulfill.har")
268275
page = await context.new_page()
269276

270277
with pytest.raises(Error) as exc_info:
271-
resp = await page.goto(server.EMPTY_PAGE)
278+
await page.goto(server.EMPTY_PAGE)
272279
assert exc_info.value
273280
if is_chromium:
274281
assert "net::ERR_FAILED" in exc_info.value.message
@@ -277,29 +284,33 @@ async def test_by_default_should_abort_requests_not_found_in_har(
277284
else:
278285
assert "NS_ERROR_FAILURE" in exc_info.value.message
279286

287+
280288
async def test_fallback_continue_should_continue_requests_on_bad_har(
281289
context: BrowserContext, server: Server, tmpdir: Path
282290
) -> None:
283291
path_to_invalid_har = tmpdir / "invalid.har"
284292
with path_to_invalid_har.open("w") as f:
285-
json.dump({ "log": {} }, f)
286-
await context.route_from_har(har=path_to_invalid_har, not_found='fallback')
293+
json.dump({"log": {}}, f)
294+
await context.route_from_har(har=path_to_invalid_har, not_found="fallback")
287295
page = await context.new_page()
288-
await page.goto(server.PREFIX + '/one-style.html')
289-
await expect(page.locator("body")).to_have_css("background-color", "rgb(255, 192, 203)")
296+
await page.goto(server.PREFIX + "/one-style.html")
297+
await expect(page.locator("body")).to_have_css(
298+
"background-color", "rgb(255, 192, 203)"
299+
)
290300

291-
async def test_should_handle_requests_matching_url_filter(
292-
context: BrowserContext, server: Server, assetdir: Path
293-
) -> None:
294-
await context.route_from_har(har=assetdir / "har-fulfill.har", not_found='fallback', url='**/*.js')
295-
page = await context.new_page()
296-
async def handler(route: Route):
297-
assert route.request.url == 'http://no.playwright/'
298-
await route.fulfill(status=200, content_type='text/html', body='<script src="./script.js"></script><div>hello</div>')
299-
await context.route('http://no.playwright/', handler)
300-
await page.goto('http://no.playwright/')
301-
assert await page.evaluate("window.value") == "foo"
302-
await expect(page.locator("body")).to_have_css("background-color", "rgba(0, 0, 0, 0)'")
301+
302+
# async def test_should_handle_requests_matching_url_filter(
303+
# context: BrowserContext, server: Server, assetdir: Path
304+
# ) -> None:
305+
# await context.route_from_har(har=assetdir / "har-fulfill.har", not_found='fallback', url='**/*.js')
306+
# page = await context.new_page()
307+
# async def handler(route: Route):
308+
# assert route.request.url == 'http://no.playwright/'
309+
# await route.fulfill(status=200, content_type='text/html', body='<script src="./script.js"></script><div>hello</div>')
310+
# await context.route('http://no.playwright/', handler)
311+
# await page.goto('http://no.playwright/')
312+
# assert await page.evaluate("window.value") == "foo"
313+
# await expect(page.locator("body")).to_have_css("background-color", "rgba(0, 0, 0, 0)'")
303314

304315
# it('should only handle requests matching url filter', async ({ context, isAndroid, asset }) => {
305316
# it.fixme(isAndroid);

0 commit comments

Comments
 (0)