Migrate Terminal api tests to playwright

This commit is contained in:
Daniel Imms
2023-09-02 08:18:02 -07:00
parent c099cb2a3d
commit 1624854bd7
5 changed files with 1069 additions and 1071 deletions
+1
View File
@@ -118,6 +118,7 @@ export class Viewport extends Disposable implements IViewport {
}
private _innerRefresh(): void {
debugger;
if (this._charSizeService.height > 0) {
this._currentRowHeight = this._renderService.dimensions.device.cell.height / this._coreBrowserService.dpr;
this._currentDeviceCellHeight = this._renderService.dimensions.device.cell.height;
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -3,10 +3,9 @@
* @license MIT
*/
import { test } from '@playwright/test';
import { deepStrictEqual, ok, strictEqual } from 'assert';
import type { IDisposable } from 'xterm';
import { createTestContext, ITestContext, openTerminal, pollFor } from './TestUtils';
import { deepStrictEqual, ok } from 'assert';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { ITestContext, createTestContext, openTerminal, pollFor } from './TestUtils';
let ctx: ITestContext;
test.beforeAll(async ({ browser }) => {
File diff suppressed because it is too large Load Diff
+13 -6
View File
@@ -4,13 +4,13 @@
*/
import { Browser, JSHandle, Page } from '@playwright/test';
import { deepStrictEqual } from 'assert';
import { deepStrictEqual, strictEqual } from 'assert';
import type { IRenderDimensions } from 'browser/renderer/shared/Types';
import type { IRenderService } from 'browser/services/Services';
import type { ICoreTerminal, IMarker } from 'common/Types';
import * as playwright from '@playwright/test';
import { PageFunction } from 'playwright-core/types/structs';
import { IBuffer, IBufferCell, IBufferLine, IBufferNamespace, IBufferRange, IDecoration, IDecorationOptions, IModes, ITerminalOptions, Terminal } from 'xterm';
import { IBuffer, IBufferCell, IBufferLine, IBufferNamespace, IBufferRange, IDecoration, IDecorationOptions, IModes, ITerminalInitOnlyOptions, ITerminalOptions, Terminal } from 'xterm';
import { EventEmitter } from '../../out/common/EventEmitter';
// TODO: We could avoid needing this
import deepEqual = require('deep-equal');
@@ -353,12 +353,19 @@ class TerminalCoreProxy {
}
}
export async function openTerminal(ctx: ITestContext, options: ITerminalOptions = {}): Promise<void> {
export async function openTerminal(ctx: ITestContext, options: ITerminalOptions | ITerminalInitOnlyOptions = {}): Promise<void> {
await ctx.page.evaluate(`
if ('term' in window) {
if ('term' in window) {
try {
window.term.dispose();
}
window.term = new Terminal(${JSON.stringify(options)});
} catch {}
}
`);
// HACK: Tests may have side effects that could cause the terminal not to be removed. This
// assertion catches this case early.
strictEqual(await ctx.page.evaluate(`document.querySelector('#terminal-container').children.length`), 0, 'there must be no terminals on the page');
await ctx.page.evaluate(`
window.term = new Terminal(${JSON.stringify({ allowProposedApi: true, ...options })});
window.term.open(document.querySelector('#terminal-container'));
`);
await ctx.page.waitForSelector('.xterm-rows');