Skip to content

Commit

Permalink
chore: split playwright.fixtures into files (6) (#3988)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Sep 26, 2020
1 parent 423485e commit 109688a
Show file tree
Hide file tree
Showing 59 changed files with 450 additions and 407 deletions.
16 changes: 8 additions & 8 deletions test/accessibility.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

it('should work', async ({ page, isFirefox, isChromium }) => {
await page.setContent(`
Expand Down Expand Up @@ -139,8 +139,8 @@ it('should not report text nodes inside controls', async function({page, isFiref
expect(await page.accessibility.snapshot()).toEqual(golden);
});

it('rich text editable fields should have children', (test, parameters) => {
test.skip(options.WEBKIT(parameters), 'WebKit rich text accessibility is iffy');
it('rich text editable fields should have children', (test, { browserName }) => {
test.skip(browserName === 'webkit', 'WebKit rich text accessibility is iffy');
}, async function({page, isFirefox}) {
await page.setContent(`
<div contenteditable="true">
Expand Down Expand Up @@ -172,8 +172,8 @@ it('rich text editable fields should have children', (test, parameters) => {
expect(snapshot.children[0]).toEqual(golden);
});

it('rich text editable fields with role should have children', (test, parameters) => {
test.skip(options.WEBKIT(parameters), 'WebKit rich text accessibility is iffy');
it('rich text editable fields with role should have children', (test, { browserName }) => {
test.skip(browserName === 'webkit', 'WebKit rich text accessibility is iffy');
}, async function({page, isFirefox}) {
await page.setContent(`
<div contenteditable="true" role='textbox'>
Expand Down Expand Up @@ -203,9 +203,9 @@ it('rich text editable fields with role should have children', (test, parameters
expect(snapshot.children[0]).toEqual(golden);
});

describe('contenteditable', (suite, parameters) => {
suite.skip(options.FIREFOX(parameters), 'Firefox does not support contenteditable="plaintext-only"');
suite.skip(options.WEBKIT(parameters), 'WebKit rich text accessibility is iffy');
describe('contenteditable', (suite, { browserName }) => {
suite.skip(browserName === 'firefox', 'Firefox does not support contenteditable="plaintext-only"');
suite.skip(browserName === 'webkit', 'WebKit rich text accessibility is iffy');
}, () => {
it('plain text field with role should not have children', async function({page}) {
await page.setContent(`
Expand Down
6 changes: 3 additions & 3 deletions test/autowaiting-basic.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('should await navigation when clicking anchor', async ({page, server}) => {
const messages = [];
Expand Down Expand Up @@ -201,8 +201,8 @@ it('should work with goto following click', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
});

it('should report navigation in the log when clicking anchor', (test, parameters) => {
test.skip(options.WIRE);
it('should report navigation in the log when clicking anchor', (test, { wire }) => {
test.skip(wire);
}, async ({page, server}) => {
await page.setContent(`<a href="${server.PREFIX + '/frames/one-frame.html'}">click me</a>`);
const __testHookAfterPointerAction = () => new Promise(f => setTimeout(f, 6000));
Expand Down
10 changes: 5 additions & 5 deletions test/browsercontext-cookies.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('should return no cookies in pristine browser context', async ({context, page, server}) => {
expect(await context.cookies()).toEqual([]);
Expand Down Expand Up @@ -73,8 +73,8 @@ it('should properly report httpOnly cookie', async ({context, page, server}) =>
expect(cookies[0].httpOnly).toBe(true);
});

it('should properly report "Strict" sameSite cookie', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
it('should properly report "Strict" sameSite cookie', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform === 'win32');
}, async ({context, page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Strict');
Expand All @@ -86,8 +86,8 @@ it('should properly report "Strict" sameSite cookie', (test, parameters) => {
expect(cookies[0].sameSite).toBe('Strict');
});

it('should properly report "Lax" sameSite cookie', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
it('should properly report "Lax" sameSite cookie', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform === 'win32');
}, async ({context, page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Lax');
Expand Down
10 changes: 5 additions & 5 deletions test/browsercontext-credentials.spec.ts
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('should fail without credentials', (test, parameters) => {
test.fail(options.CHROMIUM(parameters) && !options.HEADLESS);
it('should fail without credentials', (test, { browserName, headful}) => {
test.fail(browserName === 'chromium' && headful);
}, async ({browser, server}) => {
server.setAuth('/empty.html', 'user', 'pass');
const context = await browser.newContext();
Expand All @@ -28,8 +28,8 @@ it('should fail without credentials', (test, parameters) => {
await context.close();
});

it('should work with setHTTPCredentials', (test, parameters) => {
test.fail(options.CHROMIUM(parameters) && !options.HEADLESS);
it('should work with setHTTPCredentials', (test, { browserName, headful }) => {
test.fail(browserName === 'chromium' && headful);
}, async ({browser, server}) => {
server.setAuth('/empty.html', 'user', 'pass');
const context = await browser.newContext();
Expand Down
6 changes: 3 additions & 3 deletions test/browsercontext-device.spec.ts
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

describe('device', (suite, parameters) => {
suite.skip(options.FIREFOX(parameters));
describe('device', (suite, { browserName }) => {
suite.skip(browserName === 'firefox');
}, () => {
it('should work', async ({playwright, browser, server}) => {
const iPhone = playwright.devices['iPhone 6'];
Expand Down
12 changes: 6 additions & 6 deletions test/browsercontext-page-event.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('should have url', async ({browser, server}) => {
const context = await browser.newContext();
Expand Down Expand Up @@ -157,8 +157,8 @@ it('should fire page lifecycle events', async function({browser, server}) {
await context.close();
});

it('should work with Shift-clicking', (test, parameters) => {
test.fixme(options.WEBKIT(parameters), 'WebKit: Shift+Click does not open a new window.');
it('should work with Shift-clicking', (test, { browserName }) => {
test.fixme(browserName === 'webkit', 'WebKit: Shift+Click does not open a new window.');
}, async ({browser, server}) => {
const context = await browser.newContext();
const page = await context.newPage();
Expand All @@ -172,9 +172,9 @@ it('should work with Shift-clicking', (test, parameters) => {
await context.close();
});

it('should work with Ctrl-clicking', (test, parameters) => {
test.fixme(options.WEBKIT(parameters), 'Ctrl+Click does not open a new tab.');
test.fixme(options.FIREFOX(parameters), 'Reports an opener in this case.');
it('should work with Ctrl-clicking', (test, { browserName }) => {
test.fixme(browserName === 'webkit', 'Ctrl+Click does not open a new tab.');
test.fixme(browserName === 'firefox', 'Reports an opener in this case.');
}, async ({browser, server, isMac}) => {
const context = await browser.newContext();
const page = await context.newPage();
Expand Down
10 changes: 5 additions & 5 deletions test/browsercontext-viewport-mobile.spec.ts
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

describe('mobile viewport', (suite, parameters) => {
suite.skip(options.FIREFOX(parameters));
describe('mobile viewport', (suite, { browserName }) => {
suite.skip(browserName === 'firefox');
}, () => {
it('should support mobile emulation', async ({playwright, browser, server}) => {
const iPhone = playwright.devices['iPhone 6'];
Expand Down Expand Up @@ -131,8 +131,8 @@ describe('mobile viewport', (suite, parameters) => {
await context.close();
});

it('should emulate the hover media feature', (test, parameters) => {
test.fail(options.WEBKIT(parameters));
it('should emulate the hover media feature', (test, { browserName }) => {
test.fail(browserName === 'webkit');
}, async ({playwright, browser}) => {
const iPhone = playwright.devices['iPhone 6'];
const mobilepage = await browser.newPage({ ...iPhone });
Expand Down
5 changes: 2 additions & 3 deletions test/browsertype-connect.spec.ts
Expand Up @@ -15,12 +15,11 @@
* limitations under the License.
*/

import { options } from './fixtures';
import { serverFixtures } from './remoteServer.fixture';
const { it, expect, describe } = serverFixtures;

describe('connect', suite => {
suite.skip(options.WIRE);
describe('connect', (suite, { wire }) => {
suite.skip(wire);
suite.slow();
}, () => {
it('should be able to reconnect to a browser', async ({browserType, remoteServer, server}) => {
Expand Down
6 changes: 3 additions & 3 deletions test/browsertype-launch-server.spec.ts
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

describe('lauch server', suite => {
suite.skip(options.WIRE);
describe('lauch server', (suite, { wire }) => {
suite.skip(wire);
}, () => {
it('should work', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions);
Expand Down
18 changes: 9 additions & 9 deletions test/browsertype-launch.spec.ts
Expand Up @@ -16,7 +16,7 @@
*/

import path from 'path';
import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('should reject all promises when browser is closed', async ({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch(defaultBrowserOptions);
Expand Down Expand Up @@ -48,8 +48,8 @@ it('should throw if port option is passed for persistent context', async ({brows
expect(error.message).toContain('Cannot specify a port without launching as a server.');
});

it('should throw if page argument is passed', (test, parameters) => {
test.skip(options.FIREFOX(parameters));
it('should throw if page argument is passed', (test, { browserName }) => {
test.skip(browserName === 'firefox');
}, async ({browserType, defaultBrowserOptions}) => {
let waitError = null;
const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] });
Expand All @@ -73,8 +73,8 @@ it('should reject if executable path is invalid', async ({browserType, defaultBr
expect(waitError.message).toContain('Failed to launch');
});

it('should handle timeout', (test, parameters) => {
test.skip(options.WIRE);
it('should handle timeout', (test, { wire }) => {
test.skip(wire);
}, async ({browserType, defaultBrowserOptions}) => {
const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };
const error = await browserType.launch(options).catch(e => e);
Expand All @@ -83,17 +83,17 @@ it('should handle timeout', (test, parameters) => {
expect(error.message).toContain(`<launched> pid=`);
});

it('should handle exception', (test, parameters) => {
test.skip(options.WIRE);
it('should handle exception', (test, { wire }) => {
test.skip(wire);
}, async ({browserType, defaultBrowserOptions}) => {
const e = new Error('Dummy');
const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };
const error = await browserType.launch(options).catch(e => e);
expect(error.message).toContain('Dummy');
});

it('should report launch log', (test, parameters) => {
test.skip(options.WIRE);
it('should report launch log', (test, { wire }) => {
test.skip(wire);
}, async ({browserType, defaultBrowserOptions}) => {
const e = new Error('Dummy');
const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };
Expand Down
10 changes: 5 additions & 5 deletions test/capabilities.spec.ts
Expand Up @@ -15,10 +15,10 @@
*/

import url from 'url';
import { it, expect, options } from './fixtures';
import { it, expect } from './fixtures';

it('Web Assembly should work', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
it('Web Assembly should work', (test, { browserName, platform }) => {
test.fail(browserName === 'webkit' && platform === 'win32');
}, async function({page, server}) {
await page.goto(server.PREFIX + '/wasm/table2.html');
expect(await page.evaluate('loadTable()')).toBe('42, 83');
Expand Down Expand Up @@ -50,8 +50,8 @@ it('should respect CSP', async ({page, server}) => {
expect(await page.evaluate(() => window['testStatus'])).toBe('SUCCESS');
});

it('should play video', (test, parameters) => {
test.fixme(options.WEBKIT(parameters) && (options.WIN(parameters) || options.LINUX(parameters)));
it('should play video', (test, { browserName, platform }) => {
test.fixme(browserName === 'webkit' && (platform !== 'darwin'));
}, async ({page, asset, isWebKit}) => {
// TODO: the test passes on Windows locally but fails on GitHub Action bot,
// apparently due to a Media Pack issue in the Windows Server.
Expand Down
6 changes: 3 additions & 3 deletions test/channels.spec.ts
Expand Up @@ -16,7 +16,7 @@
*/

import domain from 'domain';
import { options, fixtures as baseFixtures } from './fixtures';
import { fixtures as baseFixtures } from './fixtures';
import type { ChromiumBrowser } from '..';

type DomainFixtures = {
Expand Down Expand Up @@ -84,8 +84,8 @@ it('should scope context handles', async ({browserType, browser, server}) => {
await expectScopeState(browser, GOLDEN_PRECONDITION);
});

it('should scope CDPSession handles', (test, parameters) => {
test.skip(!options.CHROMIUM(parameters));
it('should scope CDPSession handles', (test, { browserName }) => {
test.skip(browserName !== 'chromium');
}, async ({browserType, browser}) => {
const GOLDEN_PRECONDITION = {
_guid: '',
Expand Down
6 changes: 3 additions & 3 deletions test/chromium-css-coverage.spec.ts
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

describe('oopif', (suite, parameters) => {
suite.skip(!options.CHROMIUM(parameters));
describe('oopif', (suite, { browserName }) => {
suite.skip(browserName !== 'chromium');
}, () => {
it('should work', async function({browserType, page, server}) {
await page.coverage.startCSSCoverage();
Expand Down
10 changes: 5 additions & 5 deletions test/chromium-js-coverage.spec.ts
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

import { it, expect, describe, options } from './fixtures';
import { it, expect, describe } from './fixtures';

it('should be missing', (test, parameters) => {
test.skip(options.CHROMIUM(parameters));
it('should be missing', (test, { browserName }) => {
test.skip(browserName === 'chromium');
},
async function({page}) {
expect(page.coverage).toBe(null);
});

describe('oopif', (suite, parameters) => {
suite.skip(!options.CHROMIUM(parameters));
describe('oopif', (suite, { browserName }) => {
suite.skip(browserName !== 'chromium');
}, () => {
it('should work', async function({page, server}) {
await page.coverage.startJSCoverage();
Expand Down
6 changes: 3 additions & 3 deletions test/chromium/chromium.spec.ts
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { it, expect, describe, options } from '../fixtures';
import { it, expect, describe } from '../fixtures';
import type { ChromiumBrowserContext } from '../..';

describe('chromium', (suite, parameters) => {
suite.skip(!options.CHROMIUM(parameters));
describe('chromium', (suite, { browserName }) => {
suite.skip(browserName !== 'chromium');
}, () => {
it('should create a worker from a service worker', async ({page, server, context}) => {
const [worker] = await Promise.all([
Expand Down

0 comments on commit 109688a

Please sign in to comment.