mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: split test to be more fine grained (#12337)
This commit is contained in:
parent
47013cd938
commit
7b5e286146
@ -76,13 +76,6 @@
|
||||
"expectations": ["SKIP"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Page.setBypassServiceWorker *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -104,6 +97,13 @@
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Request.resourceType *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Bidi does not have equivalent field"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Response.buffer *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -118,6 +118,13 @@
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Response.remoteAddress *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Bidi does not have equivalent field"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Response.text *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -488,18 +495,6 @@
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events Page.Events.RequestFinished",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["PASS"]
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events should fire events in proper order",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["PASS"]
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Page.setExtraHTTPHeaders *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -756,6 +751,20 @@
|
||||
"expectations": ["SKIP"],
|
||||
"comment": "TODO: Needs full support for continueRequest in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1850680"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.resourceType should work for document type",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.resourceType should work for stylesheets",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception-experimental.spec] cooperative request interception Request.respond *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -812,6 +821,20 @@
|
||||
"expectations": ["SKIP"],
|
||||
"comment": "TODO: Needs full support for continueRequest in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1850680"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception.spec] request interception Request.resourceType should work for document type",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception.spec] request interception Request.resourceType should work for stylesheets",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "`HTTPRequest.resourceType()` has no eqivalent in BiDi spec"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[requestinterception.spec] request interception Request.respond *",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -2567,6 +2590,13 @@
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events Page.Events.RequestFailed",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Test expects slightly different error message consider changing"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events Page.Events.RequestFinished",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -2584,8 +2614,9 @@
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events Page.Events.RequestServedFromCache",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["chrome", "webDriverBiDi"],
|
||||
"expectations": ["PASS"]
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Firefox does not send events for the cached event (bypasses network?)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events Page.Events.Response",
|
||||
@ -2622,6 +2653,13 @@
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events should support redirects",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["firefox", "webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Response completed for the redirect get emitter after the beforeSent (or flushed with the last responseCompleted)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Page.authenticate should allow disable authentication",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -2817,6 +2855,13 @@
|
||||
"expectations": ["SKIP"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Response.remoteAddress should support redirects",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
"parameters": ["cdp", "firefox"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Response.text should return uncompressed text",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
@ -4042,6 +4087,13 @@
|
||||
"expectations": ["FAIL", "PASS"],
|
||||
"comment": "TODO: add a comment explaining why this expectation is required (include links to issues)"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network Network Events should support redirects",
|
||||
"platforms": ["linux"],
|
||||
"parameters": ["chrome", "headless", "webDriverBiDi"],
|
||||
"expectations": ["FAIL"],
|
||||
"comment": "Fix in next PR"
|
||||
},
|
||||
{
|
||||
"testIdPattern": "[network.spec] network raw network headers Same-origin set-cookie subresource",
|
||||
"platforms": ["darwin", "linux", "win32"],
|
||||
|
@ -492,12 +492,12 @@ describe('network', function () {
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(requests).toHaveLength(1);
|
||||
expect(requests[0]!.url()).toBe(server.EMPTY_PAGE);
|
||||
expect(requests[0]!.resourceType()).toBe('document');
|
||||
expect(requests[0]!.method()).toBe('GET');
|
||||
expect(requests[0]!.response()).toBeTruthy();
|
||||
expect(requests[0]!.frame() === page.mainFrame()).toBe(true);
|
||||
expect(requests[0]!.frame()!.url()).toBe(server.EMPTY_PAGE);
|
||||
const request = requests[0]!;
|
||||
expect(request.url()).toBe(server.EMPTY_PAGE);
|
||||
expect(request.method()).toBe('GET');
|
||||
expect(request.response()).toBeTruthy();
|
||||
expect(request.frame() === page.mainFrame()).toBe(true);
|
||||
expect(request.frame()!.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it('Page.Events.RequestServedFromCache', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
@ -509,7 +509,9 @@ describe('network', function () {
|
||||
|
||||
await page.goto(server.PREFIX + '/cached/one-style.html');
|
||||
expect(cached).toEqual([]);
|
||||
|
||||
await new Promise(res => {
|
||||
setTimeout(res, 1000);
|
||||
});
|
||||
await page.reload();
|
||||
expect(cached).toEqual(['one-style.css']);
|
||||
});
|
||||
@ -522,16 +524,11 @@ describe('network', function () {
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(responses).toHaveLength(1);
|
||||
expect(responses[0]!.url()).toBe(server.EMPTY_PAGE);
|
||||
expect(responses[0]!.status()).toBe(200);
|
||||
expect(responses[0]!.ok()).toBe(true);
|
||||
expect(responses[0]!.request()).toBeTruthy();
|
||||
const remoteAddress = responses[0]!.remoteAddress();
|
||||
// Either IPv6 or IPv4, depending on environment.
|
||||
expect(
|
||||
remoteAddress.ip!.includes('::1') || remoteAddress.ip === '127.0.0.1'
|
||||
).toBe(true);
|
||||
expect(remoteAddress.port).toBe(server.PORT);
|
||||
const response = responses[0]!;
|
||||
expect(response.url()).toBe(server.EMPTY_PAGE);
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.ok()).toBe(true);
|
||||
expect(response.request()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Page.Events.RequestFailed', async () => {
|
||||
@ -551,17 +548,15 @@ describe('network', function () {
|
||||
});
|
||||
await page.goto(server.PREFIX + '/one-style.html');
|
||||
expect(failedRequests).toHaveLength(1);
|
||||
expect(failedRequests[0]!.url()).toContain('one-style.css');
|
||||
expect(failedRequests[0]!.response()).toBe(null);
|
||||
expect(failedRequests[0]!.resourceType()).toBe('stylesheet');
|
||||
const failedRequest = failedRequests[0]!;
|
||||
expect(failedRequest.url()).toContain('one-style.css');
|
||||
expect(failedRequest.response()).toBe(null);
|
||||
expect(failedRequest.frame()).toBeTruthy();
|
||||
if (isChrome) {
|
||||
expect(failedRequests[0]!.failure()!.errorText).toBe('net::ERR_FAILED');
|
||||
expect(failedRequest.failure()!.errorText).toBe('net::ERR_FAILED');
|
||||
} else {
|
||||
expect(failedRequests[0]!.failure()!.errorText).toBe(
|
||||
'NS_ERROR_FAILURE'
|
||||
);
|
||||
expect(failedRequest.failure()!.errorText).toBe('NS_ERROR_FAILURE');
|
||||
}
|
||||
expect(failedRequests[0]!.frame()).toBeTruthy();
|
||||
});
|
||||
it('Page.Events.RequestFinished', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
@ -631,9 +626,6 @@ describe('network', function () {
|
||||
const redirectChain = response.request().redirectChain();
|
||||
expect(redirectChain).toHaveLength(1);
|
||||
expect(redirectChain[0]!.url()).toContain('/foo.html');
|
||||
expect(redirectChain[0]!.response()!.remoteAddress().port).toBe(
|
||||
server.PORT
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -914,4 +906,71 @@ describe('network', function () {
|
||||
expect(responses.get('style.css').fromServiceWorker()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.resourceType', () => {
|
||||
it('should work for document type', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
const requests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
return requests.push(request);
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(requests).toHaveLength(1);
|
||||
const request = requests[0]!;
|
||||
expect(request.resourceType()).toBe('document');
|
||||
});
|
||||
|
||||
it('should work for stylesheets', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
const cssRequests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
if (request.url().endsWith('css')) {
|
||||
cssRequests.push(request);
|
||||
}
|
||||
});
|
||||
await page.goto(server.PREFIX + '/one-style.html');
|
||||
expect(cssRequests).toHaveLength(1);
|
||||
const request = cssRequests[0]!;
|
||||
expect(request.url()).toContain('one-style.css');
|
||||
expect(request.resourceType()).toBe('stylesheet');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.remoteAddress', () => {
|
||||
it('should work', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
const responses: HTTPResponse[] = [];
|
||||
page.on('response', response => {
|
||||
return responses.push(response);
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(responses).toHaveLength(1);
|
||||
const response = responses[0]!;
|
||||
const remoteAddress = response.remoteAddress();
|
||||
// Either IPv6 or IPv4, depending on environment.
|
||||
expect(
|
||||
remoteAddress.ip!.includes('::1') || remoteAddress.ip === '127.0.0.1'
|
||||
).toBe(true);
|
||||
expect(remoteAddress.port).toBe(server.PORT);
|
||||
});
|
||||
|
||||
it('should support redirects', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
server.setRedirect('/foo.html', '/empty.html');
|
||||
const FOO_URL = server.PREFIX + '/foo.html';
|
||||
const response = (await page.goto(FOO_URL))!;
|
||||
|
||||
// Check redirect chain
|
||||
const redirectChain = response.request().redirectChain();
|
||||
expect(redirectChain).toHaveLength(1);
|
||||
expect(redirectChain[0]!.url()).toContain('/foo.html');
|
||||
expect(redirectChain[0]!.response()!.remoteAddress().port).toBe(
|
||||
server.PORT
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -106,7 +106,6 @@ describe('cooperative request interception', function () {
|
||||
expect(request.method()).toBe('GET');
|
||||
expect(request.postData()).toBe(undefined);
|
||||
expect(request.isNavigationRequest()).toBe(true);
|
||||
expect(request.resourceType()).toBe('document');
|
||||
expect(request.frame()!.url()).toBe('about:blank');
|
||||
expect(request.frame() === page.mainFrame()).toBe(true);
|
||||
} catch (error) {
|
||||
@ -408,7 +407,6 @@ describe('cooperative request interception', function () {
|
||||
expect(response!.status()).toBe(200);
|
||||
expect(response!.url()).toContain('empty.html');
|
||||
expect(requests).toHaveLength(5);
|
||||
expect(requests[2]!.resourceType()).toBe('document');
|
||||
// Check redirect chain
|
||||
const redirectChain = response!.request().redirectChain();
|
||||
expect(redirectChain).toHaveLength(4);
|
||||
@ -442,8 +440,6 @@ describe('cooperative request interception', function () {
|
||||
expect(response!.status()).toBe(200);
|
||||
expect(response!.url()).toContain('one-style.html');
|
||||
expect(requests).toHaveLength(5);
|
||||
expect(requests[0]!.resourceType()).toBe('document');
|
||||
expect(requests[1]!.resourceType()).toBe('stylesheet');
|
||||
// Check redirect chain
|
||||
const redirectChain = requests[1]!.redirectChain();
|
||||
expect(redirectChain).toHaveLength(3);
|
||||
@ -1006,6 +1002,41 @@ describe('cooperative request interception', function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.resourceType', () => {
|
||||
it('should work for document type', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
await page.setRequestInterception(true);
|
||||
const requests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
requests.push(request);
|
||||
void request.continue({}, 0);
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(requests).toHaveLength(1);
|
||||
const request = requests[0]!;
|
||||
expect(request.resourceType()).toBe('document');
|
||||
});
|
||||
|
||||
it('should work for stylesheets', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
await page.setRequestInterception(true);
|
||||
const cssRequests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
if (request.url().endsWith('css')) {
|
||||
cssRequests.push(request);
|
||||
}
|
||||
void request.continue({}, 0);
|
||||
});
|
||||
await page.goto(server.PREFIX + '/one-style.html');
|
||||
expect(cssRequests).toHaveLength(1);
|
||||
const request = cssRequests[0]!;
|
||||
expect(request.url()).toContain('one-style.css');
|
||||
expect(request.resourceType()).toBe('stylesheet');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function pathToFileURL(path: string): string {
|
||||
|
@ -35,7 +35,6 @@ describe('request interception', function () {
|
||||
expect(request.method()).toBe('GET');
|
||||
expect(request.postData()).toBe(undefined);
|
||||
expect(request.isNavigationRequest()).toBe(true);
|
||||
expect(request.resourceType()).toBe('document');
|
||||
expect(request.frame()!.url()).toBe('about:blank');
|
||||
expect(request.frame() === page.mainFrame()).toBe(true);
|
||||
} catch (error) {
|
||||
@ -325,7 +324,6 @@ describe('request interception', function () {
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.url()).toContain('empty.html');
|
||||
expect(requests).toHaveLength(5);
|
||||
expect(requests[2]!.resourceType()).toBe('document');
|
||||
// Check redirect chain
|
||||
const redirectChain = response.request().redirectChain();
|
||||
expect(redirectChain).toHaveLength(4);
|
||||
@ -359,8 +357,6 @@ describe('request interception', function () {
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.url()).toContain('one-style.html');
|
||||
expect(requests).toHaveLength(5);
|
||||
expect(requests[0]!.resourceType()).toBe('document');
|
||||
expect(requests[1]!.resourceType()).toBe('stylesheet');
|
||||
// Check redirect chain
|
||||
const redirectChain = requests[1]!.redirectChain();
|
||||
expect(redirectChain).toHaveLength(3);
|
||||
@ -935,6 +931,41 @@ describe('request interception', function () {
|
||||
expect(error.message).toMatch(/Invalid header/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.resourceType', () => {
|
||||
it('should work for document type', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
await page.setRequestInterception(true);
|
||||
const requests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
requests.push(request);
|
||||
void request.continue();
|
||||
});
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(requests).toHaveLength(1);
|
||||
const request = requests[0]!;
|
||||
expect(request.resourceType()).toBe('document');
|
||||
});
|
||||
|
||||
it('should work for stylesheets', async () => {
|
||||
const {page, server} = await getTestState();
|
||||
|
||||
await page.setRequestInterception(true);
|
||||
const cssRequests: HTTPRequest[] = [];
|
||||
page.on('request', request => {
|
||||
if (request.url().endsWith('css')) {
|
||||
cssRequests.push(request);
|
||||
}
|
||||
void request.continue();
|
||||
});
|
||||
await page.goto(server.PREFIX + '/one-style.html');
|
||||
expect(cssRequests).toHaveLength(1);
|
||||
const request = cssRequests[0]!;
|
||||
expect(request.url()).toContain('one-style.css');
|
||||
expect(request.resourceType()).toBe('stylesheet');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function pathToFileURL(path: string): string {
|
||||
|
Loading…
Reference in New Issue
Block a user