Use playwright instead of puppeteer

This commit is contained in:
Jon Bockhorst
2020-02-10 16:56:37 -06:00
parent 1bb2fc912b
commit 7515ed6146
15 changed files with 562 additions and 380 deletions
+14 -14
View File
@@ -3,24 +3,24 @@
* @license MIT
*/
import * as puppeteer from 'puppeteer';
import { ITerminalOptions } from 'xterm';
import { pollFor } from './TestUtils';
import { pollFor, getBrowserType } from './TestUtils';
import { Browser, Page } from 'playwright';
const APP = 'http://127.0.0.1:3000/test';
let browser: puppeteer.Browser;
let page: puppeteer.Page;
let browser: Browser;
let page: Page;
const width = 800;
const height = 600;
describe('CharWidth Integration Tests', function(): void {
before(async function(): Promise<any> {
browser = await puppeteer.launch({
describe('CharWidth Integration Tests', function (): void {
before(async function (): Promise<any> {
browser = await getBrowserType().launch({
headless: process.argv.indexOf('--headless') !== -1,
args: [`--window-size=${width},${height}`, `--no-sandbox`]
});
page = (await browser.pages())[0];
page = (await browser.defaultContext().pages())[0];
await page.setViewport({ width, height });
await page.goto(APP);
await openTerminal({ rows: 5, cols: 30 });
@@ -35,37 +35,37 @@ describe('CharWidth Integration Tests', function(): void {
await page.evaluate(`window.term.reset()`);
});
it('ASCII chars', async function(): Promise<void> {
it('ASCII chars', async function (): Promise<void> {
const input = 'This is just ASCII text.#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 25);
});
it('combining chars', async function(): Promise<void> {
it('combining chars', async function (): Promise<void> {
const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 10);
});
it('surrogate chars', async function(): Promise<void> {
it('surrogate chars', async function (): Promise<void> {
const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 28);
});
it('surrogate combining chars', async function(): Promise<void> {
it('surrogate combining chars', async function (): Promise<void> {
const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 12);
});
it('fullwidth chars', async function(): Promise<void> {
it('fullwidth chars', async function (): Promise<void> {
const input = '1234567890#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 21);
});
it('fullwidth chars offset 1', async function(): Promise<void> {
it('fullwidth chars offset 1', async function (): Promise<void> {
const input = 'a1234567890#';
await page.evaluate(`window.term.write('${input}')`);
await pollFor(page, () => sumWidths(0, 1, '#'), 22);