From f44d68ef4aeca9986b4b4f8e577354d5d373385c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 3 Jul 2024 03:10:58 -0700 Subject: [PATCH] Remain test/api project --- .eslintrc.json | 1 - test/api/README.md | 1 - test/api/TestUtils.ts | 90 ------------------------------------------ test/api/tsconfig.json | 34 ---------------- tsconfig.all.json | 1 - 5 files changed, 127 deletions(-) delete mode 100644 test/api/README.md delete mode 100644 test/api/TestUtils.ts delete mode 100644 test/api/tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 5e49b021bb..958b53a106 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ "src/browser/tsconfig.json", "src/common/tsconfig.json", "src/headless/tsconfig.json", - "test/api/tsconfig.json", "test/benchmark/tsconfig.json", "test/playwright/tsconfig.json", "addons/addon-attach/src/tsconfig.json", diff --git a/test/api/README.md b/test/api/README.md deleted file mode 100644 index 1c86815c5f..0000000000 --- a/test/api/README.md +++ /dev/null @@ -1 +0,0 @@ -This project contains helpers for the legacy playwright tests. Currently addons use this as a dependency, when all addons have moved over to use `@playright/test` this can be removed. diff --git a/test/api/TestUtils.ts b/test/api/TestUtils.ts deleted file mode 100644 index cee59cceb1..0000000000 --- a/test/api/TestUtils.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import * as playwright from '@playwright/test'; -import deepEqual = require('deep-equal'); -import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm'; -import { deepStrictEqual } from 'assert'; - -export async function pollFor(page: playwright.Page, evalOrFn: string | (() => Promise), val: T, preFn?: () => Promise, maxDuration?: number): Promise { - if (preFn) { - await preFn(); - } - const result = typeof evalOrFn === 'string' ? await page.evaluate(evalOrFn) : await evalOrFn(); - - if (process.env.DEBUG) { - console.log('pollFor result: ', result); - } - - if (!deepEqual(result, val)) { - if (maxDuration === undefined) { - maxDuration = 2000; - } - if (maxDuration <= 0) { - deepStrictEqual(result, val, 'pollFor max duration exceeded'); - } - return new Promise(r => { - setTimeout(() => r(pollFor(page, evalOrFn, val, preFn, maxDuration! - 10)), 10); - }); - } -} - -export async function writeSync(page: playwright.Page, data: string): Promise { - await page.evaluate(` - window.ready = false; - window.term.write('${data}', () => window.ready = true); - `); - await pollFor(page, 'window.ready', true); -} - -export async function timeout(ms: number): Promise { - return new Promise(r => setTimeout(r, ms)); -} - -export async function openTerminal(page: playwright.Page, options: ITerminalOptions & ITerminalInitOnlyOptions = {}, testOptions: { loadUnicodeGraphemesAddon: boolean } = { loadUnicodeGraphemesAddon: true }): Promise { - await page.evaluate(`window.term = new Terminal(${JSON.stringify({ allowProposedApi: true, ...options })})`); - await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`); - - // HACK: This is a soft layer breaker that's temporarily included until unicode graphemes have - // more complete integration tests. See https://github.com/xtermjs/xterm.js/pull/4519#discussion_r1285234453 - if (testOptions.loadUnicodeGraphemesAddon) { - await page.evaluate(` - window.unicode = new UnicodeGraphemesAddon(); - window.term.loadAddon(window.unicode); - window.term.unicode.activeVersion = '15-graphemes'; - `); - } - await page.waitForSelector('.xterm-rows'); -} - -export function getBrowserType(): playwright.BrowserType | playwright.BrowserType | playwright.BrowserType { - // Default to chromium - let browserType: playwright.BrowserType | playwright.BrowserType | playwright.BrowserType = playwright['chromium']; - - const index = process.argv.indexOf('--browser'); - if (index !== -1 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { - const string = process.argv[index + 1]; - if (string === 'firefox' || string === 'webkit') { - browserType = playwright[string]; - } - } - - return browserType; -} - -export function launchBrowser(opts?: playwright.LaunchOptions): Promise { - const browserType = getBrowserType(); - const options: playwright.LaunchOptions = { - ...opts, - headless: process.argv.includes('--headless') - }; - - const index = process.argv.indexOf('--executablePath'); - if (index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { - options.executablePath = process.argv[index + 1]; - } - - return browserType.launch(options); -} diff --git a/test/api/tsconfig.json b/test/api/tsconfig.json deleted file mode 100644 index bc050db4ff..0000000000 --- a/test/api/tsconfig.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "compilerOptions": { - "lib": [ - "dom", - "es2021" - ], - "rootDir": ".", - "outDir": "../../out-test/api", - "types": [ - "../../node_modules/@types/mocha", - "../../node_modules/@types/node" - ], - "sourceMap": true, - "removeComments": true, - "pretty": true, - "strict": true, - "declaration": true, - "baseUrl": ".", - "paths": { - "browser/*": [ - "../../src/browser/*" - ] - } - }, - "include": [ - "./**/*", - "../../typings/xterm.d.ts" - ], - "references": [ - { - "path": "../../src/browser" - } - ] -} diff --git a/tsconfig.all.json b/tsconfig.all.json index d40761f337..0311a65eda 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -4,7 +4,6 @@ "references": [ { "path": "./src/browser" }, { "path": "./src/headless" }, - { "path": "./test/api" }, { "path": "./test/benchmark" }, { "path": "./test/playwright" }, { "path": "./addons/addon-attach" },