mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-04 16:44:11 +03:00
b6c2b32b53
This patch introduces 109 "#smoke" tests - a subset of tests that makes sure that basic Playwright functionality works. This set is loosely defined; feel free to add/remove tests to the set. The only goal is to keep this set minimal & fast to run. I tried to pick tests so that various parts of Playwright functionality are exercised.
79 lines
3.2 KiB
TypeScript
79 lines
3.2 KiB
TypeScript
/**
|
|
* Copyright 2018 Google Inc. All rights reserved.
|
|
* Modifications copyright (c) Microsoft Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { test as it, expect } from './pageTest';
|
|
import { attachFrame } from '../config/utils';
|
|
|
|
it('should navigate subframes #smoke', async ({ page, server }) => {
|
|
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
|
expect(page.frames()[0].url()).toContain('/frames/one-frame.html');
|
|
expect(page.frames()[1].url()).toContain('/frames/frame.html');
|
|
|
|
const response = await page.frames()[1].goto(server.EMPTY_PAGE);
|
|
expect(response.ok()).toBe(true);
|
|
expect(response.frame()).toBe(page.frames()[1]);
|
|
});
|
|
|
|
it('should reject when frame detaches', async ({ page, server }) => {
|
|
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
|
|
|
server.setRoute('/empty.html', () => {});
|
|
const navigationPromise = page.frames()[1].goto(server.EMPTY_PAGE).catch(e => e);
|
|
await server.waitForRequest('/empty.html');
|
|
|
|
await page.$eval('iframe', frame => frame.remove());
|
|
const error = await navigationPromise;
|
|
expect(error.message).toContain('frame was detached');
|
|
});
|
|
|
|
it('should continue after client redirect', async ({ page, server, isAndroid }) => {
|
|
it.fixme(isAndroid);
|
|
|
|
server.setRoute('/frames/script.js', () => {});
|
|
const url = server.PREFIX + '/frames/child-redirect.html';
|
|
const error = await page.goto(url, { timeout: 5000, waitUntil: 'networkidle' }).catch(e => e);
|
|
expect(error.message).toContain('page.goto: Timeout 5000ms exceeded.');
|
|
expect(error.message).toContain(`navigating to "${url}", waiting until "networkidle"`);
|
|
});
|
|
|
|
it('should return matching responses', async ({ page, server }) => {
|
|
await page.goto(server.EMPTY_PAGE);
|
|
// Attach three frames.
|
|
const frames = [
|
|
await attachFrame(page, 'frame1', server.EMPTY_PAGE),
|
|
await attachFrame(page, 'frame2', server.EMPTY_PAGE),
|
|
await attachFrame(page, 'frame3', server.EMPTY_PAGE),
|
|
];
|
|
const serverResponses = [];
|
|
server.setRoute('/0.html', (req, res) => serverResponses.push(res));
|
|
server.setRoute('/1.html', (req, res) => serverResponses.push(res));
|
|
server.setRoute('/2.html', (req, res) => serverResponses.push(res));
|
|
const navigations = [];
|
|
for (let i = 0; i < 3; ++i) {
|
|
navigations.push(frames[i].goto(server.PREFIX + '/' + i + '.html'));
|
|
await server.waitForRequest('/' + i + '.html');
|
|
}
|
|
// Respond from server out-of-order.
|
|
const serverResponseTexts = ['AAA', 'BBB', 'CCC'];
|
|
for (const i of [1, 2, 0]) {
|
|
serverResponses[i].end(serverResponseTexts[i]);
|
|
const response = await navigations[i];
|
|
expect(response.frame()).toBe(frames[i]);
|
|
expect(await response.text()).toBe(serverResponseTexts[i]);
|
|
}
|
|
});
|