Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: misc test fixes (#2857)

Pavel Feldmanb3ca4afd4044
diff --git a/src/rpc/channels.ts b/src/rpc/channels.ts
index 2bf97775ba..d565d4aa95 100644
--- a/src/rpc/channels.ts
+++ b/src/rpc/channels.ts
@@ -274,14 +274,12 @@ export type RequestInitializer = {
export interface RouteChannel extends Channel {
abort(params: { errorCode: string }): Promise<void>;
- continue(params: { overrides: { method?: string, headers?: types.Headers, postData?: string } }): Promise<void>;
+ continue(params: { method?: string, headers?: types.Headers, postData?: string }): Promise<void>;
fulfill(params: {
- response: {
- status?: number,
- headers?: types.Headers,
- body: string,
- isBase64: boolean,
- }
+ status?: number,
+ headers?: types.Headers,
+ body: string,
+ isBase64: boolean,
}): Promise<void>;
}
export type RouteInitializer = {
diff --git a/src/rpc/client/network.ts b/src/rpc/client/network.ts
index 5f2e22e94a..99f44d2fa5 100644
--- a/src/rpc/client/network.ts
+++ b/src/rpc/client/network.ts
@@ -152,11 +152,11 @@ export class Route extends ChannelOwner<RouteChannel, RouteInitializer> {
async fulfill(response: types.FulfillResponse & { path?: string }) {
const normalized = await normalizeFulfillParameters(response);
- await this._channel.fulfill({ response: normalized });
+ await this._channel.fulfill(normalized);
}
async continue(overrides: { method?: string; headers?: types.Headers; postData?: string } = {}) {
- await this._channel.continue({ overrides });
+ await this._channel.continue(overrides);
}
}
diff --git a/src/rpc/server/networkDispatchers.ts b/src/rpc/server/networkDispatchers.ts
index 607cf2779b..af511100b4 100644
--- a/src/rpc/server/networkDispatchers.ts
+++ b/src/rpc/server/networkDispatchers.ts
@@ -80,16 +80,15 @@ export class RouteDispatcher extends Dispatcher<Route, RouteInitializer> impleme
});
}
- async continue(params: { overrides: { method?: string, headers?: types.Headers, postData?: string } }): Promise<void> {
- await this._object.continue(params.overrides);
+ async continue(params: { method?: string, headers?: types.Headers, postData?: string }): Promise<void> {
+ await this._object.continue(params);
}
- async fulfill(params: { response: { status?: number, headers?: types.Headers, contentType?: string, body: string, isBase64: boolean } }): Promise<void> {
- const { response } = params;
+ async fulfill(params: { status?: number, headers?: types.Headers, contentType?: string, body: string, isBase64: boolean }): Promise<void> {
await this._object.fulfill({
- status: response.status,
- headers: response.headers,
- body: response.isBase64 ? Buffer.from(response.body, 'base64') : response.body,
+ status: params.status,
+ headers: params.headers,
+ body: params.isBase64 ? Buffer.from(params.body, 'base64') : params.body,
});
}
diff --git a/test/jshandle.spec.js b/test/jshandle.spec.js
index 521438d4ad..b7e3b4d20c 100644
--- a/test/jshandle.spec.js
+++ b/test/jshandle.spec.js
@@ -90,13 +90,6 @@ describe('Page.evaluateHandle', function() {
}, { foo: 42 });
expect(result).toEqual({});
});
- it('should use the same JS wrappers', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => {
- window.FOO = 123;
- return window;
- });
- expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
- });
it('should work with primitives', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => {
window.FOO = 123;
@@ -152,10 +145,10 @@ describe('JSHandle.jsonValue', function() {
const json = await aHandle.jsonValue();
expect(json).toEqual({foo: 'bar'});
});
- it('should not work with dates', async({page, server}) => {
+ it('should work with dates', async({page, server}) => {
const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z'));
const json = await dateHandle.jsonValue();
- expect(json).toEqual({});
+ expect(json instanceof Date).toBeTruthy();
});
it('should throw for circular objects', async({page, server}) => {
const windowHandle = await page.evaluateHandle('window');
@@ -163,11 +156,6 @@ describe('JSHandle.jsonValue', function() {
await windowHandle.jsonValue().catch(e => error = e);
expect(error.message).toContain('Argument is a circular structure');
});
- it('should work with tricky values', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => ({a: 1}));
- const json = await aHandle.jsonValue();
- expect(json).toEqual({a: 1});
- });
});
describe('JSHandle.getProperties', function() {
diff --git a/test/keyboard.spec.ts b/test/keyboard.spec.ts
index 20858032c3..81b11e44bd 100644
--- a/test/keyboard.spec.ts
+++ b/test/keyboard.spec.ts
@@ -34,13 +34,13 @@ describe('Keyboard', function() {
await page.type('textarea', 'Hello World!');
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello World!');
for (let i = 0; i < 'World!'.length; i++)
- page.keyboard.press('ArrowLeft');
+ await page.keyboard.press('ArrowLeft');
await page.keyboard.type('inserted ');
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello inserted World!');
- page.keyboard.down('Shift');
+ await page.keyboard.down('Shift');
for (let i = 0; i < 'inserted '.length; i++)
- page.keyboard.press('ArrowLeft');
- page.keyboard.up('Shift');
+ await page.keyboard.press('ArrowLeft');
+ await page.keyboard.up('Shift');
await page.keyboard.press('Backspace');
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello World!');
});