Skip to content

Commit

Permalink
test: roll test runner 0.9.16
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Sep 29, 2020
1 parent 109688a commit 88b7f3d
Show file tree
Hide file tree
Showing 168 changed files with 152 additions and 212 deletions.
65 changes: 19 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"ws": "^7.3.1"
},
"devDependencies": {
"@playwright/test": "^0.9.6",
"@playwright/test-runner": "^0.9.15",
"@playwright/test": "^0.9.7",
"@playwright/test-runner": "^0.9.16",
"@types/debug": "^4.1.5",
"@types/extract-zip": "^1.6.2",
"@types/mime": "^2.0.3",
Expand Down
10 changes: 7 additions & 3 deletions src/client/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ import { ChromiumCoverage } from './chromiumCoverage';
import { Waiter } from './waiter';

import * as fs from 'fs';
import * as path from 'path';
import * as util from 'util';
import { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions } from './types';
import { evaluationScript, urlMatches } from './clientHelper';
import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils/utils';

const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
const mkdirAsync = util.promisify(fs.mkdir);

type PDFOptions = Omit<channels.PagePdfParams, 'width' | 'height' | 'margin'> & {
width?: string | number,
height?: string | number,
Expand All @@ -56,8 +60,6 @@ type PDFOptions = Omit<channels.PagePdfParams, 'width' | 'height' | 'margin'> &
};
type Listener = (...args: any[]) => void;

const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));

export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitializer> {
private _browserContext: BrowserContext;
_ownedContext: BrowserContext | undefined;
Expand Down Expand Up @@ -581,8 +583,10 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
}
const result = await this._channel.pdf(transportOptions);
const buffer = Buffer.from(result.pdf, 'base64');
if (options.path)
if (options.path) {
await mkdirAsync(path.dirname(options.path), { recursive: true });
await fsWriteFileAsync(options.path, buffer);
}
return buffer;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/trace/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Tracer implements ContextListener {
async onContextCreated(context: BrowserContext): Promise<void> {
if (!context._options.recordTrace)
return;
const traceStorageDir = path.join(context._browser._options.artifactsPath!, '.playwright-shared');
const traceStorageDir = path.join(context._browser._options.artifactsPath!, 'trace-resources');
const traceFile = path.join(context._artifactsPath!, 'playwright.trace');
const contextTracer = new ContextTracer(context, traceStorageDir, traceFile);
this._contextTracers.set(context, contextTracer);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed test/__snapshots__/request-fulfill/webkit/mock-svg.png
Diff not rendered.
2 changes: 1 addition & 1 deletion test/chromium/oopif.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('oopif', (suite, { browserName }) => {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
expect(await page.screenshot()).toMatchImage(golden('screenshot-oopif.png'), { threshold: 0.3 });
expect(await page.screenshot()).toMatchImage('screenshot-oopif.png', { threshold: 0.3 });
});

it('should load oopif iframes with subresources and route', async function({browser, page, server, context}) {
Expand Down
8 changes: 4 additions & 4 deletions test/chromium/tracing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type TestState = {
const fixtures = playwrightFixtures.declareTestFixtures<TestState>();
const { it, expect, describe, defineTestFixture } = fixtures;

defineTestFixture('outputTraceFile', async ({testOutputDir}, test) => {
await test(path.join(testOutputDir, `trace.json`));
defineTestFixture('outputTraceFile', async ({testOutputPath}, test) => {
await test(testOutputPath(path.join(`trace.json`)));
});

describe('oopif', (suite, { browserName }) => {
Expand All @@ -39,8 +39,8 @@ describe('oopif', (suite, { browserName }) => {
expect(fs.existsSync(outputTraceFile)).toBe(true);
});

it('should create directories as needed', async ({browser, page, server, testOutputDir}) => {
const filePath = path.join(testOutputDir, 'these', 'are', 'directories', 'trace.json');
it('should create directories as needed', async ({browser, page, server, testOutputPath}) => {
const filePath = testOutputPath(path.join('these', 'are', 'directories', 'trace.json'));
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: filePath});
await page.goto(server.PREFIX + '/grid.html');
await (browser as ChromiumBrowser).stopTracing();
Expand Down
38 changes: 19 additions & 19 deletions test/download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,28 @@ it('should report downloads with acceptDownloads: true', async ({browser, server
await page.close();
});

it('should save to user-specified path', async ({testOutputDir, browser, server}) => {
it('should save to user-specified path', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
await download.saveAs(userPath);
expect(fs.existsSync(userPath)).toBeTruthy();
expect(fs.readFileSync(userPath).toString()).toBe('Hello world');
await page.close();
});

it('should save to user-specified path without updating original path', async ({testOutputDir, browser, server}) => {
it('should save to user-specified path without updating original path', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
await download.saveAs(userPath);
expect(fs.existsSync(userPath)).toBeTruthy();
expect(fs.readFileSync(userPath).toString()).toBe('Hello world');
Expand All @@ -93,33 +93,33 @@ it('should save to user-specified path without updating original path', async ({
await page.close();
});

it('should save to two different paths with multiple saveAs calls', async ({testOutputDir, browser, server}) => {
it('should save to two different paths with multiple saveAs calls', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
await download.saveAs(userPath);
expect(fs.existsSync(userPath)).toBeTruthy();
expect(fs.readFileSync(userPath).toString()).toBe('Hello world');

const anotherUserPath = path.join(testOutputDir, 'download (2).txt');
const anotherUserPath = testOutputPath('download (2).txt');
await download.saveAs(anotherUserPath);
expect(fs.existsSync(anotherUserPath)).toBeTruthy();
expect(fs.readFileSync(anotherUserPath).toString()).toBe('Hello world');
await page.close();
});

it('should save to overwritten filepath', async ({testOutputDir, browser, server}) => {
it('should save to overwritten filepath', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const dir = path.join(testOutputDir, 'downloads');
const dir = testOutputPath('downloads');
const userPath = path.join(dir, 'download.txt');
await download.saveAs(userPath);
expect((await util.promisify(fs.readdir)(dir)).length).toBe(1);
Expand All @@ -130,14 +130,14 @@ it('should save to overwritten filepath', async ({testOutputDir, browser, server
await page.close();
});

it('should create subdirectories when saving to non-existent user-specified path', async ({testOutputDir, browser, server}) => {
it('should create subdirectories when saving to non-existent user-specified path', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const nestedPath = path.join(testOutputDir, 'these', 'are', 'directories', 'download.txt');
const nestedPath = testOutputPath(path.join('these', 'are', 'directories', 'download.txt'));
await download.saveAs(nestedPath);
expect(fs.existsSync(nestedPath)).toBeTruthy();
expect(fs.readFileSync(nestedPath).toString()).toBe('Hello world');
Expand All @@ -146,15 +146,15 @@ it('should create subdirectories when saving to non-existent user-specified path

it('should save when connected remotely', (test, { wire }) => {
test.skip(wire);
}, async ({testOutputDir, server, browserType, remoteServer}) => {
}, async ({testOutputPath, server, browserType, remoteServer}) => {
const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() });
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const nestedPath = path.join(testOutputDir, 'these', 'are', 'directories', 'download.txt');
const nestedPath = testOutputPath(path.join('these', 'are', 'directories', 'download.txt'));
await download.saveAs(nestedPath);
expect(fs.existsSync(nestedPath)).toBeTruthy();
expect(fs.readFileSync(nestedPath).toString()).toBe('Hello world');
Expand All @@ -163,27 +163,27 @@ it('should save when connected remotely', (test, { wire }) => {
await browser.close();
});

it('should error when saving with downloads disabled', async ({testOutputDir, browser, server}) => {
it('should error when saving with downloads disabled', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: false });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
const { message } = await download.saveAs(userPath).catch(e => e);
expect(message).toContain('Pass { acceptDownloads: true } when you are creating your browser context');
await page.close();
});

it('should error when saving after deletion', async ({testOutputDir, browser, server}) => {
it('should error when saving after deletion', async ({testOutputPath, browser, server}) => {
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
await download.delete();
const { message } = await download.saveAs(userPath).catch(e => e);
expect(message).toContain('Download already deleted. Save before deleting.');
Expand All @@ -192,15 +192,15 @@ it('should error when saving after deletion', async ({testOutputDir, browser, se

it('should error when saving after deletion when connected remotely', (test, { wire }) => {
test.skip(wire);
}, async ({testOutputDir, server, browserType, remoteServer}) => {
}, async ({testOutputPath, server, browserType, remoteServer}) => {
const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() });
const page = await browser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.click('a')
]);
const userPath = path.join(testOutputDir, 'download.txt');
const userPath = testOutputPath('download.txt');
await download.delete();
const { message } = await download.saveAs(userPath).catch(e => e);
expect(message).toContain('Download already deleted. Save before deleting.');
Expand Down
Loading

0 comments on commit 88b7f3d

Please sign in to comment.