diff --git a/other/hbuilderx-autotest/common/_helper.d.ts b/other/hbuilderx-autotest/common/_helper.d.ts new file mode 100644 index 0000000..d024f82 --- /dev/null +++ b/other/hbuilderx-autotest/common/_helper.d.ts @@ -0,0 +1,25 @@ +/** + * @description 获取HBuilderX数据目录 + * @returns + */ +export declare const hxAppDataDir: () => string; +/** + * @description 获取HBuilderX .log文件路径 + * @returns + */ +export declare const getHXLogFile: () => string; +/** + * @description 获取HBuilderX autosaves文件路径 + * @returns + */ +export declare const clearHXAutosavesPath: () => Promise; +/** + * @description 清空HBuilderX数据目录.log文件 + */ +export declare const clearHXLogFile: () => void; +/** + * @description 格式化【测试用例文件】字符串 + * @param openfile + * @returns + */ +export declare const format_str_case_file: (openfile: string) => string; diff --git a/other/hbuilderx-autotest/common/context.d.ts b/other/hbuilderx-autotest/common/context.d.ts new file mode 100644 index 0000000..27cc384 --- /dev/null +++ b/other/hbuilderx-autotest/common/context.d.ts @@ -0,0 +1,2 @@ +export declare const setContext: (c: Record) => void; +export declare const getContext: () => Record; diff --git a/other/hbuilderx-autotest/common/execa.d.ts b/other/hbuilderx-autotest/common/execa.d.ts new file mode 100644 index 0000000..c44e5be --- /dev/null +++ b/other/hbuilderx-autotest/common/execa.d.ts @@ -0,0 +1,2 @@ +export declare function installProjectModule(projectDir: string): Promise; +export declare function runScript(projectDir: string, scriptName: string): Promise; diff --git a/other/hbuilderx-autotest/common/git.d.ts b/other/hbuilderx-autotest/common/git.d.ts new file mode 100644 index 0000000..b88e8dd --- /dev/null +++ b/other/hbuilderx-autotest/common/git.d.ts @@ -0,0 +1,18 @@ +import { SimpleGit } from 'simple-git'; +export default class Git { + private options; + private localDir; + private url; + private gitExample; + constructor(localDir: string, url: string); + get git(): SimpleGit; + clone(): Promise; + status(): Promise; + clean(): Promise; + reset(): Promise; + checkout(branch?: string): Promise; + pull(): Promise; + fetch(): Promise; + resetCodeToLatestByBranch(branch?: string): Promise; + checkIfRepoHasUpdates(): Promise; +} diff --git a/other/hbuilderx-autotest/common/utils.d.ts b/other/hbuilderx-autotest/common/utils.d.ts new file mode 100644 index 0000000..9c4afe5 --- /dev/null +++ b/other/hbuilderx-autotest/common/utils.d.ts @@ -0,0 +1,9 @@ +export declare function getLocalIP(): string; +export declare function purgeCache(moduleName: string): any; +export declare const getInitTestFile: (fileOrProjectKey: string) => string; +export declare const sleep: (time?: number) => Promise; +export declare const getTmpdir: (time?: number) => string; +export declare const isWin: () => boolean; +export declare const getPlatform: () => string; +export declare const generateCode: (file: any, recordOpt: any) => string; +export declare const requireFunc: any; diff --git a/other/hbuilderx-autotest/config.d.ts b/other/hbuilderx-autotest/config.d.ts new file mode 100644 index 0000000..ec685ff --- /dev/null +++ b/other/hbuilderx-autotest/config.d.ts @@ -0,0 +1,17 @@ +import * as convict from 'convict'; +declare const config: convict.Config<{ + dev: string; + alpha: string; + release: string; + testsStorage: string; + lsTestsStorage: string; + lsTestReportDir: string; + hxMarketPLuginDir: string; + mountSmbfs: string; + tagrelease: string; + tagdev: string; + tagalpha: string; + autoUpdate: boolean; + mainStorage: string; +}>; +export default config; diff --git a/other/hbuilderx-autotest/core/Assert.d.ts b/other/hbuilderx-autotest/core/Assert.d.ts new file mode 100644 index 0000000..d2b48c8 --- /dev/null +++ b/other/hbuilderx-autotest/core/Assert.d.ts @@ -0,0 +1,14 @@ +export default class Assert { + private res; + private file; + constructor(file: string); + expectArrayIncludes(casename: string, targetArray: string[], includeArray: string[]): void; + expectEquals(casename: string, target: any, expect: any): void; + expectMatches(casename: string, target: string, expect: RegExp): void; + expectTrue(casename: string, value: boolean, context?: any): void; + get result(): { + count: number; + caseFail: any[]; + cassAll: any[]; + }; +} diff --git a/other/hbuilderx-autotest/core/applicationActive.d.ts b/other/hbuilderx-autotest/core/applicationActive.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/other/hbuilderx-autotest/core/applicationActive.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/other/hbuilderx-autotest/core/autotest.d.ts b/other/hbuilderx-autotest/core/autotest.d.ts new file mode 100644 index 0000000..11d425a --- /dev/null +++ b/other/hbuilderx-autotest/core/autotest.d.ts @@ -0,0 +1,176 @@ +import { Position, Range } from 'vscode-languageserver'; +import { Editor, TextDocument } from './editor'; +export interface AutoTestCase { + kind: string; + title: string; + tag?: string; + expect: T; + error?: { + message: string; + cause: string; + }; +} +export interface KeybindingExpect { + /** + * apply之后对应的函内容匹配 + */ + lines: string[] | RegExp[]; + /** + * apply之后对应的光标位置 + */ + cursor?: Position; +} +export interface AutoTestKeybindCase extends AutoTestCase { + kind: 'keybind'; + range: Range; + input: string; + typeInNewLine?: boolean; + keybind: string; +} +export interface AutoTestCheckEditorCase extends AutoTestCase { + kind: 'checkEditor'; +} +export interface AutoEditExpect { + /** + * apply之后对应的函内容匹配 + */ + lines: string[] | RegExp[]; + /** + * apply之后对应的光标位置 + */ + cursor?: Position; +} +export interface AutoTestAutoEditCase extends AutoTestCase { + kind: 'autoedit'; + range: Range; + typeInNewLine?: boolean; + input: string; +} +export interface DefinitionExpect { + uri: string; + line: string | RegExp; + cursor?: number; +} +export interface AutoTestDefinitionCase extends AutoTestCase { + kind: 'definition'; + range: Range; +} +export interface HoverExpect { + /** + * hover的内容 + */ + content: string | RegExp; + /** + * 是否支持F1打开帮助文档 + */ + supportF1?: boolean; +} +export interface AutoTestHoverCase extends AutoTestCase { + kind: 'hover' | 'noerror' | 'error'; + range: Range; + docOffsetAt: number; + type: 'string'; +} +export interface OutlineExpect { + filePath: string; +} +export interface AutoTestOutlineCase extends AutoTestCase { + kind: 'outline'; + needCreate?: boolean; + project: string; + lsDir: string; + programData: string; + programPlugin: string; +} +export interface ReferencesExpect { + filePath: string; +} +export interface AutoTestReferencesCase extends AutoTestCase { + kind: 'references'; + needCreate?: boolean; + range: Range; + docOffsetAt: number; + project: string; + lsDir: string; + programData: string; + programPlugin: string; +} +export interface ErrorExpect { + content: string | RegExp; +} +export interface CompletionExpect { + /** + * 代码助手列表项 + */ + items: string[]; + /** + * 代码助手列表项-不能包含项 + */ + excludeItems: string[]; + /** + * apply之后对应的函内容匹配 + */ + lines: string[] | RegExp[]; + /** + * apply之后对应的光标位置 + */ + cursor?: Position; + /** + * apply的item的详细信息 + */ + detail?: string | RegExp; +} +export interface AutoTestCompletionCase extends AutoTestCase { + kind: 'completion' | 'init'; + /** + * 是否在新的一行写,如为true,则会在range位置回车后开始写 + */ + typeInNewLine?: boolean; + /** + * 要输入的位置 + */ + range: Range; + /** + * 要输入的文字 + */ + input: string; + /** + * 选择哪一项,默认是第一项。下标从`0`开始 + */ + applyIndex?: number; +} +export interface AutoTestDbClickCase extends AutoTestCase { + kind: 'dbclick'; + range: Range; +} +export interface DbClickExpect { + begin: string; + end: string; + match: string; +} +export interface PerformanceExpect { + expect: AutoTestDefinitionCase | AutoTestHoverCase | AutoTestCompletionCase; +} +export interface AutoTestPerformanceCase extends AutoTestCase { + kind: 'performance'; + type: string; + num: number; + timer: number; + range: Range; +} +interface TestCaseResult { + casename: string; + passed: boolean; + message?: string; + filePath?: string; +} +export declare function getTestMergedResults(testResults: TestCaseResult[], project_name: string, autotestOptions: any): unknown[]; +export declare function generateTestReport(testResults: TestCaseResult[], testBaseInfo: any, allCase: number): any; +export declare function matchTestcaseContent(line: string): string | undefined; +export declare function scan(doc: TextDocument, project: string, config: any, range?: { + startLine: number; + endLine: number; +}): AutoTestCase[][]; +export declare function runCaseItem(testcase: AutoTestCase, editor: Editor, config?: any): Promise; +export declare function runcase(testcase: AutoTestCase, editor: Editor, config?: any): Promise; +export {}; diff --git a/other/hbuilderx-autotest/core/caseHandler.d.ts b/other/hbuilderx-autotest/core/caseHandler.d.ts new file mode 100644 index 0000000..de5f744 --- /dev/null +++ b/other/hbuilderx-autotest/core/caseHandler.d.ts @@ -0,0 +1,45 @@ +import { AutoTestCheckEditorCase, AutoTestCompletionCase, AutoTestDbClickCase, AutoTestDefinitionCase, AutoTestHoverCase, AutoTestKeybindCase, AutoTestOutlineCase, AutoTestPerformanceCase, AutoTestReferencesCase } from './autotest'; +import { Editor } from './editor'; +declare function runDbClickCase(test: AutoTestDbClickCase, editor: Editor): Promise<({ + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +})[]>; +declare function runCompletionCase(test: AutoTestCompletionCase, editor: Editor, config?: any): Promise; +declare function runKeybindCase(test: AutoTestKeybindCase, editor: Editor): Promise; +declare function runDefinitionCase(test: AutoTestDefinitionCase, editor: Editor): Promise<({ + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +})[]>; +declare function runHoverCase(test: AutoTestHoverCase, editor: Editor): Promise; +declare function runNoErrorCase(test: AutoTestHoverCase, editor: Editor): Promise; +declare function runCheckEditor(test: AutoTestCheckEditorCase, editor: Editor): Promise; +declare function runErrorCase(test: AutoTestHoverCase, editor: Editor): Promise; +declare function runPerformanceCase(test: AutoTestPerformanceCase, editor: Editor): Promise<({ + casename: string; + passed: boolean; + timer: any; + message: string; +} | { + casename: string; + timer: any; + passed: boolean; + message?: undefined; +} | { + casename: string; + passed: boolean; + message: string; + timer?: undefined; +})[]>; +declare function runOutlineCase(test: AutoTestOutlineCase, editor: Editor): Promise; +declare function runReferencesCase(test: AutoTestReferencesCase, editor: Editor): Promise; +export { runCheckEditor, runCompletionCase, runDbClickCase, runDefinitionCase, runErrorCase, runHoverCase, runKeybindCase, runNoErrorCase, runOutlineCase, runPerformanceCase, runReferencesCase }; diff --git a/other/hbuilderx-autotest/core/caseHandler/outline.d.ts b/other/hbuilderx-autotest/core/caseHandler/outline.d.ts new file mode 100644 index 0000000..fb9cc69 --- /dev/null +++ b/other/hbuilderx-autotest/core/caseHandler/outline.d.ts @@ -0,0 +1,27 @@ +import { AutoTestOutlineCase } from '../autotest'; +import { Editor } from '../editor'; +import { HBuilderX } from '../hxdriver'; +import { TreeItem, TreeItemInfo } from '../treeItem'; +declare class Outline { + readonly hx: HBuilderX; + protected treeItem: TreeItem; + constructor(hx: HBuilderX); + private getFilePath; + /** + * 获取大纲文件数据 + */ + getFileOutlineData(jsonFilePath: string, needCreate: boolean): TreeItemInfo | undefined; + /** + * 对比结果 + */ + comparativeData(mainData: TreeItemInfo, targetData: TreeItemInfo, title: string, result: any[]): Promise; + /** + * 处理点击跳转 + */ + doTreeItemJump(test: AutoTestOutlineCase, jsonData: TreeItemInfo, filePath: string, title: string, result: any[]): Promise; + /** + * 执行大纲测试用例 + */ + runOutlineCase(test: AutoTestOutlineCase, editor: Editor): Promise; +} +export { Outline }; diff --git a/other/hbuilderx-autotest/core/caseHandler/references.d.ts b/other/hbuilderx-autotest/core/caseHandler/references.d.ts new file mode 100644 index 0000000..d1c4bf9 --- /dev/null +++ b/other/hbuilderx-autotest/core/caseHandler/references.d.ts @@ -0,0 +1,30 @@ +import { AutoTestReferencesCase } from '../autotest'; +import { Editor } from '../editor'; +import { HBuilderX } from '../hxdriver'; +import { TreeItem, TreeItemInfo } from '../treeItem'; +declare class References { + readonly hx: HBuilderX; + protected treeItem: TreeItem; + constructor(hx: HBuilderX); + private getFilePath; + /** + * 获取文件数据 + */ + getFileReferencesData(jsonFilePath: string, needCreate: boolean): TreeItemInfo | undefined; + /** + * 对比结果 + */ + comparativeData(mainData: TreeItemInfo, targetData: TreeItemInfo, title: string, result: any[]): Promise; + /** + * 处理点击跳转 + */ + doTreeItemJump(test: AutoTestReferencesCase, jsonData: TreeItemInfo, filePath: string, title: string, result: any[]): Promise; + /** + * 执行查找引用测试用例 + * @param test + * @param editor + * @returns + */ + runReferencesCase(test: AutoTestReferencesCase, editor: Editor): Promise; +} +export { References }; diff --git a/other/hbuilderx-autotest/core/editor.d.ts b/other/hbuilderx-autotest/core/editor.d.ts new file mode 100644 index 0000000..6610adc --- /dev/null +++ b/other/hbuilderx-autotest/core/editor.d.ts @@ -0,0 +1,62 @@ +import { CompletionList, Range } from 'vscode-languageserver'; +import { TextDocument as FullTextDocument } from 'vscode-languageserver-textdocument'; +import { HBuilderX } from './hxdriver'; +import { TreeItemInfo } from './treeItem'; +export interface TextDocumentLine { + text: string; + range: Range; + lineNumber: number; +} +export interface DefinitionResult { + uri: string; + range: Range; + editor: Editor; +} +export interface TextDocument extends FullTextDocument { + lineAt(line: number): TextDocumentLine; + getText(range?: Range): string; + dirty: boolean; + indicators: any[]; + lineCount: number; +} +export declare function createTextDocument(fileUri: string, contents: string, languageId: string): TextDocument; +export declare class Editor { + readonly hx: HBuilderX; + readonly selector: string; + readonly fileUri: string; + readonly explorerFile?: string | undefined; + private _document; + constructor(hx: HBuilderX, selector: string, fileUri: string, explorerFile?: string | undefined); + syncDocument(): Promise; + get document(): TextDocument | undefined; + selections(): Promise; + newLine(lineNum: number): Promise; + completions(input: string, range?: Range, retryCount?: number): Promise; + setSelections(range: Range): Promise; + getTsServerError(): Promise; + resolveCompletionDetail(index: number): Promise; + applyCompletion(index: number): Promise; + functionSignatures(range: Range): Promise; + hxSleep(ms: number): Promise; + hover(range: Range): Promise; + grammarRrror(range: Range): Promise; + gotoDefinition(range: Range): Promise; + /** + * 触发大纲, 获取大纲结果 + */ + outline(): Promise; + closeOutline(): Promise; + /** + * 获取查找引用结果 + * @param range + * @returns + */ + findReferences(range: Range): Promise; + focusProjectManager(): Promise; + close(): Promise; + reset(): Promise; + open(): Promise; + getIndicators(type: string): Promise; + checkIndicators(): Promise; + checkDocumentSync(): Promise<{} | undefined>; +} diff --git a/other/hbuilderx-autotest/core/expect.d.ts b/other/hbuilderx-autotest/core/expect.d.ts new file mode 100644 index 0000000..e6e4a0a --- /dev/null +++ b/other/hbuilderx-autotest/core/expect.d.ts @@ -0,0 +1,48 @@ +declare function expectArrayIncludes(casename: string, targetArray: string[], includeArray: string[]): { + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +}; +declare function expectArrayExcludes(casename: string, targetArray: string[], excludeArray: string[]): { + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +}; +declare function expectEquals(casename: string, target: any, expect: any): { + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +}; +declare function expectMatches(casename: string, target: string, expect: RegExp): { + casename: string; + passed: boolean; + message: string; +} | { + casename: string; + passed: boolean; + message?: undefined; +}; +declare function expectTrue(casename: string, value: boolean, context?: any): { + casename: string; + passed: boolean; + message: string; + context: any; +} | { + casename: string; + passed: boolean; + context: any; + message?: undefined; +}; +export { expectArrayExcludes, expectArrayIncludes, expectEquals, expectMatches, expectTrue }; diff --git a/other/hbuilderx-autotest/core/fakeDriver.d.ts b/other/hbuilderx-autotest/core/fakeDriver.d.ts new file mode 100644 index 0000000..46c363b --- /dev/null +++ b/other/hbuilderx-autotest/core/fakeDriver.d.ts @@ -0,0 +1,5 @@ +declare var appArgs: string[]; +declare var args: any; +declare var pipeName: any; +declare var hostPid: any; +declare var processId: number; diff --git a/other/hbuilderx-autotest/core/hxdriver.d.ts b/other/hbuilderx-autotest/core/hxdriver.d.ts new file mode 100644 index 0000000..6b005c5 --- /dev/null +++ b/other/hbuilderx-autotest/core/hxdriver.d.ts @@ -0,0 +1,102 @@ +export interface IElement { + className: string; + objectName?: string; + textContent?: string; + hasFocus?: boolean; + rect: { + left: number; + top: number; + width: number; + height: number; + }; + attributes: { + [name: string]: any; + }; + hasChildren: boolean; +} +interface SelectorItem { + objectName: string; + className: string; + sub_control: string; + properties: Record; + pseudos: any[]; +} +interface HBuilderOption { + program: string; + args: string[]; + env?: any; +} +/** + * 轮询 + * @param fn 核心处理逻辑 + * @param acceptFn 判断是否接受结果 + * @param timeoutMessage 超时消息 + * @param retryCount 重试次数 + * @param retryInterval 重试间隔 + * @returns + */ +export declare function poll(fn: () => Promise, acceptFn: (result: T) => boolean, timeoutMessage: string, retryCount: number, retryInterval?: number): Promise; +export declare function parseSelector(selector: string): SelectorItem[]; +export declare class HBuilderX { + readonly option: HBuilderOption; + private connection; + private programHandle; + private program; + private fakeDriver; + private peocess; + applicationActive: boolean; + constructor(option: HBuilderOption); + getProgram(): string; + getEnv(): any; + private checkConnection; + executeCommand(command: string, commandArgs?: any): Promise; + request(key: string, params: Record): Promise; + waitForClose(): Promise; + delay(delay: number, fn?: () => Promise): Promise; + hxClose(): void; + hxClosed(): boolean; + waitForStartAndConnect(): Promise; + getWindowsIds(): Promise; + getActiveWindowId(): Promise; + capturePage(output: string, selector: string, windowId?: number): Promise; + dispatchKeybinding(keybinding: string, selector?: string, windowId?: number, useCommandOnWindows?: boolean): Promise; + /** + * xy不传,默认是选中控件的中心 + */ + waitAndClick(selector: string, xy?: { + x: number; + y: number; + }, tryCount?: number): Promise; + /** + * xy不传,默认是选中控件的中心 + */ + waitAndDbClick(selector: string, xy?: { + x: number; + y: number; + }): Promise; + /** + * xy不传,默认是选中控件的中心 + */ + waitAndRightClick(selector: string, xy?: { + x: number; + y: number; + }, keyModifier?: string): Promise; + waitForMouseMove(selector: string, xy: { + x: number; + y: number; + }): Promise; + waitForTypeInElement(selector: string, input: string): Promise; + waitForTextContent(selector: string, acceptFn?: (text: string) => boolean, tryCount?: number): Promise; + waitForActiveElement(selector: string, tryCount?: number): Promise; + waitForElements(selector: string, tryCount?: number): Promise; + waitForElement(selector: string, tryCount?: number): Promise; + waitForElementsWithAttrs(selector: string, containAttributes?: string[], tryCount?: number): Promise; + waitForElementWithAttrs(selector: string, containAttributes?: string[], tryCount?: number): Promise; + waitForSetValue(selector: string, property: string, value: any): Promise; + waitForGetValue(selector: string, property: string, tryCount?: number): Promise; + startRecording(path?: string, detail?: boolean): Promise; + stopRecording(): Promise; + importPlugins(name: string): Promise; + withRestart(call: Function): Promise; +} +export {}; diff --git a/other/hbuilderx-autotest/core/index.d.ts b/other/hbuilderx-autotest/core/index.d.ts new file mode 100644 index 0000000..e0b5f1c --- /dev/null +++ b/other/hbuilderx-autotest/core/index.d.ts @@ -0,0 +1,9 @@ +export interface IAfter { + appRoot: string; + appData: string; +} +export interface IBefore { + appRoot: string; + appData: string; +} +export type IConfig = IAfter | IBefore; diff --git a/other/hbuilderx-autotest/core/keybinding.d.ts b/other/hbuilderx-autotest/core/keybinding.d.ts new file mode 100644 index 0000000..3b4a1eb --- /dev/null +++ b/other/hbuilderx-autotest/core/keybinding.d.ts @@ -0,0 +1,30 @@ +/** + * insertLineAfter + * closeActiveEditor + */ +interface KeyBindings { + insertLineAfter: string; + gotoDefinition: string; + closeActiveEditor: string; + showPubMenu: string; + closeAllEditor: string; + undo: string; + copy: string; + cut: string; + paste: string; + save: string; + run: string; + delLine: string; + selectAll: string; + clipBoardHistory: string; + newUnTitledEditor: string; + 'editor.action.triggerSuggest': string; + enter: string; + down: string; + esc: string; + openAndCloseOutline: string; + findReferences: string; + focusProjectManager: string; +} +declare let keyBindings: KeyBindings; +export { keyBindings }; diff --git a/other/hbuilderx-autotest/core/selectors.d.ts b/other/hbuilderx-autotest/core/selectors.d.ts new file mode 100644 index 0000000..575e11f --- /dev/null +++ b/other/hbuilderx-autotest/core/selectors.d.ts @@ -0,0 +1,25 @@ +export declare const SELECTORS: { + Window: string; + StatusBarMessage: string; + TsServerErrorIgnore: string; + TsServerErrorEdit: string; + StatusBarItem0Message: string; + editor(fileName: string): string; + jqlEditor(fileName: string): string; + editorTab(fileName: string): string; + activeEditorTab: string; + activeEditor(fileName: string): string; + treeFile(fileName: string): string; + /** + * 获取大纲选择器 + * @param outlinePath 大纲路径 + * @returns + */ + outline(outlinePath: string): string; + findReferences(referencesPath: string): string; + Completions: string; + CompletionDetail: string; + Hover: string; + Signatures: string; + MessageService: string; +}; diff --git a/other/hbuilderx-autotest/core/test.d.ts b/other/hbuilderx-autotest/core/test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/other/hbuilderx-autotest/core/test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/other/hbuilderx-autotest/core/treeItem.d.ts b/other/hbuilderx-autotest/core/treeItem.d.ts new file mode 100644 index 0000000..b1ac4a7 --- /dev/null +++ b/other/hbuilderx-autotest/core/treeItem.d.ts @@ -0,0 +1,151 @@ +import { Range } from 'vscode-languageserver'; +import { Editor } from './editor'; +import { HBuilderX } from './hxdriver'; +/** + * 树形图控件错误信息 + * @param caseName 用例名称 + * @param value 值 + * @param context 上下文 + */ +interface TreeItemError { + caseName: string; + value: boolean; + context?: any; +} +/** + * 树形图跳转相关位置信息 + * @param enable 是否启用 + * @param filePath 文件路径 + * @param ranges 位置信息 + * @param activeEditor 激活编辑器 + */ +interface TreeItemJumpInfo { + enable: boolean; + filePath?: string; + ranges: Range[]; + activeEditor?: Editor; + errorList?: TreeItemError[]; +} +/** + * 树形图控件信息 + * @param child 子节点 + * @param text 文本 + * @param convertedPath 转换后的树形控件路径, 跳转使用 + * @param kind 类型 + * @param checkClick 检查点击 + */ +interface TreeItemInfo { + child?: TreeItemInfo[]; + text?: string; + convertedPath?: string; + kind?: string; + checkClick?: TreeItemJumpInfo; +} +/** + * 解析目标路径信息 + * @param projectPath 项目路径 + * @param lsDir lsDir路径 + * @param programData programData路径 + * @param programPlugin programPlugin路径 + */ +interface ParseTargetPathInfo { + projectPath: string; + lsDir: string; + programData: string; + programPlugin: string; +} +/** + * 树形图控件类型 + */ +declare enum TreeItemKind { + Outline = "outline", + References = "references" +} +/** + * 树形图控件基类 + */ +declare class TreeItem { + readonly hx: HBuilderX; + readonly kind: TreeItemKind; + constructor(hx: HBuilderX, kind: TreeItemKind); + /** + * 生成错误数据 + * @param caseName + * @param context + * @returns + */ + private createErrorData; + /** + * 获取对应的树形控件选择器 + * @param treePath + * @param isClick + * @returns + */ + private getSelector; + /** + * 树节点获取数据时, 会在最外层包裹`""` + * 此处将文本本身的`"`转义为`\"` + */ + private treeNodeEscape; + /** + * 遍历树节点, 获取对应的json数据 + */ + getTreeItemData(parentPath: string, treeText: string, hasChildren: boolean, tryCount: number): Promise; + /** + * 对比两个item数据 + * @param mainData + * @param targetData + * @param caseName + * @param rootPath + * @returns + */ + private comparativeItemData; + /** + * 对比treeItem数据 + */ + comparativeTreeItemData(mainData: TreeItemInfo, targetData: TreeItemInfo, title: string, rootPath: string, result: TreeItemError[]): Promise; + /** + * 获取当前激活编辑器的信息 + * @returns + */ + private getActiveEditorSelectInfo; + /** + * 点击树形图控件 + * @param jsonData + * @returns + */ + private clickTreeItem; + /** + * 点击树形图控件, 跳转到对应的位置, 并获取位置信息 + */ + private getTreeItemRangeInfo; + /** + * 对比两个位置 + */ + private comparativeTreeItemOffset; + /** + * 解析目标路径 + * @param parseInfo + * @param filePath + * @returns + */ + private parseTargetPath; + /** + * 点击跳转并对比结果 + * @param jsonData 树形图数据 + * @param parseInfo 解析目标路径信息 + * @param filePath 文件路径 + * @param title 标题 + * @param result 结果 + */ + comparativeTreeItemJump(jsonData: TreeItemInfo, parseInfo: ParseTargetPathInfo, filePath: string, title: string, isEnd: boolean, result: TreeItemError[]): Promise; + /** + * 生成断言数据 + */ + createExpect(errorList: TreeItemError[]): any[]; + /** + * 给json数据添加range + */ + addRangToJson(data: TreeItemInfo, onlyValue?: boolean): void; +} +export { ParseTargetPathInfo, TreeItem, TreeItemError, TreeItemInfo, TreeItemKind }; diff --git a/other/hbuilderx-autotest/core/update.d.ts b/other/hbuilderx-autotest/core/update.d.ts new file mode 100644 index 0000000..24c31fb --- /dev/null +++ b/other/hbuilderx-autotest/core/update.d.ts @@ -0,0 +1,18 @@ +/** + * 处理升级 + */ +import * as driver from './hxdriver'; +declare class Update { + private version; + constructor(version: string); + /** + * 强制结束所有具有指定名称的进程 + * @param processName 要结束的进程的名称 + * @returns 返回终止的进程数 + */ + killAllProcessesByName(processName: string): number; + restartAndClose(hx: driver.HBuilderX): Promise; + update(hx: driver.HBuilderX, forceUpdates?: boolean): Promise; + checkAutoUpdate(hx: driver.HBuilderX, delay?: number): Promise; +} +export { Update }; diff --git a/other/hbuilderx-autotest/core/utils.d.ts b/other/hbuilderx-autotest/core/utils.d.ts new file mode 100644 index 0000000..3222b7b --- /dev/null +++ b/other/hbuilderx-autotest/core/utils.d.ts @@ -0,0 +1,45 @@ +import * as autotest from './autotest'; +export declare const extServer: import("axios").AxiosInstance; +export declare function closeHBuilderX(cmd: string): Promise; +export declare function getProjectTestFiles(autotestOptions: any, getProjectList: any): string[]; +export declare const average: (arr: number[]) => number; +export declare const performanceCompute: any; +export declare function fileCase(project: string, openfile: string, workbench: any, config: any, opt?: any): Promise<{ + count: number; + caseFail: any[]; + cassAll: any[]; +} | { + error: unknown; + count?: undefined; + openfile?: undefined; + documentSyncAttr?: undefined; + caseFail?: undefined; + cassAll?: undefined; + allTextCases?: undefined; + runFaliTime?: undefined; + runSuccessTime?: undefined; + runFailCase?: undefined; + runSuccessCase?: undefined; +} | { + count: number; + openfile: string; + documentSyncAttr: any; + caseFail: any[]; + cassAll: any[]; + allTextCases: autotest.AutoTestCase[]; + runFaliTime: number; + runSuccessTime: number; + runFailCase: number; + runSuccessCase: number; + error?: undefined; +}>; +export declare function traverseDirectory(dir: string, includes?: string[], needSort?: boolean): string[]; +export declare function moveItemToFront(arr: string[], key: string): string[]; +export declare const directoryList: (dirPath: string) => string[]; +/** + * 解析测试用例的期望路径 + * @param expectUri + * @returns + */ +export declare function parseExpectUri(expectUri: string, project: string, lsDir: string, programData: string, programPlugin: string): string; +export declare function normalizedPath(filePath: string): string; diff --git a/other/hbuilderx-autotest/core/workbench.d.ts b/other/hbuilderx-autotest/core/workbench.d.ts new file mode 100644 index 0000000..e37459d --- /dev/null +++ b/other/hbuilderx-autotest/core/workbench.d.ts @@ -0,0 +1,67 @@ +import Git from '../common/git'; +import { Editor, createTextDocument } from './editor'; +import { expectArrayIncludes, expectEquals, expectMatches, expectTrue } from './expect'; +import type { HBuilderX } from './hxdriver'; +import { TreeItem, TreeItemKind } from './treeItem'; +export declare class Workbench { + readonly hx: HBuilderX; + constructor(hx: HBuilderX); + openProject(project: string): Promise; + importProject(project: string): Promise; + installExtensionFromLocal(path: string): Promise; + getActiveEditor(file?: string): Promise; + openEditor(file: string, project?: string): Promise; + getTreeItemHandler(treeItemKind?: TreeItemKind): Promise; + utils: { + expectArrayIncludes: typeof expectArrayIncludes; + expectEquals: typeof expectEquals; + expectMatches: typeof expectMatches; + expectTrue: typeof expectTrue; + Git: typeof Git; + }; + createTextDocument: typeof createTextDocument; + SELECTORS: { + Window: string; + StatusBarMessage: string; + TsServerErrorIgnore: string; + TsServerErrorEdit: string; + StatusBarItem0Message: string; + editor(fileName: string): string; + jqlEditor(fileName: string): string; + editorTab(fileName: string): string; + activeEditorTab: string; + activeEditor(fileName: string): string; + treeFile(fileName: string): string; + outline(outlinePath: string): string; + findReferences(referencesPath: string): string; + Completions: string; + CompletionDetail: string; + Hover: string; + Signatures: string; + MessageService: string; + }; + keyBindings: { + insertLineAfter: string; + gotoDefinition: string; + closeActiveEditor: string; + showPubMenu: string; + closeAllEditor: string; + undo: string; + copy: string; + cut: string; + paste: string; + save: string; + run: string; + delLine: string; + selectAll: string; + clipBoardHistory: string; + newUnTitledEditor: string; + 'editor.action.triggerSuggest': string; + enter: string; + down: string; + esc: string; + openAndCloseOutline: string; + findReferences: string; + focusProjectManager: string; + }; +} diff --git a/other/hbuilderx-autotest/extension/assist.d.ts b/other/hbuilderx-autotest/extension/assist.d.ts new file mode 100644 index 0000000..0f511d5 --- /dev/null +++ b/other/hbuilderx-autotest/extension/assist.d.ts @@ -0,0 +1,3 @@ +import * as driver from '../core/hxdriver'; +export declare const openhx: (config: any) => driver.HBuilderX; +export declare const run: ({ program, file, openFile }: any) => Promise; diff --git a/other/hbuilderx-autotest/extension/common.d.ts b/other/hbuilderx-autotest/extension/common.d.ts new file mode 100644 index 0000000..f5c4db9 --- /dev/null +++ b/other/hbuilderx-autotest/extension/common.d.ts @@ -0,0 +1,17 @@ +import * as driver from '../core/hxdriver'; +export declare const openTextDocumentGoToLine: (link: string, line: string, row?: string) => Promise; +export declare const appendLine: (obj: any, output: any, config: any) => Promise; +export declare const getConfig: () => { + programData: any; + programPlugin: string; + lsDir: any; + tag: any; + sleep: any; + showPass: any; + shutOff: any; + storagePath: any; + completionsRetryCount: any; + openFile: any; + screenshotStoragePath: string; +}; +export declare const openhx: (config: any) => driver.HBuilderX; diff --git a/other/hbuilderx-autotest/extension/index.d.ts b/other/hbuilderx-autotest/extension/index.d.ts new file mode 100644 index 0000000..ac0ddb9 --- /dev/null +++ b/other/hbuilderx-autotest/extension/index.d.ts @@ -0,0 +1,3 @@ +import * as vscode from 'vscode'; +export declare function activate(context: vscode.ExtensionContext): void; +export declare function deactivate(): void; diff --git a/other/hbuilderx-autotest/i18n.d.ts b/other/hbuilderx-autotest/i18n.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/other/hbuilderx-autotest/i18n.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/other/hbuilderx-autotest/index.d.ts b/other/hbuilderx-autotest/index.d.ts new file mode 100644 index 0000000..cf53e64 --- /dev/null +++ b/other/hbuilderx-autotest/index.d.ts @@ -0,0 +1,2 @@ +export declare function activate(context: any): void; +export declare function deactivate(): void; diff --git a/other/hbuilderx-autotest/integration/index.d.ts b/other/hbuilderx-autotest/integration/index.d.ts new file mode 100644 index 0000000..8c5265c --- /dev/null +++ b/other/hbuilderx-autotest/integration/index.d.ts @@ -0,0 +1,3 @@ +export declare const findFiles: (dir: string, name?: string, recursion?: boolean) => Promise; +declare const runTest: (task: any) => Promise; +export default runTest; diff --git a/other/hbuilderx-autotest/integration/pm2Log.d.ts b/other/hbuilderx-autotest/integration/pm2Log.d.ts new file mode 100644 index 0000000..c2a8e9e --- /dev/null +++ b/other/hbuilderx-autotest/integration/pm2Log.d.ts @@ -0,0 +1,4 @@ +export declare const logStart: (id: string) => string; +export declare const logEnd: (id: string) => string; +export declare const getPm2RunLog: (id: string) => Promise; +export declare const getPm2Log: (filePath: string, id: string) => Promise; diff --git a/other/hbuilderx-autotest/integration/server.d.ts b/other/hbuilderx-autotest/integration/server.d.ts new file mode 100644 index 0000000..e00d1c0 --- /dev/null +++ b/other/hbuilderx-autotest/integration/server.d.ts @@ -0,0 +1,12 @@ +export declare const latestVersionByType: (type: string) => Promise; +export declare const dingtalkRobot: (access_token: string, msg: string, atMobiles?: string[]) => Promise; +export declare const task_get: (data: any) => Promise; +export declare const task_update: (data: any) => Promise; +export declare const task_update_2: (data: any) => Promise; +export declare const report_save: (data: any) => Promise; +export declare const test_end_upload_hx_log_to_server: (kwargs: { + file_name?: string; + upload_type: string; + file_path: string; + task_id: string; +}) => Promise; diff --git a/other/hbuilderx-autotest/language-services/app.d.ts b/other/hbuilderx-autotest/language-services/app.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/other/hbuilderx-autotest/language-services/app.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/other/hbuilderx-autotest/language-services/index.d.ts b/other/hbuilderx-autotest/language-services/index.d.ts new file mode 100644 index 0000000..f66c74b --- /dev/null +++ b/other/hbuilderx-autotest/language-services/index.d.ts @@ -0,0 +1,35 @@ +/** + * @description 测试任务管理 + */ +declare class TestTaskManage { + private baseUrl; + updateTask(task_id: string, status_text?: string, customFields?: any): void; + push_dingding_message(msg_type: string, test_project_list: string[] | undefined, task_id: string, hx_version?: string): Promise; +} +declare class RunHls extends TestTaskManage { + private task_id; + private hbuilderx_path; + private hbuilderx_plugin_path; + private testProjectDir; + constructor(); + init_env_config(hx_type: any): Promise<"" | undefined>; + /** + * @description 从about/pacakge.json读取HBuilderX版本号。目的用于自动化测试报告中显示HBuilderX版本号 + * @param {String} hx_type + * @returns + */ + read_hx_version(hx_type: string): Promise; + /** + * @description 初始化语言服务插件 + * @param hx_type + */ + init_ls_plugin(task_info: any): Promise; + update_testCase(branch: string): Promise; + /** + * @description 执行 node dist/app.js + */ + runHXDriverAppJS(args: string[]): Promise; + getProjectList(dirPath: string, hx_type: string): Promise; + run_main(task_list: any[]): Promise; +} +export default RunHls; diff --git a/other/hbuilderx-autotest/language-services/testConfig.d.ts b/other/hbuilderx-autotest/language-services/testConfig.d.ts new file mode 100644 index 0000000..47ccf55 --- /dev/null +++ b/other/hbuilderx-autotest/language-services/testConfig.d.ts @@ -0,0 +1,59 @@ +/** + * 此文件为自动化测试设置项文件 + * 由于平台和电脑不同, 自动化测试需要的参数也不同, 在此处统一进行设置 + */ +declare const hxProgramByType: (type: 'dev' | 'alpha' | 'release') => string; +/** + * @description 获取IP地址 + * @return + */ +declare function getLocalIPAddresses(): string; +/** + * 获取项目列表 + * @param isDeug 是否是调试模式,当为false时或为特定主机名(192.168.12.201电脑)时,会自动获取所有项目列表 + * @param dirPath 项目根目录 + * @returns Array 项目列表 + */ +declare function getProjectList(dirPath: string): string[]; +/** + * 项目路径集合 + * @param programPath hx程序所在路径 + * @param projectsRoot 所有测试用例项目路径 + * 路径下会有各个项目的文件夹(项目名称命名), 文件夹中是最后生成的测试报告 + */ +interface ProjectPathOptions { + programPath: string; + projectsRoot: string; + lsDir: string; + testReportDir?: string; + programData?: string; + programPlugin?: string; +} +/** + * 额外的配置参数, 后续可能需要更复杂的逻辑, 需要添加参数的时候, 在这里添加 + * @param hostname 电脑主机名 + * @param marketPluginDir 插件市场插件目录 + * @param marketPluginList 需要复制的插件列表 + */ +interface ExtOption { + marketPluginDir?: string; + marketPluginList?: string[]; +} +declare class AutoTestConfigOptions { + protected hxType: 'dev' | 'alpha' | 'release'; + protected tag: string[]; + protected programData: string; + protected programPlugin: string; + protected programRoot: string; + constructor(argv: any); + get projectPathOptions(): ProjectPathOptions; + get extOption(): ExtOption; + get HBuilderXVersion(): string; + get hlsPluginVersion(): string; + /** + * 验证函数, 验证当前操作系统和电脑使用者, 配置项正确 + * @returns + */ + verify(): boolean; +} +export { AutoTestConfigOptions, getLocalIPAddresses, hxProgramByType, getProjectList }; diff --git a/other/hbuilderx-autotest/language-services/testDataUpload.d.ts b/other/hbuilderx-autotest/language-services/testDataUpload.d.ts new file mode 100644 index 0000000..0c58b2f --- /dev/null +++ b/other/hbuilderx-autotest/language-services/testDataUpload.d.ts @@ -0,0 +1,6 @@ +declare const api_recordTestRun: (data: Object) => Promise; +declare const api_recordTestRunDetails: (data: any) => Promise; +declare const api_executeStatisticAnalysis: (task_id: any) => Promise; +declare const api_getTaskDetails: (task_id: any) => Promise; +declare const api_updateTaskForMongoDB: (task_id: any) => Promise; +export { api_recordTestRun, api_recordTestRunDetails, api_executeStatisticAnalysis, api_updateTaskForMongoDB, api_getTaskDetails }; diff --git a/other/hbuilderx-autotest/language-services/testSetup.d.ts b/other/hbuilderx-autotest/language-services/testSetup.d.ts new file mode 100644 index 0000000..97ec709 --- /dev/null +++ b/other/hbuilderx-autotest/language-services/testSetup.d.ts @@ -0,0 +1,17 @@ +/** + * @description Sends a DingDing message + * @param {String} msg The plain text message to be sent, which needs to contain the keyword configured on DingDing. + */ +declare function sendDingDingMsg(msg: string): void; +declare class TestSetup { + testCaseDir: string; + marketPluginList: string[]; + marketPluginDir: string; + HBuilderXPluginDir: string; + constructor(testOptions: any); + kill_HBuilderX(): void; + update_testCase(): void; + copy_plugin_to_HBuilderX(): void; + main(): Promise; +} +export { TestSetup, sendDingDingMsg }; diff --git a/other/hbuilderx-autotest/main.d.ts b/other/hbuilderx-autotest/main.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/other/hbuilderx-autotest/main.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/other/hbuilderx-autotest/package.json b/other/hbuilderx-autotest/package.json new file mode 100644 index 0000000..bf62af9 --- /dev/null +++ b/other/hbuilderx-autotest/package.json @@ -0,0 +1,6 @@ +{ + "name": "hbuilderx-autotest", + "version": "4.0.0", + "main": "index.js", + "license": "MIT" +} diff --git a/other/hbuilderx-autotest/readme.md b/other/hbuilderx-autotest/readme.md deleted file mode 100644 index 37f9127..0000000 --- a/other/hbuilderx-autotest/readme.md +++ /dev/null @@ -1 +0,0 @@ -# readme \ No newline at end of file diff --git a/other/hbuilderx-autotest/snapshot/compare_prev_version.d.ts b/other/hbuilderx-autotest/snapshot/compare_prev_version.d.ts new file mode 100644 index 0000000..bb91afd --- /dev/null +++ b/other/hbuilderx-autotest/snapshot/compare_prev_version.d.ts @@ -0,0 +1,8 @@ +/** + * @description 对比当前版本的截图与上一个版本的截图 + * @param taskId + * @param kwargs + * @returns + */ +declare function compareToThePreviousVersionScreenshot(taskId: string, kwargs: any): Promise; +export default compareToThePreviousVersionScreenshot; diff --git a/other/hbuilderx-autotest/snapshot/keep_version_base.d.ts b/other/hbuilderx-autotest/snapshot/keep_version_base.d.ts new file mode 100644 index 0000000..a744c2a --- /dev/null +++ b/other/hbuilderx-autotest/snapshot/keep_version_base.d.ts @@ -0,0 +1,20 @@ +declare class KeepSnapshotVersionBase { + taskId: string; + testTaskInfo: any; + HX_SNAPSHOT_ROOT_DIR: string; + funcId: string; + pcOsname: string; + testPcIp: string; + hx_version: string; + hxCurrentMainVersion: string; + currentTaskSnapshotOutputDir: string; + constructor(taskId?: string, testTaskInfo?: any); + get hxTestVersionStoreDir(): string; + initSetup(): boolean; + copyFileToBaseVersionDir(): void; + summaryOutputInfoToFile(thisTestFileData?: any[]): void; + calcURL(item: any): string; + summaryBaseVersionInfoToFile(thisTestFileData?: any[]): void; + main(): void; +} +export default KeepSnapshotVersionBase; diff --git a/other/hbuilderx-autotest/update.d.ts b/other/hbuilderx-autotest/update.d.ts new file mode 100644 index 0000000..8722a2d --- /dev/null +++ b/other/hbuilderx-autotest/update.d.ts @@ -0,0 +1 @@ +export declare const autoUpdateHBuilderXAutotest: (localDir: string) => Promise;