Skip to content

Commit ca35da0

Browse files
authored
test(android): run selected page tests on android (3) (#5910)
1 parent 3a27bdd commit ca35da0

15 files changed

+64
-52
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2018 Google Inc. All rights reserved.
3+
* Modifications copyright (c) Microsoft Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { it, expect } from './fixtures';
19+
20+
it('should override extra headers from browser context', async ({browser, server}) => {
21+
const context = await browser.newContext({
22+
extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
23+
});
24+
const page = await context.newPage();
25+
await page.setExtraHTTPHeaders({
26+
'Foo': 'Bar'
27+
});
28+
const [request] = await Promise.all([
29+
server.waitForRequest('/empty.html'),
30+
page.goto(server.EMPTY_PAGE),
31+
]);
32+
await context.close();
33+
expect(request.headers['foo']).toBe('Bar');
34+
expect(request.headers['bar']).toBe('foO');
35+
});

test/page-dispatchevent.spec.ts renamed to test/page/page-dispatchevent.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { it, expect } from './fixtures';
17+
import { it, expect } from '../fixtures';
1818

1919
it('should dispatch click event', async ({page, server}) => {
2020
await page.goto(server.PREFIX + '/input/button.html');

test/page-fill.spec.ts renamed to test/page/page-fill.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

2020
async function giveItAChanceToFill(page) {
2121
for (let i = 0; i < 5; i++)

test/page-route.spec.ts renamed to test/page/page-route.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

2020
it('should intercept', async ({page, server}) => {
2121
let intercepted = false;

test/page-select-option.spec.ts renamed to test/page/page-select-option.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

2020

2121
async function giveItAChanceToResolve(page) {

test/page-set-content.spec.ts renamed to test/page/page-set-content.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

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

test/page-set-extra-http-headers.spec.ts renamed to test/page/page-set-extra-http-headers.spec.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

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

45-
it('should work with extra headers from browser context', async ({browser, server}) => {
46-
const context = await browser.newContext();
47-
await context.setExtraHTTPHeaders({
45+
it('should work with extra headers from browser context', async ({page, server}) => {
46+
await page.context().setExtraHTTPHeaders({
4847
'foo': 'bar',
4948
});
50-
const page = await context.newPage();
5149
const [request] = await Promise.all([
5250
server.waitForRequest('/empty.html'),
5351
page.goto(server.EMPTY_PAGE),
5452
]);
55-
await context.close();
5653
expect(request.headers['foo']).toBe('bar');
5754
});
5855

59-
it('should override extra headers from browser context', async ({browser, server}) => {
60-
const context = await browser.newContext({
61-
extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
62-
});
63-
const page = await context.newPage();
64-
await page.setExtraHTTPHeaders({
65-
'Foo': 'Bar'
66-
});
67-
const [request] = await Promise.all([
68-
server.waitForRequest('/empty.html'),
69-
page.goto(server.EMPTY_PAGE),
70-
]);
71-
await context.close();
72-
expect(request.headers['foo']).toBe('Bar');
73-
expect(request.headers['bar']).toBe('foO');
74-
});
75-
7656
it('should throw for non-string header values', async ({browser, page}) => {
7757
// @ts-expect-error headers must be strings
7858
const error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);

test/page-set-input-files.spec.ts renamed to test/page/page-set-input-files.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

2020
import path from 'path';
2121
import fs from 'fs';
2222
import formidable from 'formidable';
2323

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

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

4040
it('should work', async ({page}) => {
4141
await page.setContent(`<input type=file>`);
42-
await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
42+
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
4343
expect(await page.$eval('input', input => input.files.length)).toBe(1);
4444
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
4545
});
@@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {
168168
server.setCSP('/empty.html', 'default-src "none"');
169169
await page.goto(server.EMPTY_PAGE);
170170
await page.setContent(`<input type=file>`);
171-
await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
171+
await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
172172
expect(await page.$eval('input', input => input.files.length)).toBe(1);
173173
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
174174
});
@@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
244244
<input type="file" name="file2">
245245
<input type="submit" value="Submit">
246246
</form>`);
247-
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '/assets/file-to-upload.txt'));
248-
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '/assets/pptr.png'));
247+
await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));
248+
await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));
249249
await Promise.all([
250250
page.click('input[type=submit]'),
251251
server.waitForRequest('/upload'),
@@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {
254254
expect(file1.name).toBe('file-to-upload.txt');
255255
expect(file1.type).toBe('text/plain');
256256
expect(fs.readFileSync(file1.path).toString()).toBe(
257-
fs.readFileSync(path.join(__dirname, '/assets/file-to-upload.txt')).toString());
257+
fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());
258258
expect(file2.name).toBe('pptr.png');
259259
expect(file2.type).toBe('image/png');
260260
expect(fs.readFileSync(file2.path).toString()).toBe(
261-
fs.readFileSync(path.join(__dirname, '/assets/pptr.png')).toString());
261+
fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());
262262
});
263263

264264
it('should be able to read selected file', async ({page, server}) => {

test/page-wait-for-function.spec.ts renamed to test/page/page-wait-for-function.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
18+
import { it, expect } from '../fixtures';
1919

2020
it('should timeout', async ({page}) => {
2121
const startTime = Date.now();

test/page-wait-for-load-state.spec.ts renamed to test/page/page-wait-for-load-state.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { it, expect } from './fixtures';
19-
import type { Route } from '..';
18+
import { it, expect } from '../fixtures';
19+
import type { Route } from '../..';
2020

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

143-
it('should resolve after popup load', async ({browser, server}) => {
144-
const context = await browser.newContext();
145-
const page = await context.newPage();
143+
it('should resolve after popup load', async ({page, server}) => {
146144
await page.goto(server.EMPTY_PAGE);
147145
// Stall the 'load' by delaying css.
148146
let cssResponse;
@@ -162,7 +160,6 @@ it('should resolve after popup load', async ({browser, server}) => {
162160
await loadSatePromise;
163161
expect(resolved).toBe(true);
164162
expect(popup.url()).toBe(server.PREFIX + '/one-style.html');
165-
await context.close();
166163
});
167164

168165
it('should work for frame', async ({page, server}) => {

0 commit comments

Comments
 (0)