chore(ui): move TeleSuiteUpdater into testIsomorphic (#32273)
Preparation for https://github.com/microsoft/playwright/issues/32076.
This commit is contained in:
parent
16e76cb71a
commit
850436c656
|
|
@ -14,11 +14,24 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TeleReporterReceiver, TeleSuite } from '@testIsomorphic/teleReceiver';
|
import { TeleReporterReceiver, TeleSuite } from './teleReceiver';
|
||||||
import { statusEx } from '@testIsomorphic/testTree';
|
import { statusEx } from './testTree';
|
||||||
import type { ReporterV2 } from 'playwright/src/reporters/reporterV2';
|
import type { ReporterV2 } from '../reporters/reporterV2';
|
||||||
import type * as reporterTypes from 'playwright/types/testReporter';
|
import type * as reporterTypes from '../../types/testReporter';
|
||||||
import type { Progress, TestModel } from './uiModeModel';
|
|
||||||
|
export type TeleSuiteUpdaterProgress = {
|
||||||
|
total: number;
|
||||||
|
passed: number;
|
||||||
|
failed: number;
|
||||||
|
skipped: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TeleSuiteUpdaterTestModel = {
|
||||||
|
config: reporterTypes.FullConfig;
|
||||||
|
rootSuite: reporterTypes.Suite;
|
||||||
|
loadErrors: reporterTypes.TestError[];
|
||||||
|
progress: TeleSuiteUpdaterProgress;
|
||||||
|
};
|
||||||
|
|
||||||
export type TeleSuiteUpdaterOptions = {
|
export type TeleSuiteUpdaterOptions = {
|
||||||
onUpdate: (force?: boolean) => void,
|
onUpdate: (force?: boolean) => void,
|
||||||
|
|
@ -30,7 +43,7 @@ export class TeleSuiteUpdater {
|
||||||
rootSuite: TeleSuite | undefined;
|
rootSuite: TeleSuite | undefined;
|
||||||
config: reporterTypes.FullConfig | undefined;
|
config: reporterTypes.FullConfig | undefined;
|
||||||
readonly loadErrors: reporterTypes.TestError[] = [];
|
readonly loadErrors: reporterTypes.TestError[] = [];
|
||||||
readonly progress: Progress = {
|
readonly progress: TeleSuiteUpdaterProgress = {
|
||||||
total: 0,
|
total: 0,
|
||||||
passed: 0,
|
passed: 0,
|
||||||
failed: 0,
|
failed: 0,
|
||||||
|
|
@ -118,11 +131,11 @@ export class TeleSuiteUpdater {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
onStdOut: () => {},
|
onStdOut: () => { },
|
||||||
onStdErr: () => {},
|
onStdErr: () => { },
|
||||||
onExit: () => {},
|
onExit: () => { },
|
||||||
onStepBegin: () => {},
|
onStepBegin: () => { },
|
||||||
onStepEnd: () => {},
|
onStepEnd: () => { },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +147,7 @@ export class TeleSuiteUpdater {
|
||||||
onError: (error: reporterTypes.TestError) => this._handleOnError(error)
|
onError: (error: reporterTypes.TestError) => this._handleOnError(error)
|
||||||
});
|
});
|
||||||
for (const message of report)
|
for (const message of report)
|
||||||
receiver.dispatch(message);
|
void receiver.dispatch(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
processListReport(report: any[]) {
|
processListReport(report: any[]) {
|
||||||
|
|
@ -144,14 +157,14 @@ export class TeleSuiteUpdater {
|
||||||
this._testResultsSnapshot = new Map(tests.map(test => [test.id, test.results]));
|
this._testResultsSnapshot = new Map(tests.map(test => [test.id, test.results]));
|
||||||
this._receiver.reset();
|
this._receiver.reset();
|
||||||
for (const message of report)
|
for (const message of report)
|
||||||
this._receiver.dispatch(message);
|
void this._receiver.dispatch(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
processTestReportEvent(message: any) {
|
processTestReportEvent(message: any) {
|
||||||
// The order of receiver dispatches matters here, we want to assign `lastRunTestCount`
|
// The order of receiver dispatches matters here, we want to assign `lastRunTestCount`
|
||||||
// before we use it.
|
// before we use it.
|
||||||
this._lastRunReceiver?.dispatch(message)?.catch(() => {});
|
this._lastRunReceiver?.dispatch(message)?.catch(() => { });
|
||||||
this._receiver.dispatch(message)?.catch(() => {});
|
this._receiver.dispatch(message)?.catch(() => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleOnError(error: reporterTypes.TestError) {
|
private _handleOnError(error: reporterTypes.TestError) {
|
||||||
|
|
@ -160,7 +173,7 @@ export class TeleSuiteUpdater {
|
||||||
this._options.onUpdate();
|
this._options.onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
asModel(): TestModel {
|
asModel(): TeleSuiteUpdaterTestModel {
|
||||||
return {
|
return {
|
||||||
rootSuite: this.rootSuite || new TeleSuite('', 'root'),
|
rootSuite: this.rootSuite || new TeleSuite('', 'root'),
|
||||||
config: this.config!,
|
config: this.config!,
|
||||||
|
|
@ -20,7 +20,7 @@ import '@web/third_party/vscode/codicon.css';
|
||||||
import { settings } from '@web/uiUtils';
|
import { settings } from '@web/uiUtils';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './uiModeFiltersView.css';
|
import './uiModeFiltersView.css';
|
||||||
import type { TestModel } from './uiModeModel';
|
import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
|
||||||
|
|
||||||
export const FiltersView: React.FC<{
|
export const FiltersView: React.FC<{
|
||||||
filterText: string;
|
filterText: string;
|
||||||
|
|
@ -29,7 +29,7 @@ export const FiltersView: React.FC<{
|
||||||
setStatusFilters: (filters: Map<string, boolean>) => void;
|
setStatusFilters: (filters: Map<string, boolean>) => void;
|
||||||
projectFilters: Map<string, boolean>;
|
projectFilters: Map<string, boolean>;
|
||||||
setProjectFilters: (filters: Map<string, boolean>) => void;
|
setProjectFilters: (filters: Map<string, boolean>) => void;
|
||||||
testModel: TestModel | undefined,
|
testModel: TeleSuiteUpdaterTestModel | undefined,
|
||||||
runTests: () => void;
|
runTests: () => void;
|
||||||
}> = ({ filterText, setFilterText, statusFilters, setStatusFilters, projectFilters, setProjectFilters, testModel, runTests }) => {
|
}> = ({ filterText, setFilterText, statusFilters, setStatusFilters, projectFilters, setProjectFilters, testModel, runTests }) => {
|
||||||
const [expanded, setExpanded] = React.useState(false);
|
const [expanded, setExpanded] = React.useState(false);
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
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 type * as reporterTypes from 'playwright/types/testReporter';
|
|
||||||
|
|
||||||
export type Progress = {
|
|
||||||
total: number;
|
|
||||||
passed: number;
|
|
||||||
failed: number;
|
|
||||||
skipped: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type TestModel = {
|
|
||||||
config: reporterTypes.FullConfig;
|
|
||||||
rootSuite: reporterTypes.Suite;
|
|
||||||
loadErrors: reporterTypes.TestError[];
|
|
||||||
progress: Progress;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const pathSeparator = navigator.userAgent.toLowerCase().includes('windows') ? '\\' : '/';
|
|
||||||
|
|
@ -27,10 +27,10 @@ import type * as reporterTypes from 'playwright/types/testReporter';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { SourceLocation } from './modelUtil';
|
import type { SourceLocation } from './modelUtil';
|
||||||
import { testStatusIcon } from './testUtils';
|
import { testStatusIcon } from './testUtils';
|
||||||
import type { TestModel } from './uiModeModel';
|
|
||||||
import './uiModeTestListView.css';
|
import './uiModeTestListView.css';
|
||||||
import type { TestServerConnection } from '@testIsomorphic/testServerConnection';
|
import type { TestServerConnection } from '@testIsomorphic/testServerConnection';
|
||||||
import { TagView } from './tag';
|
import { TagView } from './tag';
|
||||||
|
import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
|
||||||
|
|
||||||
const TestTreeView = TreeView<TreeItem>;
|
const TestTreeView = TreeView<TreeItem>;
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ export const TestListView: React.FC<{
|
||||||
filterText: string,
|
filterText: string,
|
||||||
testTree: TestTree,
|
testTree: TestTree,
|
||||||
testServerConnection: TestServerConnection | undefined,
|
testServerConnection: TestServerConnection | undefined,
|
||||||
testModel?: TestModel,
|
testModel?: TeleSuiteUpdaterTestModel,
|
||||||
runTests: (mode: 'bounce-if-busy' | 'queue-if-busy', testIds: Set<string>) => void,
|
runTests: (mode: 'bounce-if-busy' | 'queue-if-busy', testIds: Set<string>) => void,
|
||||||
runningState?: { testIds: Set<string>, itemSelectedByUser?: boolean, completed?: boolean },
|
runningState?: { testIds: Set<string>, itemSelectedByUser?: boolean, completed?: boolean },
|
||||||
watchAll: boolean,
|
watchAll: boolean,
|
||||||
|
|
@ -179,7 +179,7 @@ export const TestListView: React.FC<{
|
||||||
noItemsMessage={isLoading ? 'Loading\u2026' : 'No tests'} />;
|
noItemsMessage={isLoading ? 'Loading\u2026' : 'No tests'} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
function itemLocation(item: TreeItem | undefined, model: TestModel | undefined): SourceLocation | undefined {
|
function itemLocation(item: TreeItem | undefined, model: TeleSuiteUpdaterTestModel | undefined): SourceLocation | undefined {
|
||||||
if (!item || !model)
|
if (!item || !model)
|
||||||
return;
|
return;
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ import '@web/third_party/vscode/codicon.css';
|
||||||
import '@web/common.css';
|
import '@web/common.css';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { TeleSuite } from '@testIsomorphic/teleReceiver';
|
import { TeleSuite } from '@testIsomorphic/teleReceiver';
|
||||||
import { TeleSuiteUpdater } from './teleSuiteUpdater';
|
import { TeleSuiteUpdater, type TeleSuiteUpdaterProgress, type TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
|
||||||
import type { Progress } from './uiModeModel';
|
|
||||||
import type { TeleTestCase } from '@testIsomorphic/teleReceiver';
|
import type { TeleTestCase } from '@testIsomorphic/teleReceiver';
|
||||||
import type * as reporterTypes from 'playwright/types/testReporter';
|
import type * as reporterTypes from 'playwright/types/testReporter';
|
||||||
import { SplitView } from '@web/components/splitView';
|
import { SplitView } from '@web/components/splitView';
|
||||||
|
|
@ -34,13 +33,13 @@ import { clsx, settings, useSetting } from '@web/uiUtils';
|
||||||
import { statusEx, TestTree } from '@testIsomorphic/testTree';
|
import { statusEx, TestTree } from '@testIsomorphic/testTree';
|
||||||
import type { TreeItem } from '@testIsomorphic/testTree';
|
import type { TreeItem } from '@testIsomorphic/testTree';
|
||||||
import { TestServerConnection } from '@testIsomorphic/testServerConnection';
|
import { TestServerConnection } from '@testIsomorphic/testServerConnection';
|
||||||
import { pathSeparator } from './uiModeModel';
|
|
||||||
import type { TestModel } from './uiModeModel';
|
|
||||||
import { FiltersView } from './uiModeFiltersView';
|
import { FiltersView } from './uiModeFiltersView';
|
||||||
import { TestListView } from './uiModeTestListView';
|
import { TestListView } from './uiModeTestListView';
|
||||||
import { TraceView } from './uiModeTraceView';
|
import { TraceView } from './uiModeTraceView';
|
||||||
import { SettingsView } from './settingsView';
|
import { SettingsView } from './settingsView';
|
||||||
|
|
||||||
|
const pathSeparator = navigator.userAgent.toLowerCase().includes('windows') ? '\\' : '/';
|
||||||
|
|
||||||
let xtermSize = { cols: 80, rows: 24 };
|
let xtermSize = { cols: 80, rows: 24 };
|
||||||
const xtermDataSource: XtermDataSource = {
|
const xtermDataSource: XtermDataSource = {
|
||||||
pending: [],
|
pending: [],
|
||||||
|
|
@ -80,8 +79,8 @@ export const UIModeView: React.FC<{}> = ({
|
||||||
['skipped', false],
|
['skipped', false],
|
||||||
]));
|
]));
|
||||||
const [projectFilters, setProjectFilters] = React.useState<Map<string, boolean>>(new Map());
|
const [projectFilters, setProjectFilters] = React.useState<Map<string, boolean>>(new Map());
|
||||||
const [testModel, setTestModel] = React.useState<TestModel>();
|
const [testModel, setTestModel] = React.useState<TeleSuiteUpdaterTestModel>();
|
||||||
const [progress, setProgress] = React.useState<Progress & { total: number } | undefined>();
|
const [progress, setProgress] = React.useState<TeleSuiteUpdaterProgress & { total: number } | undefined>();
|
||||||
const [selectedItem, setSelectedItem] = React.useState<{ treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase }>({});
|
const [selectedItem, setSelectedItem] = React.useState<{ treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase }>({});
|
||||||
const [visibleTestIds, setVisibleTestIds] = React.useState<Set<string>>(new Set());
|
const [visibleTestIds, setVisibleTestIds] = React.useState<Set<string>>(new Set());
|
||||||
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue