test: add more baseURL tests for edge-cases (#7586)

This commit is contained in:
Max Schmitt 2021-07-13 21:11:46 +02:00 committed by GitHub
parent 767e22c6b2
commit 053d39cb19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,17 @@ it('should construct a new URL when a baseURL in browser.newPage is passed to pa
await page.close();
});
it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({browserType, server, createUserDataDir, browserOptions}) {
const userDataDir = await createUserDataDir();
const context = await browserType.launchPersistentContext(userDataDir, {
...browserOptions,
baseURL: server.PREFIX,
});
const page = await context.newPage();
expect((await page.goto('/empty.html')).url()).toBe(server.EMPTY_PAGE);
await context.close();
});
it('should construct the URLs correctly when a baseURL without a trailing slash in browser.newPage is passed to page.goto', async function({browser, server}) {
const page = await browser.newPage({
baseURL: server.PREFIX + '/url-construction',
@ -91,3 +102,12 @@ it('should be able to match a URL relative to its given URL with urlMatcher', as
expect((await response.body()).toString()).toBe('base-url-matched-route');
await page.close();
});
it('should not construct a new URL with baseURL when a glob was used', async function({browser, server}) {
const page = await browser.newPage({
baseURL: server.PREFIX + '/foobar/',
});
await page.goto('./kek/index.html');
await page.waitForURL('**/foobar/kek/index.html');
await page.close();
});