import { expect } from "chai" ; import { By , TreeItem , ViewItemAction } from "vscode-extension-tester" ; import { delay , fillEnvironment , fillUserdata , fireContextMenuAction , } from "../helper" ; import { IUserData } from "./interface-po" ; import { WorkbenchPageObject } from "./workbench-po" ; export class ServerTreeItemPageObject { private serverTreeItem : TreeItem ; private workbenchPO : WorkbenchPageObject ; constructor ( serverTreeItem ) { this . serverTreeItem = serverTreeItem ; this . workbenchPO = new WorkbenchPageObject ( ) ; } async connect ( environment , userData ) { this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Connect" ) ; this . workbenchPO . waitValidatingServer ( ) ; await delay ( 2000 ) ; await fillEnvironment ( environment ) ; await fillUserdata ( userData ) ; await this . workbenchPO . waitConnection ( ) ; expect ( await this . workbenchPO . isConnected ( await this . serverTreeItem . getLabel ( ) , environment ) ) . is . true ; } async isServerP20OrGreater ( ) { const tooltip = await this . serverTreeItem . getTooltip ( ) ; return tooltip . localeCompare ( "7.00.191205P" ) > 0 ; } async select ( ) { await this . serverTreeItem . select ( ) ; await delay ( ) ; } async isSelected ( ) { const klass = await this . serverTreeItem . getAttribute ( "class" ) ; return klass . indexOf ( "selected" ) > - 1 ; } async fireConnectAction ( ) { const action = await this . serverTreeItem . getActionButton ( "Connect" ) ; await action . click ( ) ; await delay ( ) ; } async isConnected ( ) { const icon = await this . serverTreeItem . findElement ( By . className ( "custom-view-tree-node-item-icon" ) ) ; const klass = await icon . getAttribute ( "style" ) ; return klass . indexOf ( "server.connected.svg" ) > - 1 ; } async isNotConnected ( ) { const icon = await this . serverTreeItem . findElement ( By . className ( "custom-view-tree-node-item-icon" ) ) ; const klass = await icon . getAttribute ( "style" ) ; return klass . indexOf ( "_server.svg" ) > - 1 ; } async fireDisconnectAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Disconnect" ) ; } async fireReconnectAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Reconnect" ) ; } async fireAddServerAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Add Server" ) ; } async fireDefragAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Defrag RPO" ) ; } async fireInclude ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Include" ) ; await delay ( 2000 ) ; } async fireCompileKey ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Compile Key" ) ; await delay ( 2000 ) ; } async fireCheckIntegrity ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "RPO check integrity" ) ; } async fireRepositoryLog ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Repository Log" ) ; } async fireObjectsInspector ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Objects Inspector" ) ; } async fireFunctionsInspector ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Functions Inspector" ) ; } async firePatchGenerationFromRPOAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Patch Generation (from RPO)" ) ; } async fireApplyPatchAction ( ) { await this . select ( ) ; await fireContextMenuAction ( this . serverTreeItem , "Patch Apply" ) ; } }