chore(ui): move TeleSuiteUpdater into testIsomorphic (#32273)

Preparation for https://github.com/microsoft/playwright/issues/32076.
This commit is contained in:
Simon Knott 2024-08-22 17:29:10 +02:00 committed by GitHub
parent 16e76cb71a
commit 850436c656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 60 deletions

View file

@ -14,11 +14,24 @@
* limitations under the License.
*/
import { TeleReporterReceiver, TeleSuite } from '@testIsomorphic/teleReceiver';
import { statusEx } from '@testIsomorphic/testTree';
import type { ReporterV2 } from 'playwright/src/reporters/reporterV2';
import type * as reporterTypes from 'playwright/types/testReporter';
import type { Progress, TestModel } from './uiModeModel';
import { TeleReporterReceiver, TeleSuite } from './teleReceiver';
import { statusEx } from './testTree';
import type { ReporterV2 } from '../reporters/reporterV2';
import type * as reporterTypes from '../../types/testReporter';
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 = {
onUpdate: (force?: boolean) => void,
@ -30,7 +43,7 @@ export class TeleSuiteUpdater {
rootSuite: TeleSuite | undefined;
config: reporterTypes.FullConfig | undefined;
readonly loadErrors: reporterTypes.TestError[] = [];
readonly progress: Progress = {
readonly progress: TeleSuiteUpdaterProgress = {
total: 0,
passed: 0,
failed: 0,
@ -134,7 +147,7 @@ export class TeleSuiteUpdater {
onError: (error: reporterTypes.TestError) => this._handleOnError(error)
});
for (const message of report)
receiver.dispatch(message);
void receiver.dispatch(message);
}
processListReport(report: any[]) {
@ -144,7 +157,7 @@ export class TeleSuiteUpdater {
this._testResultsSnapshot = new Map(tests.map(test => [test.id, test.results]));
this._receiver.reset();
for (const message of report)
this._receiver.dispatch(message);
void this._receiver.dispatch(message);
}
processTestReportEvent(message: any) {
@ -160,7 +173,7 @@ export class TeleSuiteUpdater {
this._options.onUpdate();
}
asModel(): TestModel {
asModel(): TeleSuiteUpdaterTestModel {
return {
rootSuite: this.rootSuite || new TeleSuite('', 'root'),
config: this.config!,

View file

@ -20,7 +20,7 @@ import '@web/third_party/vscode/codicon.css';
import { settings } from '@web/uiUtils';
import React from 'react';
import './uiModeFiltersView.css';
import type { TestModel } from './uiModeModel';
import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
export const FiltersView: React.FC<{
filterText: string;
@ -29,7 +29,7 @@ export const FiltersView: React.FC<{
setStatusFilters: (filters: Map<string, boolean>) => void;
projectFilters: Map<string, boolean>;
setProjectFilters: (filters: Map<string, boolean>) => void;
testModel: TestModel | undefined,
testModel: TeleSuiteUpdaterTestModel | undefined,
runTests: () => void;
}> = ({ filterText, setFilterText, statusFilters, setStatusFilters, projectFilters, setProjectFilters, testModel, runTests }) => {
const [expanded, setExpanded] = React.useState(false);

View file

@ -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') ? '\\' : '/';

View file

@ -27,10 +27,10 @@ import type * as reporterTypes from 'playwright/types/testReporter';
import React from 'react';
import type { SourceLocation } from './modelUtil';
import { testStatusIcon } from './testUtils';
import type { TestModel } from './uiModeModel';
import './uiModeTestListView.css';
import type { TestServerConnection } from '@testIsomorphic/testServerConnection';
import { TagView } from './tag';
import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
const TestTreeView = TreeView<TreeItem>;
@ -38,7 +38,7 @@ export const TestListView: React.FC<{
filterText: string,
testTree: TestTree,
testServerConnection: TestServerConnection | undefined,
testModel?: TestModel,
testModel?: TeleSuiteUpdaterTestModel,
runTests: (mode: 'bounce-if-busy' | 'queue-if-busy', testIds: Set<string>) => void,
runningState?: { testIds: Set<string>, itemSelectedByUser?: boolean, completed?: boolean },
watchAll: boolean,
@ -179,7 +179,7 @@ export const TestListView: React.FC<{
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)
return;
return {

View file

@ -18,8 +18,7 @@ import '@web/third_party/vscode/codicon.css';
import '@web/common.css';
import React from 'react';
import { TeleSuite } from '@testIsomorphic/teleReceiver';
import { TeleSuiteUpdater } from './teleSuiteUpdater';
import type { Progress } from './uiModeModel';
import { TeleSuiteUpdater, type TeleSuiteUpdaterProgress, type TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater';
import type { TeleTestCase } from '@testIsomorphic/teleReceiver';
import type * as reporterTypes from 'playwright/types/testReporter';
import { SplitView } from '@web/components/splitView';
@ -34,13 +33,13 @@ import { clsx, settings, useSetting } from '@web/uiUtils';
import { statusEx, TestTree } from '@testIsomorphic/testTree';
import type { TreeItem } from '@testIsomorphic/testTree';
import { TestServerConnection } from '@testIsomorphic/testServerConnection';
import { pathSeparator } from './uiModeModel';
import type { TestModel } from './uiModeModel';
import { FiltersView } from './uiModeFiltersView';
import { TestListView } from './uiModeTestListView';
import { TraceView } from './uiModeTraceView';
import { SettingsView } from './settingsView';
const pathSeparator = navigator.userAgent.toLowerCase().includes('windows') ? '\\' : '/';
let xtermSize = { cols: 80, rows: 24 };
const xtermDataSource: XtermDataSource = {
pending: [],
@ -80,8 +79,8 @@ export const UIModeView: React.FC<{}> = ({
['skipped', false],
]));
const [projectFilters, setProjectFilters] = React.useState<Map<string, boolean>>(new Map());
const [testModel, setTestModel] = React.useState<TestModel>();
const [progress, setProgress] = React.useState<Progress & { total: number } | undefined>();
const [testModel, setTestModel] = React.useState<TeleSuiteUpdaterTestModel>();
const [progress, setProgress] = React.useState<TeleSuiteUpdaterProgress & { total: number } | undefined>();
const [selectedItem, setSelectedItem] = React.useState<{ treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase }>({});
const [visibleTestIds, setVisibleTestIds] = React.useState<Set<string>>(new Set());
const [isLoading, setIsLoading] = React.useState<boolean>(false);