Skip to content

Commit

Permalink
test(android): run selected page tests on android (3) (#5910)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Mar 23, 2021
1 parent 3a27bdd commit ca35da0
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 52 deletions.
35 changes: 35 additions & 0 deletions test/browsercontext-set-extra-http-headers.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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 { it, expect } from './fixtures';

it('should override extra headers from browser context', async ({browser, server}) => {
const context = await browser.newContext({
extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
});
const page = await context.newPage();
await page.setExtraHTTPHeaders({
'Foo': 'Bar'
});
const [request] = await Promise.all([
server.waitForRequest('/empty.html'),
page.goto(server.EMPTY_PAGE),
]);
await context.close();
expect(request.headers['foo']).toBe('Bar');
expect(request.headers['bar']).toBe('foO');
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

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

it('should dispatch click event', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
Expand Down
2 changes: 1 addition & 1 deletion test/page-fill.spec.ts → test/page/page-fill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

async function giveItAChanceToFill(page) {
for (let i = 0; i < 5; i++)
Expand Down
2 changes: 1 addition & 1 deletion test/page-route.spec.ts → test/page/page-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

it('should intercept', async ({page, server}) => {
let intercepted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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


async function giveItAChanceToResolve(page) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

it('should work', async ({page, server}) => {
await page.setExtraHTTPHeaders({
Expand All @@ -42,37 +42,17 @@ it('should work with redirects', async ({page, server}) => {
expect(request.headers['foo']).toBe('bar');
});

it('should work with extra headers from browser context', async ({browser, server}) => {
const context = await browser.newContext();
await context.setExtraHTTPHeaders({
it('should work with extra headers from browser context', async ({page, server}) => {
await page.context().setExtraHTTPHeaders({
'foo': 'bar',
});
const page = await context.newPage();
const [request] = await Promise.all([
server.waitForRequest('/empty.html'),
page.goto(server.EMPTY_PAGE),
]);
await context.close();
expect(request.headers['foo']).toBe('bar');
});

it('should override extra headers from browser context', async ({browser, server}) => {
const context = await browser.newContext({
extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
});
const page = await context.newPage();
await page.setExtraHTTPHeaders({
'Foo': 'Bar'
});
const [request] = await Promise.all([
server.waitForRequest('/empty.html'),
page.goto(server.EMPTY_PAGE),
]);
await context.close();
expect(request.headers['foo']).toBe('Bar');
expect(request.headers['bar']).toBe('foO');
});

it('should throw for non-string header values', async ({browser, page}) => {
// @ts-expect-error headers must be strings
const error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/

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

import path from 'path';
import fs from 'fs';
import formidable from 'formidable';

const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');
const FILE_TO_UPLOAD = path.join(__dirname, '../assets/file-to-upload.txt');

it('should upload the file', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/fileupload.html');
Expand All @@ -39,7 +39,7 @@ it('should upload the file', async ({page, server}) => {

it('should work', async ({page}) => {
await page.setContent(`<input type=file>`);
await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
Expand Down Expand Up @@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {
server.setCSP('/empty.html', 'default-src "none"');
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<input type=file>`);
await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
Expand Down Expand Up @@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
<input type="file" name="file2">
<input type="submit" value="Submit">
</form>`);
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '/assets/file-to-upload.txt'));
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '/assets/pptr.png'));
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));
await Promise.all([
page.click('input[type=submit]'),
server.waitForRequest('/upload'),
Expand All @@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {
expect(file1.name).toBe('file-to-upload.txt');
expect(file1.type).toBe('text/plain');
expect(fs.readFileSync(file1.path).toString()).toBe(
fs.readFileSync(path.join(__dirname, '/assets/file-to-upload.txt')).toString());
fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());
expect(file2.name).toBe('pptr.png');
expect(file2.type).toBe('image/png');
expect(fs.readFileSync(file2.path).toString()).toBe(
fs.readFileSync(path.join(__dirname, '/assets/pptr.png')).toString());
fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());
});

it('should be able to read selected file', async ({page, server}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

it('should timeout', async ({page}) => {
const startTime = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

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

it('should pick up ongoing navigation', async ({page, server}) => {
let response = null;
Expand Down Expand Up @@ -140,9 +140,7 @@ it('should wait for load state of newPage', async ({browser, context, page, serv
expect(await newPage.evaluate(() => document.readyState)).toBe('complete');
});

it('should resolve after popup load', async ({browser, server}) => {
const context = await browser.newContext();
const page = await context.newPage();
it('should resolve after popup load', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
// Stall the 'load' by delaying css.
let cssResponse;
Expand All @@ -162,7 +160,6 @@ it('should resolve after popup load', async ({browser, server}) => {
await loadSatePromise;
expect(resolved).toBe(true);
expect(popup.url()).toBe(server.PREFIX + '/one-style.html');
await context.close();
});

it('should work for frame', async ({page, server}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

import { it, expect } from './fixtures';
import type { Frame } from '../index';
import { expectedSSLError } from './utils';
import { it, expect } from '../fixtures';
import type { Frame } from '../../index';
import { expectedSSLError } from '../utils';

it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import vm from 'vm';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

import { it, expect } from './fixtures';
import { attachFrame, detachFrame } from './utils';
import { it, expect } from '../fixtures';
import { attachFrame, detachFrame } from '../utils';

async function giveItTimeToLog(frame) {
await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
*/

import { it, expect } from './fixtures';
import { attachFrame, detachFrame } from './utils';
import { it, expect } from '../fixtures';
import { attachFrame, detachFrame } from '../utils';

const addElement = tag => document.body.appendChild(document.createElement(tag));

Expand Down

0 comments on commit ca35da0

Please sign in to comment.